package me.km.plots; import me.km.api.GlobalText; import me.km.api.Module; import me.km.inventory.InventoryUtils; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.EnumHand; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ProtectionBuyPlot extends Protection { public ProtectionBuyPlot(Module m) { super(m); } /*@SubscribeEvent public void markRegion(PlayerInteractEvent.RightClickBlock e) { if(e.getHand() == EnumHand.OFF_HAND) { return; } World w = e.getWorld(); IBlockState state = w.getBlockState(e.getPos()); Block b = state.getBlock(); if(b != Blocks.WALL_SIGN && b != Blocks.STANDING_SIGN) { return; } EntityPlayer p = e.getEntityPlayer(); TileEntitySign sign = (TileEntitySign) w.getTileEntity(e.getPos()); if(sign == null) { this.getModule().send(p, GlobalText.shouldNotHappen()); return; } System.out.println("SIGN::" + sign.signText[0].getFormattedText()); if(!sign.signText[0].getFormattedText().equals("[§6Plot§0]")) { return; } int costs; try { String s = sign.signText[1].getUnformattedText(); if(!s.contains(" ")) { throw new NumberFormatException(); } costs = Integer.parseInt(s.substring(2, s.indexOf(" "))); if(costs < 0) { throw new NumberFormatException(); } } catch(NumberFormatException ex) { this.getModule().send(p, "Die angegebenen Kosten sind ungültig."); return; } if(InventoryUtils.searchInventoryFor(p.inventory, new ItemStack(Items.EMERALD), false) < costs) { this.getModule().send(p, "Du hast zu wenig Emeralds dabei."); return; } try { int id = Integer.parseInt(sign.signText[2].getUnformattedText()); if(id < 0) { throw new NumberFormatException(); } if(!this.getProtectionBank().doesPlotExist(id)) { this.getModule().send(p, "Der Plot mit der ID '" + id + "' ist nicht vorhanden."); return; } this.getProtectionBank().addPlayer(id, p.getGameProfile(), p); InventoryUtils.removeFromInventory(p.inventory, new ItemStack(Items.EMERALD, costs)); w.setBlockToAir(e.getPos()); } catch(NumberFormatException ex) { this.getModule().send(p, GlobalText.noNaturalNumber()); } }*/ }