DismountCommand class

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

Файл: com/hypixel/hytale/builtin/mounts/commands/DismountCommand.java

extends: AbstractPlayerCommand

Поля (7)

МодификаторыТипИмя
private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD
private final RequiredArg<PlayerRef> playerArg
PlayerRef var2
Ref var3
Store var4
Player var4
World var5

Методы (5)

МодификаторыВозвратСигнатура
DismountOtherCommand DismountOtherCommand()
protected void executeSyncprotected void executeSync(@Nonnull CommandContext var1)
if if(var4 == null)
abstract super super("dismount", "server.commands.dismount.desc")
abstract super super("server.commands.dismount.other.desc")

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.mounts.MountedComponent;
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.basecommands.AbstractPlayerCommand;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
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.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;

class="kw">public class DismountCommand class="kw">extends AbstractPlayerCommand {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_DISMOUNT_DISMOUNT_ATTEMPTED = Message.translation("server.commands.dismount.dismountAttempted");

   class="kw">public DismountCommand() {
      super("dismount", "server.commands.dismount.desc");
      this.addUsageVariant(new DismountCommand.DismountOtherCommand());
   }

   @Override
   class="kw">protected void execute(
      @Nonnull CommandContext var1, @Nonnull Store<EntityStore> var2, @Nonnull Ref<EntityStore> var3, @Nonnull PlayerRef var4, @Nonnull World var5
   ) {
      var2.tryRemoveComponent(var3, MountedComponent.getComponentType());
      var1.sendMessage(MESSAGE_COMMANDS_DISMOUNT_DISMOUNT_ATTEMPTED);
   }

   class="kw">private class="kw">static class DismountOtherCommand class="kw">extends CommandBase {
      @Nonnull
      class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld");
      @Nonnull
      class="kw">private class="kw">final RequiredArg<PlayerRef> playerArg = this.withRequiredArg("player", "server.commands.argtype.player.desc", ArgTypes.PLAYER_REF);

      DismountOtherCommand() {
         super("server.commands.dismount.other.desc");
      }

      @Override
      class="kw">protected void executeSync(@Nonnull CommandContext var1) {
         PlayerRef var2 = this.playerArg.get(var1);
         Ref var3 = var2.getReference();
         if (var3 != null && var3.isValid()) {
            Store var4 = var3.getStore();
            World var5 = var4.getExternalData().getWorld();
            var5.execute(() -> {
               Player var4 = var4.getComponent(var3, Player.getComponentType());
               if (var4 == null) {
                  var1.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
               } else {
                  var4.tryRemoveComponent(var3, MountedComponent.getComponentType());
                  var1.sendMessage(Message.translation("server.commands.dismount.dismountOther").param("username", var2.getUsername()));
               }
            });
         } else {
            var1.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
         }
      }
   }
}