This commit is contained in:
boy0001 2015-07-25 17:09:47 +10:00
parent 6758628cba
commit 00ab472ba6
3 changed files with 148 additions and 48 deletions

View File

@ -50,9 +50,12 @@ public class MusicSubcommand extends SubCommand {
sendMessage(player, C.NO_PLOT_PERMS); sendMessage(player, C.NO_PLOT_PERMS);
return true; return true;
} }
PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") { PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") {
public boolean onClick(int index) { public boolean onClick(int index) {
PlotItemStack item = getItem(index); PlotItemStack item = getItem(index);
if (item == null) {
return true;
}
int id = item.id == 7 ? 0 : item.id; int id = item.id == 7 ? 0 : item.id;
if (id == 0) { if (id == 0) {
FlagManager.removePlotFlag(plot, "music"); FlagManager.removePlotFlag(plot, "music");
@ -62,7 +65,7 @@ PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") {
} }
return false; return false;
} }
}; };
int index = 0; int index = 0;
for (int i = 2256; i < 2268; i++) { for (int i = 2256; i < 2268; i++) {
String name = "&r&6" + BlockManager.manager.getClosestMatchingName(new PlotBlock((short) i, (byte) 0)); String name = "&r&6" + BlockManager.manager.getClosestMatchingName(new PlotBlock((short) i, (byte) 0));

View File

@ -1372,37 +1372,133 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (event.getTo() == null || event.getFrom() == null) { if (event.getTo() == null || event.getFrom() == null) {
return; return;
} }
final Location f = BukkitUtil.getLocation(event.getFrom()); final org.bukkit.Location from = event.getFrom();
final Location t = BukkitUtil.getLocation(event.getTo()); final org.bukkit.Location to = event.getTo();
final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ());
final Player player = event.getPlayer(); int x2;
if (PS.get().isPlotWorld(q.getWorld())) { if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
final Plot plot = MainUtil.getPlot(q); String worldname = to.getWorld().getName();
if (plot != null) { PlotWorld plotworld = PS.get().getPlotWorld(worldname);
final PlotPlayer pp = BukkitUtil.getPlayer(player); if (plotworld == null) {
if (plot.isDenied(pp.getUUID())) {
if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) {
return; return;
} }
MainUtil.sendMessage(pp, C.YOU_BE_DENIED); PlotManager plotManager = PS.get().getPlotManager(worldname);
event.setCancelled(true); PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) {
if (lastPlot == null) {
return; return;
} else {
if (MainUtil.enteredPlot(f, t)) {
plotEntry(pp, plot);
} }
if (!plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.exit.denied");
if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from);
} }
} else { else {
if (MainUtil.leftPlot(f, t)) { player.teleport(player.getWorld().getSpawnLocation());
final Plot plot2 = MainUtil.getPlot(f);
plotExit(BukkitUtil.getPlayer(player), plot2);
} }
}
if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
else if (lastPlot != null && id.equals(lastPlot.id)) {
return;
}
else {
Plot plot = MainUtil.getPlot(worldname, id);
if (!plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied");
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from);
}
else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true);
return;
}
}
Integer border = MainUtil.worldBorder.get(worldname);
if (border != null) {
if (x2 > border) {
to.setX(border - 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
return;
}
else if (x2 < -border) {
to.setX(-border + 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
return;
}
}
return;
}
int z2;
if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) {
String worldname = to.getWorld().getName();
PlotWorld plotworld = PS.get().getPlotWorld(worldname);
if (plotworld == null) {
return;
}
PlotManager plotManager = PS.get().getPlotManager(worldname);
PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) {
if (lastPlot == null) {
return;
}
if (!plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.exit.denied");
if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from);
}
else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true);
return;
}
}
else if (lastPlot != null && id.equals(lastPlot.id)) {
return;
}
else {
Plot plot = MainUtil.getPlot(worldname, id);
if (!plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied");
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from);
}
else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true);
return;
}
}
Integer border = MainUtil.worldBorder.get(worldname);
if (border != null) {
if (z2 > border) {
to.setZ(border - 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
return;
}
else if (z2 < -border) {
to.setZ(-border + 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
return;
}
}
return;
}
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -1460,6 +1556,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (inv != null && event.getRawSlot() == event.getSlot()) { if (inv != null && event.getRawSlot() == event.getSlot()) {
if (!inv.onClick(event.getSlot())) { if (!inv.onClick(event.getSlot())) {
event.setCancelled(true); event.setCancelled(true);
inv.close();
} }
} }
} }

View File

@ -120,7 +120,6 @@ public class WEListener implements Listener {
} }
return true; return true;
} }
}
if (!WEManager.regionContains(region, mask)) { if (!WEManager.regionContains(region, mask)) {
MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "pos1 + pos2"); MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "pos1 + pos2");
e.setCancelled(true); e.setCancelled(true);
@ -129,6 +128,7 @@ public class WEListener implements Listener {
} }
return true; return true;
} }
}
long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier; long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier;
return checkVolume(pp, volume, max, e); return checkVolume(pp, volume, max, e);
} }