ProtectionMarkPlot.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package me.km.plots;
  2. import me.km.api.Module;
  3. import java.util.HashMap;
  4. import java.util.UUID;
  5. import me.km.KajetansMod;
  6. import me.km.permissions.Permissions;
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.init.Items;
  9. import net.minecraft.util.EnumHand;
  10. import net.minecraft.util.math.BlockPos;
  11. import net.minecraftforge.event.entity.player.PlayerInteractEvent;
  12. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  13. public class ProtectionMarkPlot extends Protection
  14. {
  15. private final HashMap<UUID, BlockPos> coord1;
  16. private final HashMap<UUID, BlockPos> coord2;
  17. public ProtectionMarkPlot(Module m)
  18. {
  19. super(m);
  20. coord1 = KajetansMod.plots.getCommand(CommandPlot.class).coord1;
  21. coord2 = KajetansMod.plots.getCommand(CommandPlot.class).coord2;
  22. }
  23. @SubscribeEvent
  24. public void markRegionRightClick(PlayerInteractEvent.RightClickBlock e)
  25. {
  26. if(e.getHand() == EnumHand.OFF_HAND)
  27. {
  28. return;
  29. }
  30. EntityPlayer p = e.getEntityPlayer();
  31. if(KajetansMod.perms.has(p, Permissions.PLOT_MARK) && p.getHeldItemMainhand().getItem() == Items.WOODEN_SWORD && p.isCreative())
  32. {
  33. BlockPos pos = e.getPos();
  34. coord2.put(p.getUniqueID(), pos);
  35. this.getModule().send(p, "Punkt 2 wurde ausgewählt (" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + ")");
  36. e.setCanceled(true);
  37. }
  38. }
  39. @SubscribeEvent
  40. public void markRegionLeftClick(PlayerInteractEvent.LeftClickBlock e)
  41. {
  42. if(e.getHand() == EnumHand.OFF_HAND)
  43. {
  44. return;
  45. }
  46. EntityPlayer p = e.getEntityPlayer();
  47. if(KajetansMod.perms.has(p, Permissions.PLOT_MARK) && p.getHeldItemMainhand().getItem() == Items.WOODEN_SWORD && p.isCreative())
  48. {
  49. BlockPos pos = e.getPos();
  50. coord1.put(p.getUniqueID(), pos);
  51. this.getModule().send(p, "Punkt 1 wurde ausgewählt (" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + ")");
  52. e.setCanceled(true);
  53. }
  54. }
  55. }