SpawnPopulateCommand class
Пакет: com.hypixel.hytale.server.spawning.commands
Файл: com/hypixel/hytale/server/spawning/commands/SpawnPopulateCommand.java
extends: AbstractWorldCommand
Поля (4)
| Модификаторы | Тип | Имя |
|---|---|---|
|
int |
var4 |
|
NPCEntity |
var4 |
|
int |
var5 |
|
WorldConfig |
var5 |
Методы (1)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
|
super super("populate", "server.commands.spawning.populate.desc") |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.spawning.commands;
class="kw">import com.hypixel.hytale.component.RemoveReason;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.asset.type.environment.config.Environment;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.OptionalArg;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.WorldConfig;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.entities.NPCEntity;
class="kw">import javax.annotation.Nonnull;
class="kw">public class SpawnPopulateCommand class="kw">extends AbstractWorldCommand {
@Nonnull
class="kw">private class="kw">final OptionalArg<Environment> environmentArg = this.withOptionalArg(
"environment", "server.commands.spawning.populate.arg.environment.desc", ArgTypes.ENVIRONMENT_ASSET
);
class="kw">public SpawnPopulateCommand() {
super("populate", "server.commands.spawning.populate.desc");
}
@Override
class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
int var4 = this.environmentArg.provided(var1) ? Environment.getAssetMap().getIndex(this.environmentArg.get(var1).getId()) : Integer.MIN_VALUE;
var3.forEachEntityParallel(NPCEntity.getComponentType(), (var1x, var2x, var3x) -> {
NPCEntity var4 = var2x.getComponent(var1x, NPCEntity.getComponentType());
assert var4 != null;
int var5 = var4.getEnvironment();
if (var5 >= 0 && (var4 == Integer.MIN_VALUE || var4 == var5)) {
var3x.removeEntity(var2x.getReferenceTo(var1x), RemoveReason.REMOVE);
}
});
WorldConfig var5 = var2.getWorldConfig();
var5.setSpawningNPC(true);
var5.markChanged();
var1.sendMessage(Message.translation("server.commands.spawning.populate.success").param("worldName", var2.getName()));
}
}