package me.km.commands; import me.km.api.GlobalText; import me.km.api.Module; import me.km.api.ModuleCommand; import me.km.permissions.Permissions; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; public class CommandHat extends ModuleCommand { public CommandHat(Module m) { super("hat", m); super.setDescription("Setzt dir einen Hut auf"); super.setUsage("/hat"); super.setPermission(Permissions.HAT); } @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 == null || stack.getItem() == Items.AIR) { this.getModule().send(cs, "Du musst ein Item in der Hand halten."); return true; } if(p.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == ItemStack.EMPTY) { p.setItemStackToSlot(EntityEquipmentSlot.HEAD, stack); this.getModule().send(cs, "Du trägst nun einen Hut."); return true; } this.getModule().send(cs, "Du trägst bereits einen Hut."); return true; } }