|
| 1 | +package com.bencrow11.betterbreeding; |
| 2 | + |
| 3 | +import com.google.common.collect.Lists; |
| 4 | +import com.mojang.brigadier.CommandDispatcher; |
| 5 | +import com.mojang.brigadier.exceptions.CommandSyntaxException; |
| 6 | +import com.pixelmonmod.pixelmon.api.pokemon.Pokemon; |
| 7 | +import com.pixelmonmod.pixelmon.api.storage.PartyStorage; |
| 8 | +import com.pixelmonmod.pixelmon.api.storage.StorageProxy; |
| 9 | +import com.pixelmonmod.pixelmon.comm.CommandChatHandler; |
| 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.text.TextFormatting; |
| 15 | +import net.minecraftforge.fml.server.ServerLifecycleHooks; |
| 16 | +import net.minecraftforge.server.permission.PermissionAPI; |
| 17 | +import org.w3c.dom.Text; |
| 18 | + |
| 19 | +import java.util.List; |
| 20 | +import java.util.Objects; |
| 21 | + |
| 22 | +public class CommandDebug extends PixelCommand { |
| 23 | + |
| 24 | + |
| 25 | + public CommandDebug(CommandDispatcher<CommandSource> dispatcher) { |
| 26 | + super(dispatcher); |
| 27 | + } |
| 28 | + |
| 29 | + public String getName() { |
| 30 | + return "pbdebug"; |
| 31 | + } |
| 32 | + |
| 33 | + @Override |
| 34 | + public List<String> getAliases() { |
| 35 | + return Lists.newArrayList("pbdebug"); |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public void execute(CommandSource sender, String[] args) throws CommandException, CommandSyntaxException { |
| 40 | + // Checks for permission to use the command |
| 41 | + if (!PermissionAPI.hasPermission(sender.asPlayer(), "pokebuilder.admin")) { |
| 42 | + CommandChatHandler.sendChat(sender, TextFormatting.RED + "You do not have permission for this command!"); |
| 43 | + } else { |
| 44 | + // checks arg amount is correct |
| 45 | + if (args.length != 1) { |
| 46 | + CommandChatHandler.sendChat(sender, TextFormatting.RED + "Usage: /pbdebug <slot>"); |
| 47 | + } else { |
| 48 | + try { |
| 49 | + int slot = Integer.parseInt(args[0]); |
| 50 | + PartyStorage storage = StorageProxy.getParty(sender.asPlayer().getUniqueID()); |
| 51 | + Pokemon pokemon = storage.get(slot - 1); |
| 52 | + |
| 53 | + if (pokemon == null) { |
| 54 | + CommandChatHandler.sendChat(sender, TextFormatting.RED + "No Pokemon in slot " + slot); |
| 55 | + return; |
| 56 | + } |
| 57 | + |
| 58 | + // Prints pokemon information to chat |
| 59 | + CommandChatHandler.sendChat(sender, TextFormatting.AQUA + "Pokebuilt: " + pokemon.hasFlag( |
| 60 | + "Pokebuilder")); |
| 61 | + CommandChatHandler.sendChat(sender, TextFormatting.AQUA + "Can breed: " + !pokemon.hasFlag( |
| 62 | + "unbreedable")); |
| 63 | + CommandChatHandler.sendChat(sender, |
| 64 | + TextFormatting.AQUA + "Current Owner: " + pokemon.getPersistentData().getString( |
| 65 | + "currentOwner")); |
| 66 | + |
| 67 | + } catch (Exception error) { |
| 68 | + CommandChatHandler.sendChat(sender, TextFormatting.RED + "Usage: /pbdebug <slot>"); |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | +} |
0 commit comments