EnableLocationMarkerCommand class

Пакет: com.hypixel.hytale.builtin.adventure.objectives.commands

Файл: com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveLocationMarkerCommand.java

extends: AbstractWorldCommand

Поля (1)

МодификаторыТипИмя
WorldConfig var4

Методы (2)

МодификаторыВозвратСигнатура
protected void executeprotected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3)
abstract super super("enable", "server.commands.objective.locationMarker.enable")

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.adventure.objectives.commands;

class="kw">import com.hypixel.hytale.builtin.adventure.objectives.ObjectivePlugin;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.config.ObjectiveLocationMarkerAsset;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.markers.objectivelocation.ObjectiveLocationMarker;
class="kw">import com.hypixel.hytale.common.util.StringUtil;
class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.Holder;
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.asset.type.model.config.Model;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandUtil;
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.basecommands.AbstractCommandCollection;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.entity.nameplate.Nameplate;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HiddenFromAdventurePlayers;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.Intangible;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.PersistentModel;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
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 javax.annotation.Nonnull;

class="kw">public class ObjectiveLocationMarkerCommand class="kw">extends AbstractCommandCollection {
   class="kw">public ObjectiveLocationMarkerCommand() {
      super("locationmarker", "server.commands.objective.locationMarker");
      this.addAliases("marker");
      this.addSubCommand(new ObjectiveLocationMarkerCommand.AddLocationMarkerCommand());
      this.addSubCommand(new ObjectiveLocationMarkerCommand.EnableLocationMarkerCommand());
      this.addSubCommand(new ObjectiveLocationMarkerCommand.DisableLocationMarkerCommand());
   }

   class="kw">public class="kw">static class AddLocationMarkerCommand class="kw">extends AbstractPlayerCommand {
      @Nonnull
      class="kw">private class="kw">final RequiredArg<String> locationMarkerArg = this.withRequiredArg(
         "locationMarkerId", "server.commands.objective.locationMarker.add.arg.locationMarkerId.desc", ArgTypes.STRING
      );

      class="kw">public AddLocationMarkerCommand() {
         super("add", "server.commands.objective.locationMarker.add");
      }

      @Override
      class="kw">protected void execute(
         @Nonnull CommandContext var1, @Nonnull Store<EntityStore> var2, @Nonnull Ref<EntityStore> var3, @Nonnull PlayerRef var4, @Nonnull World var5
      ) {
         TransformComponent var6 = var2.getComponent(var3, TransformComponent.getComponentType());
         if (var6 != null) {
            String var7 = this.locationMarkerArg.get(var1);
            if (ObjectiveLocationMarkerAsset.getAssetMap().getAsset(var7) == null) {
               var1.sendMessage(Message.translation("server.commands.objective.locationMarker.notFound").param("id", var7));
               var1.sendMessage(
                  Message.translation("server.general.failed.didYouMean")
                     .param(
                        "choices",
                        StringUtil.sortByFuzzyDistance(var7, ObjectiveLocationMarkerAsset.getAssetMap().getAssetMap().keySet(), CommandUtil.RECOMMEND_COUNT)
                           .toString()
                     )
               );
            } else {
               Holder var8 = EntityStore.REGISTRY.newHolder();
               var8.addComponent(ObjectiveLocationMarker.getComponentType(), new ObjectiveLocationMarker(var7));
               Model var9 = ObjectivePlugin.get().getObjectiveLocationMarkerModel();
               var8.addComponent(ModelComponent.getComponentType(), new ModelComponent(var9));
               var8.addComponent(PersistentModel.getComponentType(), new PersistentModel(var9.toReference()));
               var8.addComponent(Nameplate.getComponentType(), new Nameplate(var7));
               TransformComponent var10 = new TransformComponent(var6.getPosition(), var6.getRotation());
               var8.addComponent(TransformComponent.getComponentType(), var10);
               var8.ensureComponent(UUIDComponent.getComponentType());
               var8.ensureComponent(Intangible.getComponentType());
               var8.ensureComponent(HiddenFromAdventurePlayers.getComponentType());
               var2.addEntity(var8, AddReason.SPAWN);
               var1.sendMessage(Message.translation("server.commands.objective.locationMarker.added").param("id", var7));
            }
         }
      }
   }

   class="kw">public class="kw">static class DisableLocationMarkerCommand class="kw">extends AbstractWorldCommand {
      class="kw">public DisableLocationMarkerCommand() {
         super("disable", "server.commands.objective.locationMarker.disable");
      }

      @Override
      class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
         WorldConfig var4 = var2.getWorldConfig();
         var4.setObjectiveMarkersEnabled(false);
         var4.markChanged();
         var1.sendMessage(Message.translation("server.commands.objective.locationMarker.disabled").param("worldName", var2.getName()));
      }
   }

   class="kw">public class="kw">static class EnableLocationMarkerCommand class="kw">extends AbstractWorldCommand {
      class="kw">public EnableLocationMarkerCommand() {
         super("enable", "server.commands.objective.locationMarker.enable");
      }

      @Override
      class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
         WorldConfig var4 = var2.getWorldConfig();
         var4.setObjectiveMarkersEnabled(true);
         var4.markChanged();
         var1.sendMessage(Message.translation("server.commands.objective.locationMarker.enabled").param("worldName", var2.getName()));
      }
   }
}