package me.km.commands; import me.km.api.GlobalText; import me.km.api.Module; import me.km.api.ModuleCommand; import me.km.capabilities.CapabilitiesEvents; import me.km.capabilities.DefenseProvider; import me.km.capabilities.IDefense; import me.km.permissions.Permissions; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.text.TextComponentString; public class CommandTest extends ModuleCommand { public CommandTest(Module m) { super("test", m); super.setDescription("Für Tests"); super.setUsage("/test"); super.setPermission(Permissions.TEST); } @Override public boolean execute(ICommandSender cs, String[] arg) { if(!(cs instanceof EntityPlayer)) { this.getModule().send(cs, GlobalText.onlyPlayer()); return true; } EntityPlayer p = (EntityPlayer) cs; ItemStack stack = p.getHeldItemMainhand(); if(stack.hasCapability(DefenseProvider.DEFENSE_CAP, null)) { IDefense wusi = stack.getCapability(DefenseProvider.DEFENSE_CAP, null); if(arg.length >= 1) { try { wusi.setMagicDefense(Integer.parseInt(arg[0])); } catch(NumberFormatException ex) { } } else { cs.sendMessage(new TextComponentString(" " + wusi.getMagicDefense())); } } else { cs.sendMessage(new TextComponentString("Nichts")); } return true; } }