This commit is contained in:
boy0001 2015-02-20 19:47:33 +11:00
parent 2f771832a8
commit 202ec71bb2
2 changed files with 80 additions and 98 deletions

View File

@ -143,110 +143,96 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (!player.hasPlayedBefore()) { if (!player.hasPlayedBefore()) {
player.saveData(); player.saveData();
} }
// UUID stuff
final String username = player.getName(); final String username = player.getName();
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()); Location loc = BukkitUtil.getLocation(player.getLocation());
// textures(event.getPlayer());
Plot plot = PlotHelper.getPlot(loc); Plot plot = PlotHelper.getPlot(loc);
if (plot == null) { if (plot == null) {
return; return;
} }
if (Settings.TELEPORT_ON_LOGIN) {
BukkitUtil.teleportPlayer(player, PlotHelper.getPlotHomeDefault(plot));
if (isInPlot(loc)) { PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD);
if (Settings.TELEPORT_ON_LOGIN) {
BukkitUtil.teleportPlayer(player, PlotHelper.getPlotHomeDefault(getPlot(event.getPlayer())));
PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD);
} else {
plotEntry(event.getPlayer(), getCurrentPlot(event.getPlayer().getLocation()));
}
} }
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) {
try { Location f = BukkitUtil.getLocation(event.getFrom());
Location t = BukkitUtil.getLocation(event.getTo());
if ((f.getX() != t.getX()) || (f.getZ() != t.getZ())) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Location f = event.getFrom(); if (Settings.TELEPORT_DELAY != 0) {
final Location t = event.getTo(); TaskManager.TELEPORT_QUEUE.remove(player.getName());
final Location q = new Location(t.getWorld(), t.getBlockX(), 0, t.getZ()); }
if ((f.getBlockX() != q.getBlockX()) || (f.getBlockZ() != q.getBlockZ())) { String worldname = t.getWorld();
if ((Settings.TELEPORT_DELAY != 0) && (TaskManager.TELEPORT_QUEUE.size() > 0)) { if (!isPlotWorld(worldname)) {
final String name = player.getName(); return;
if (TaskManager.TELEPORT_QUEUE.contains(name)) { }
TaskManager.TELEPORT_QUEUE.remove(name); if (PlotHelper.worldBorder.containsKey(worldname)) {
} final int border = PlotHelper.getBorder(worldname);
boolean passed = true;
if (t.getX() > border) {
event.getTo().setX(border);
} else if (t.getX() < -border) {
event.getTo().setX(-border);
} else if (t.getZ() > border) {
event.getTo().setZ(border);
} else if (t.getZ() < -border) {
event.getTo().setZ(-border);
} }
if (!isPlotWorld(player.getWorld())) { else {
passed = false;
}
if (passed) {
PlayerFunctions.sendMessage(player, C.BORDER);
return; return;
} }
final String worldname = q.getWorld().getName(); }
if (PlotHelper.worldBorder.containsKey(worldname)) { Plot plot = getCurrentPlot(t);
final int border = PlotHelper.getBorder(worldname); if (plot != null) {
boolean passed = false; if (plot.denied.size() > 0) {
if (t.getBlockX() > border) { UUID uuid = UUIDHandler.getUUID(player);
q.setX(border); if (plot.isDenied(uuid)) {
passed = true;
} else if (t.getBlockX() < -border) {
q.setX(-border);
passed = true;
}
if (t.getBlockZ() > border) {
q.setZ(border);
passed = true;
} else if (t.getBlockZ() < -border) {
q.setZ(-border);
passed = true;
}
if (passed) {
q.setY(t.getBlockY());
event.setTo(q);
PlayerFunctions.sendMessage(player, C.BORDER);
return;
}
}
Plot plot = getCurrentPlot(q);
if (plot != null) {
if (plot.deny_entry(player)) {
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");
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
if (!plot.equals(getCurrentPlot(f))) {
plotEntry(player, plot);
}
} else if (leftPlot(f, event.getTo())) {
plot = getCurrentPlot(f);
plotExit(player, plot);
} }
if (!plot.equals(getCurrentPlot(f))) {
plotEntry(player, plot);
}
} else if (leftPlot(f, t)) {
plot = getCurrentPlot(f);
plotExit(player, plot);
} }
} catch (final Exception e) {
// Gotta catch 'em all.
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public static void onChat(final AsyncPlayerChatEvent event) { public static void onChat(final AsyncPlayerChatEvent event) {
final World world = event.getPlayer().getWorld(); Player player = event.getPlayer();
final String world = player.getWorld().getName();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
} }
final PlotWorld plotworld = PlotSquared.getWorldSettings(world.getName()); final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
if (!plotworld.PLOT_CHAT) { if (!plotworld.PLOT_CHAT) {
return; return;
} }
if (getCurrentPlot(event.getPlayer().getLocation()) == null) { Location loc = BukkitUtil.getLocation(player);
if (getCurrentPlot(loc) == 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(event.getPlayer().getLocation()); 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();
@ -267,7 +253,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Location loc = 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) {
if (event.getBlock().getY() == 0) { if (event.getBlock().getY() == 0) {
@ -282,7 +268,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (!plot.hasRights(event.getPlayer())) { if (!plot.isAdded(event.getPlayer())) {
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()))) {
@ -355,7 +341,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} else { } else {
final Block b = event.getBlock(); final Block b = event.getBlock();
final Player p = (Player) e; final Player p = (Player) e;
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) { if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road"); PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.road");
@ -370,7 +356,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (!plot.hasRights(p)) { } else if (!plot.isAdded(p)) {
if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) {
if (isPlotArea(loc)) { if (isPlotArea(loc)) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other");
@ -399,7 +385,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();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc)) { if (isPlotWorld(loc)) {
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
if (isPlotArea(e.getBlock().getLocation())) { if (isPlotArea(e.getBlock().getLocation())) {
@ -412,7 +398,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();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc)) { if (isPlotWorld(loc)) {
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
if (isPlotArea(e.getBlock().getLocation())) { if (isPlotArea(e.getBlock().getLocation())) {
@ -425,7 +411,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();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc)) { if (isPlotWorld(loc)) {
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
if (isPlotArea(e.getBlock().getLocation())) { if (isPlotArea(e.getBlock().getLocation())) {
@ -438,7 +424,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();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc)) { if (isPlotWorld(loc)) {
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
if (isPlotArea(e.getBlock().getLocation())) { if (isPlotArea(e.getBlock().getLocation())) {
@ -451,7 +437,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();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc)) { if (isPlotWorld(loc)) {
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
if (isPlotArea(e.getBlock().getLocation())) { if (isPlotArea(e.getBlock().getLocation())) {
@ -464,7 +450,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();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc)) { if (isPlotWorld(loc)) {
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
if (isPlotArea(e.getBlock().getLocation())) { if (isPlotArea(e.getBlock().getLocation())) {
@ -490,7 +476,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();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) { if (isPlotWorld(loc) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) {
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
if (isPlotArea(e.getBlock().getLocation())) { if (isPlotArea(e.getBlock().getLocation())) {
@ -546,7 +532,7 @@ 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.hasRights(player)) { if (!plot.isAdded(player)) {
if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) {
return; return;
} }
@ -613,7 +599,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
final Block b = e.getBlock(); final Block b = e.getBlock();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (b != null) { if (b != null) {
if (e.getPlayer() != null) { if (e.getPlayer() != null) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();
@ -631,7 +617,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
} else if (!plot.hasRights(p)) { } else if (!plot.isAdded(p)) {
if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) { if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) {
if (isPlotArea(loc)) { if (isPlotArea(loc)) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other"); PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other");
@ -651,9 +637,9 @@ 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 = event.getFrom(); final Location f = BukkitUtil.getLocation(event.getFrom());
final Location t = event.getTo(); final Location t = BukkitUtil.getLocation(event.getTo());
final Location q = new Location(t.getWorld(), t.getBlockX(), 64, t.getZ()); final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ());
if (isPlotWorld(q)) { if (isPlotWorld(q)) {
if (isInPlot(q)) { if (isInPlot(q)) {
final Plot plot = getCurrentPlot(q); final Plot plot = getCurrentPlot(q);
@ -672,7 +658,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
plotExit(event.getPlayer(), plot); plotExit(event.getPlayer(), plot);
} }
} }
if ((q.getBlockX() >= 29999999) || (q.getBlockX() <= -29999999) || (q.getBlockZ() >= 29999999) || (q.getBlockZ() <= -29999999)) { if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -683,7 +669,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
public static void onBucketEmpty(final PlayerBucketEmptyEvent e) { public static void onBucketEmpty(final PlayerBucketEmptyEvent e) {
final BlockFace bf = e.getBlockFace(); final BlockFace bf = e.getBlockFace();
final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc)) { if (isPlotWorld(loc)) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
@ -702,7 +688,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned");
e.setCancelled(true); e.setCancelled(true);
return; return;
} else if (!plot.hasRights(e.getPlayer())) { } else if (!plot.isAdded(e.getPlayer())) {
final Flag use = FlagManager.getPlotFlag(plot, "use"); final Flag use = FlagManager.getPlotFlag(plot, "use");
if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) { if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) {
return; return;
@ -748,7 +734,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();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc)) { if (isPlotWorld(loc)) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
@ -767,7 +753,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned"); PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.unowned");
e.setCancelled(true); e.setCancelled(true);
return; return;
} else if (!plot.hasRights(e.getPlayer())) { } else if (!plot.isAdded(e.getPlayer())) {
final Flag use = FlagManager.getPlotFlag(plot, "use"); final Flag use = FlagManager.getPlotFlag(plot, "use");
final Block block = e.getBlockClicked(); final Block block = e.getBlockClicked();
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()))) {
@ -789,7 +775,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();
final Location loc = b.getLocation(); final Location loc = BukkitUtil.getLocation(b.getLocation());
if (isPlotWorld(loc)) { if (isPlotWorld(loc)) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();
if (!isInPlot(loc)) { if (!isInPlot(loc)) {
@ -806,7 +792,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
} else if (!plot.hasRights(p)) { } else if (!plot.isAdded(p)) {
if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) { if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) {
return; return;
} }
@ -843,7 +829,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
} else if (!plot.hasRights(p)) { } else if (!plot.isAdded(p)) {
if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) { if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) {
return; return;
} }
@ -879,7 +865,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
} else if (!plot.hasRights(p)) { } else if (!plot.isAdded(p)) {
final Entity entity = e.getRightClicked(); final Entity entity = e.getRightClicked();
if ((entity instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-interact")) { if ((entity instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-interact")) {
return; return;
@ -929,7 +915,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
return; return;
} }
if (!plot.hasRights(p)) { if (!plot.isAdded(p)) {
if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) { if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) {
return; return;
} }
@ -989,7 +975,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
assert plot != null; assert plot != null;
if (!plot.hasRights(p)) { if (!plot.isAdded(p)) {
if ((a instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) { if ((a instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) {
return; return;
} }
@ -1034,7 +1020,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
e.setHatching(false); e.setHatching(false);
return; return;
} }
} else if (!plot.hasRights(p)) { } else if (!plot.isAdded(p)) {
if (!BukkitMain.hasPermission(p, "plots.admin.projectile.other")) { if (!BukkitMain.hasPermission(p, "plots.admin.projectile.other")) {
if (isPlotArea(l)) { if (isPlotArea(l)) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other"); PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.projectile.other");
@ -1057,7 +1043,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Location loc = event.getBlock().getLocation(); final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
if (isInPlot(loc)) { if (isInPlot(loc)) {
final Plot plot = getCurrentPlot(loc); final Plot plot = getCurrentPlot(loc);
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
@ -1068,7 +1054,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (!plot.hasRights(player)) { if (!plot.isAdded(player)) {
final Flag place = FlagManager.getPlotFlag(plot, "place"); final Flag place = FlagManager.getPlotFlag(plot, "place");
final Block block = event.getBlock(); final Block block = event.getBlock();
if ((place != null) && ((HashSet<PlotBlock>) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if ((place != null) && ((HashSet<PlotBlock>) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {

View File

@ -125,11 +125,7 @@ public class PlotListener {
if (id == null) { if (id == null) {
return null; return null;
} }
final String world = loc.getWorld(); return PlotHelper.getPlot(loc.getWorld(), id);
if (PlotSquared.getPlots(world).containsKey(id)) {
return PlotSquared.getPlots(world).get(id);
}
return new Plot(id, null, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld());
} }
private static WeatherType getWeatherType(String str) { private static WeatherType getWeatherType(String str) {