This commit is contained in:
boy0001 2015-02-20 19:51:34 +11:00
parent 202ec71bb2
commit 0dc0b29ea7

View File

@ -122,7 +122,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
PlotSquared.loadWorld(world.getName(), null); PlotSquared.loadWorld(world.getName(), null);
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onChunkLoad(final ChunkLoadEvent event) { public static void onChunkLoad(final ChunkLoadEvent event) {
final String worldname = event.getWorld().getName(); final String worldname = event.getWorld().getName();
@ -136,7 +136,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onJoin(final PlayerJoinEvent event) { public static void onJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
@ -147,8 +147,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
final StringWrapper name = new StringWrapper(username); final StringWrapper name = new StringWrapper(username);
final UUID uuid = UUIDHandler.getUUID(player); final UUID uuid = UUIDHandler.getUUID(player);
UUIDHandler.add(name, uuid); UUIDHandler.add(name, uuid);
Location loc = BukkitUtil.getLocation(player.getLocation()); final Location loc = BukkitUtil.getLocation(player.getLocation());
Plot plot = PlotHelper.getPlot(loc); final Plot plot = PlotHelper.getPlot(loc);
if (plot == null) { if (plot == null) {
return; return;
} }
@ -158,17 +158,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
plotEntry(player, plot); plotEntry(player, plot);
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void PlayerMove(final PlayerMoveEvent event) { public static void PlayerMove(final PlayerMoveEvent event) {
Location f = BukkitUtil.getLocation(event.getFrom()); final Location f = BukkitUtil.getLocation(event.getFrom());
Location t = BukkitUtil.getLocation(event.getTo()); final Location t = BukkitUtil.getLocation(event.getTo());
if ((f.getX() != t.getX()) || (f.getZ() != t.getZ())) { if ((f.getX() != t.getX()) || (f.getZ() != t.getZ())) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (Settings.TELEPORT_DELAY != 0) { if (Settings.TELEPORT_DELAY != 0) {
TaskManager.TELEPORT_QUEUE.remove(player.getName()); TaskManager.TELEPORT_QUEUE.remove(player.getName());
} }
String worldname = t.getWorld(); final String worldname = t.getWorld();
if (!isPlotWorld(worldname)) { if (!isPlotWorld(worldname)) {
return; return;
} }
@ -183,8 +183,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
event.getTo().setZ(border); event.getTo().setZ(border);
} else if (t.getZ() < -border) { } else if (t.getZ() < -border) {
event.getTo().setZ(-border); event.getTo().setZ(-border);
} } else {
else {
passed = false; passed = false;
} }
if (passed) { if (passed) {
@ -195,7 +194,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
Plot plot = getCurrentPlot(t); Plot plot = getCurrentPlot(t);
if (plot != null) { if (plot != null) {
if (plot.denied.size() > 0) { if (plot.denied.size() > 0) {
UUID uuid = UUIDHandler.getUUID(player); final UUID uuid = UUIDHandler.getUUID(player);
if (plot.isDenied(uuid)) { if (plot.isDenied(uuid)) {
if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied");
@ -213,10 +212,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public static void onChat(final AsyncPlayerChatEvent event) { public static void onChat(final AsyncPlayerChatEvent event) {
Player player = event.getPlayer(); final Player player = event.getPlayer();
final String world = player.getWorld().getName(); final String world = player.getWorld().getName();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
@ -225,19 +224,19 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (!plotworld.PLOT_CHAT) { if (!plotworld.PLOT_CHAT) {
return; return;
} }
Location loc = BukkitUtil.getLocation(player); final Location loc = BukkitUtil.getLocation(player);
if (getCurrentPlot(loc) == null) { final Plot plot = getCurrentPlot(loc);
if (plot == null) {
return; return;
} }
final String message = event.getMessage(); final String message = event.getMessage();
String format = C.PLOT_CHAT_FORMAT.s(); String format = C.PLOT_CHAT_FORMAT.s();
final String sender = event.getPlayer().getDisplayName(); final String sender = event.getPlayer().getDisplayName();
final Plot plot = getCurrentPlot(loc);
final PlotId id = plot.id; final PlotId id = plot.id;
final Set<Player> recipients = event.getRecipients(); final Set<Player> recipients = event.getRecipients();
recipients.clear(); recipients.clear();
for (final Player p : Bukkit.getOnlinePlayers()) { for (final Player p : Bukkit.getOnlinePlayers()) {
if (getCurrentPlot(p.getLocation()) == plot) { if (getCurrentPlot(BukkitUtil.getLocation(p)) == plot) {
recipients.add(p); recipients.add(p);
} }
} }
@ -245,14 +244,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
format = ChatColor.translateAlternateColorCodes('&', format); format = ChatColor.translateAlternateColorCodes('&', format);
event.setFormat(format); event.setFormat(format);
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public static void BlockDestroy(final BlockBreakEvent event) { public static void BlockDestroy(final BlockBreakEvent event) {
final World world = event.getPlayer().getWorld(); final Player player = event.getPlayer();
final String world = player.getWorld().getName();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
} }
final Player player = event.getPlayer();
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
final Plot plot = getCurrentPlot(loc); final Plot plot = getCurrentPlot(loc);
if (plot != null) { if (plot != null) {
@ -268,7 +267,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (!plot.isAdded(event.getPlayer())) { final UUID uuid = UUIDHandler.getUUID(player);
if (!plot.isAdded(uuid)) {
final Flag destroy = FlagManager.getPlotFlag(plot, "break"); final Flag destroy = FlagManager.getPlotFlag(plot, "break");
final Block block = event.getBlock(); final Block block = event.getBlock();
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
@ -292,7 +292,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onBigBoom(final EntityExplodeEvent event) { public static void onBigBoom(final EntityExplodeEvent event) {
final World world = event.getLocation().getWorld(); final World world = event.getLocation().getWorld();
@ -325,7 +325,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) {
final World world = event.getBlock().getWorld(); final World world = event.getBlock().getWorld();
@ -356,19 +356,22 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (!plot.isAdded(p)) { } else {
if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { final UUID uuid = UUIDHandler.getUUID(p);
if (isPlotArea(loc)) { if (!plot.isAdded(uuid)) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) {
event.setCancelled(true); if (isPlotArea(loc)) {
return; PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other");
event.setCancelled(true);
return;
}
} }
} }
} }
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onEntityBlockForm(final EntityBlockFormEvent e) { public static void onEntityBlockForm(final EntityBlockFormEvent e) {
final World world = e.getBlock().getWorld(); final World world = e.getBlock().getWorld();
@ -381,7 +384,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onBS(final BlockSpreadEvent e) { public static void onBS(final BlockSpreadEvent e) {
final Block b = e.getBlock(); final Block b = e.getBlock();
@ -394,7 +397,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onBF(final BlockFormEvent e) { public static void onBF(final BlockFormEvent e) {
final Block b = e.getBlock(); final Block b = e.getBlock();
@ -407,7 +410,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onBD(final BlockDamageEvent e) { public static void onBD(final BlockDamageEvent e) {
final Block b = e.getBlock(); final Block b = e.getBlock();
@ -420,7 +423,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onFade(final BlockFadeEvent e) { public static void onFade(final BlockFadeEvent e) {
final Block b = e.getBlock(); final Block b = e.getBlock();
@ -433,7 +436,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onChange(final BlockFromToEvent e) { public static void onChange(final BlockFromToEvent e) {
final Block b = e.getToBlock(); final Block b = e.getToBlock();
@ -446,7 +449,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onGrow(final BlockGrowEvent e) { public static void onGrow(final BlockGrowEvent e) {
final Block b = e.getBlock(); final Block b = e.getBlock();
@ -459,7 +462,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public static void onBlockPistonExtend(final BlockPistonExtendEvent e) { public static void onBlockPistonExtend(final BlockPistonExtendEvent e) {
if (isInPlot(e.getBlock().getLocation())) { if (isInPlot(e.getBlock().getLocation())) {
@ -472,7 +475,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public static void onBlockPistonRetract(final BlockPistonRetractEvent e) { public static void onBlockPistonRetract(final BlockPistonRetractEvent e) {
final Block b = e.getRetractLocation().getBlock(); final Block b = e.getRetractLocation().getBlock();
@ -485,7 +488,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onStructureGrow(final StructureGrowEvent e) { public static void onStructureGrow(final StructureGrowEvent e) {
final List<BlockState> blocks = e.getBlocks(); final List<BlockState> blocks = e.getBlocks();
@ -502,7 +505,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onInteract(final PlayerInteractEvent event) { public static void onInteract(final PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
@ -512,7 +515,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (block == null) { if (block == null) {
return; return;
} }
final World world = event.getPlayer().getWorld(); final Player player = event.getPlayer();
final String world = player.getWorld().getName();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
} }
@ -532,7 +536,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return; return;
} }
if (!plot.isAdded(player)) { final UUID uuid = UUIDHandler.getUUID(player);
if (!plot.isAdded(uuid)) {
if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) {
return; return;
} }
@ -551,7 +556,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void MobSpawn(final CreatureSpawnEvent event) { public static void MobSpawn(final CreatureSpawnEvent event) {
final World world = event.getLocation().getWorld(); final World world = event.getLocation().getWorld();
@ -578,7 +583,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onBlockIgnite(final BlockIgniteEvent e) { public static void onBlockIgnite(final BlockIgniteEvent e) {
final World world; final World world;
@ -634,7 +639,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onTeleport(final PlayerTeleportEvent event) { public static void onTeleport(final PlayerTeleportEvent event) {
final Location f = BukkitUtil.getLocation(event.getFrom()); final Location f = BukkitUtil.getLocation(event.getFrom());
@ -664,7 +669,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onBucketEmpty(final PlayerBucketEmptyEvent e) { public static void onBucketEmpty(final PlayerBucketEmptyEvent e) {
final BlockFace bf = e.getBlockFace(); final BlockFace bf = e.getBlockFace();
@ -705,7 +710,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public static void onInventoryClick(final InventoryClickEvent event) { public static void onInventoryClick(final InventoryClickEvent event) {
if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) { if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) {
@ -713,7 +718,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
} }
@EventHandler @EventHandler
public static void onLeave(final PlayerQuitEvent event) { public static void onLeave(final PlayerQuitEvent event) {
if (Setup.setupMap.containsKey(event.getPlayer().getName())) { if (Setup.setupMap.containsKey(event.getPlayer().getName())) {
@ -730,7 +735,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onBucketFill(final PlayerBucketFillEvent e) { public static void onBucketFill(final PlayerBucketFillEvent e) {
final Block b = e.getBlockClicked(); final Block b = e.getBlockClicked();
@ -771,7 +776,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onHangingPlace(final HangingPlaceEvent e) { public static void onHangingPlace(final HangingPlaceEvent e) {
final Block b = e.getBlock(); final Block b = e.getBlock();
@ -807,7 +812,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { public static void onHangingBreakByEntity(final HangingBreakByEntityEvent e) {
final Entity r = e.getRemover(); final Entity r = e.getRemover();
@ -845,7 +850,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) {
final Location l = e.getRightClicked().getLocation(); final Location l = e.getRightClicked().getLocation();
@ -890,7 +895,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onVehicleDestroy(final VehicleDestroyEvent e) { public static void onVehicleDestroy(final VehicleDestroyEvent e) {
final Location l = e.getVehicle().getLocation(); final Location l = e.getVehicle().getLocation();
@ -931,7 +936,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) {
final Location l = e.getEntity().getLocation(); final Location l = e.getEntity().getLocation();
@ -1000,7 +1005,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onPlayerEggThrow(final PlayerEggThrowEvent e) { public static void onPlayerEggThrow(final PlayerEggThrowEvent e) {
final Location l = e.getEgg().getLocation(); final Location l = e.getEgg().getLocation();
@ -1032,10 +1037,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void BlockCreate(final BlockPlaceEvent event) { public void BlockCreate(final BlockPlaceEvent event) {
final World world = event.getPlayer().getWorld(); final Player player = event.getPlayer();
final String world = player.getWorld().getName();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
} }