Advertisement
Guest User

Untitled

a guest
Jun 24th, 2022
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.76 KB | None | 0 0
  1. package fr.pokepixel.pokedisplay;
  2.  
  3. import com.mojang.brigadier.CommandDispatcher;
  4. import com.mojang.brigadier.exceptions.CommandSyntaxException;
  5. import com.pixelmonmod.pixelmon.api.command.PixelmonCommandUtils;
  6. import com.pixelmonmod.pixelmon.api.pokemon.Pokemon;
  7. import com.pixelmonmod.pixelmon.api.storage.PlayerPartyStorage;
  8. import com.pixelmonmod.pixelmon.api.storage.StorageProxy;
  9. import com.pixelmonmod.pixelmon.api.util.helpers.CommandHelper;
  10. import com.pixelmonmod.pixelmon.command.PixelCommand;
  11. import net.minecraft.command.CommandException;
  12. import net.minecraft.command.CommandSource;
  13. import net.minecraft.entity.player.ServerPlayerEntity;
  14. import net.minecraft.util.Util;
  15. import net.minecraft.util.text.StringTextComponent;
  16. import net.minecraft.util.text.TextFormatting;
  17. import net.minecraftforge.fml.server.ServerLifecycleHooks;
  18.  
  19. import static java.lang.Integer.parseInt;
  20.  
  21. public class PokeDisplayCmd extends PixelCommand {
  22.  
  23.     public PokeDisplayCmd(CommandDispatcher<CommandSource> dispatcher) {
  24.         super(dispatcher, "pokedisplay", "/pokedisplay <slot>", 0);
  25.     }
  26.  
  27.     @Override
  28.     public void execute(CommandSource commandSource, String[] args) throws CommandException, CommandSyntaxException {
  29.  
  30.         ServerPlayerEntity hrac = commandSource.asPlayer();
  31.  
  32.  
  33.         if (args.length < 1) {
  34.             commandSource.sendErrorMessage(PixelmonCommandUtils.format(TextFormatting.RED, "Pouzij /pokedisplay <slot 1-6>"));
  35.             PixelmonCommandUtils.endCommand(this.getUsage(commandSource));
  36.         }
  37.  
  38.         if (args.length == 1) {
  39.             int slot2 = parseInt(args[0]);
  40.             if (slot2 > 0 && slot2 < 7) {
  41.                 int slot = slot2 - 1;
  42.                 PlayerPartyStorage storage = StorageProxy.getParty(hrac);
  43.                 Pokemon pokemon = storage.get(slot);
  44.                 if (pokemon == null) {
  45.                     commandSource.sendErrorMessage(PixelmonCommandUtils.format(TextFormatting.RED, "Pouzij /pokedisplay <slot 1-6>"));
  46.                     return;
  47.                 }
  48.                 else if (!pokemon.isEgg()) {
  49.                     for (ServerPlayerEntity player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) {
  50.                         player.sendMessage(CommandHelper.getHoverTextPokemon(pokemon), Util.DUMMY_UUID);
  51.                         player.sendMessage(new StringTextComponent("Test funkce.."), Util.DUMMY_UUID);
  52.                     }
  53.                 }
  54.             } else {
  55.                 commandSource.sendErrorMessage(PixelmonCommandUtils.format(TextFormatting.RED, "Zadej slot 1-6"));
  56.             }
  57.         }
  58.  
  59.         if (args.length == 2) {
  60.             commandSource.sendErrorMessage(PixelmonCommandUtils.format(TextFormatting.RED, "Zadej slot 1-6"));
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement