EntityNameplateCommand class
Пакет: com.hypixel.hytale.server.core.command.commands.world.entity
Файл: com/hypixel/hytale/server/core/command/commands/world/entity/EntityNameplateCommand.java
extends: AbstractWorldCommand
Поля (7)
| Модификаторы | Тип | Имя |
|---|---|---|
|
private static final Message |
MESSAGE_COMMANDS_ENTITY_NAMEPLATE_REMOVED |
final |
Message |
MESSAGE_GENERAL_NO_ENTITY_IN_VIEW |
|
private static final Message |
MESSAGE_GENERAL_NO_ENTITY_IN_VIEW |
|
private final EntityWrappedArg |
entityArg |
|
Ref |
var4 |
|
Ref |
var4 |
|
String |
var5 |
Методы (4)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
public |
Removepublic Remove() |
|
protected void |
executeprotected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) |
abstract |
|
super super("nameplate", "server.commands.entity.nameplate.desc") |
abstract |
|
super super("server.commands.entity.nameplate.remove.desc") |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.command.commands.world.entity;
class="kw">import com.hypixel.hytale.component.Ref;
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.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.EntityWrappedArg;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
class="kw">import com.hypixel.hytale.server.core.entity.nameplate.Nameplate;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">public class EntityNameplateCommand class="kw">extends AbstractWorldCommand {
class="kw">private class="kw">static class="kw">final Message MESSAGE_GENERAL_NO_ENTITY_IN_VIEW = Message.translation("server.general.noEntityInView");
class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_ENTITY_NAMEPLATE_UPDATED = Message.translation("server.commands.entity.nameplate.updated");
@Nonnull
class="kw">private class="kw">final EntityWrappedArg entityArg = this.withOptionalArg("entity", "server.commands.entity.nameplate.entity.desc", ArgTypes.ENTITY_ID);
@Nonnull
class="kw">private class="kw">final RequiredArg<String> textArg = this.withRequiredArg("text", "server.commands.entity.nameplate.text.desc", ArgTypes.STRING);
class="kw">public EntityNameplateCommand() {
super("nameplate", "server.commands.entity.nameplate.desc");
this.addUsageVariant(new EntityNameplateCommand.Remove());
}
@Override
class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
Ref var4 = this.entityArg.get(var3, var1);
if (var4 != null && var4.isValid()) {
String var5 = this.textArg.get(var1);
var3.ensureAndGetComponent(var4, Nameplate.getComponentType()).setText(var5);
var1.sendMessage(MESSAGE_COMMANDS_ENTITY_NAMEPLATE_UPDATED);
} else {
var1.sendMessage(MESSAGE_GENERAL_NO_ENTITY_IN_VIEW);
}
}
class="kw">public class="kw">static class Remove class="kw">extends AbstractWorldCommand {
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_GENERAL_NO_ENTITY_IN_VIEW = Message.translation("server.general.noEntityInView");
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_ENTITY_NAMEPLATE_REMOVED = Message.translation("server.commands.entity.nameplate.removed");
@Nonnull
class="kw">private class="kw">final EntityWrappedArg entityArg = this.withOptionalArg("entity", "server.commands.entity.nameplate.entity.desc", ArgTypes.ENTITY_ID);
class="kw">public Remove() {
super("server.commands.entity.nameplate.remove.desc");
}
@Override
class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
Ref var4 = this.entityArg.get(var3, var1);
if (var4 != null && var4.isValid()) {
var3.tryRemoveComponent(var4, Nameplate.getComponentType());
var1.sendMessage(MESSAGE_COMMANDS_ENTITY_NAMEPLATE_REMOVED);
} else {
var1.sendMessage(MESSAGE_GENERAL_NO_ENTITY_IN_VIEW);
}
}
}
}