diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PWE.java b/PlotSquared/src/com/intellectualcrafters/plot/PWE.java index 5ad94b742..ba3cf3881 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PWE.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PWE.java @@ -33,12 +33,9 @@ public class PWE { Plot plot = PlotMain.getPlots(l.getWorld()).get(id); if (plot != null) { boolean r; - r = (plot.getOwner() != null) && plot.getOwner().equals(p.getUniqueId()); - + r = (plot.getOwner() != null) && plot.getOwner().equals(p.getUniqueId()) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()); if (!r) { - if ((plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) { - r = true; - } else if (p.hasPermission("plots.worldedit.bypass")) { + if (p.hasPermission("plots.worldedit.bypass")) { removeMask(p, s); return; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index 3da561b15..94761771f 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -729,7 +729,7 @@ public class PlotMain extends JavaPlugin { } - UUIDHandler.startFetch(this); +// UUIDHandler.startFetch(this); } /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredGen.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredGen.java index 233350dd1..ceba22400 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredGen.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredGen.java @@ -18,6 +18,7 @@ import static com.intellectualcrafters.plot.PlotWorld.TOP_BLOCK_DEFAULT; import static com.intellectualcrafters.plot.PlotWorld.WALL_BLOCK_DEFAULT; import static com.intellectualcrafters.plot.PlotWorld.WALL_FILLING_DEFAULT; import static com.intellectualcrafters.plot.PlotWorld.WALL_HEIGHT_DEFAULT; +import static com.intellectualcrafters.plot.PlotWorld.MOB_SPAWNING_DEFAULT; import java.io.IOException; import java.util.Arrays; @@ -94,7 +95,7 @@ public class PlotSquaredGen extends ChunkGenerator { YamlConfiguration config = PlotMain.config; this.plotworld = new PlotWorld(); Map options = new HashMap(); - + options.put("worlds." + world + ".natural_mob_spawning", MOB_SPAWNING_DEFAULT); options.put("worlds." + world + ".plot.auto_merge", AUTO_MERGE_DEFAULT); options.put("worlds." + world + ".plot.height", PLOT_HEIGHT_DEFAULT); options.put("worlds." + world + ".plot.size", PLOT_WIDTH_DEFAULT); @@ -137,6 +138,7 @@ public class PlotSquaredGen extends ChunkGenerator { } catch (IOException e) { PlotMain.sendConsoleSenderMessage("&c[Warning] PlotSquared failed to save the configuration&7 (settings.yml may differ from the one in memory)\n - To force a save from console use /plots save"); } + this.plotworld.MOB_SPAWNING = config.getBoolean("worlds." + world + ".natural_mob_spawning"); this.plotworld.AUTO_MERGE = config.getBoolean("worlds." + world + ".plot.auto_merge"); this.plotworld.PLOT_HEIGHT = config.getInt("worlds." + world + ".plot.height"); this.plotworld.PLOT_WIDTH = config.getInt("worlds." + world + ".plot.size"); @@ -210,7 +212,13 @@ public class PlotSquaredGen extends ChunkGenerator { @Override public List getDefaultPopulators(World world) { - world.setSpawnFlags(false, false); + if (!this.plotworld.MOB_SPAWNING) { + world.setSpawnFlags(false, false); + world.setAmbientSpawnLimit(0); + world.setAnimalSpawnLimit(0); + world.setMonsterSpawnLimit(0); + world.setWaterAnimalSpawnLimit(0); + } return Arrays.asList((BlockPopulator) new XPopulator(PlotMain.getWorldSettings(world))); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java index 2faf59b4c..4ad8f568e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java @@ -35,6 +35,8 @@ public class PlotWorld { public boolean AUTO_MERGE; public static boolean AUTO_MERGE_DEFAULT = false; + public boolean MOB_SPAWNING; + public static boolean MOB_SPAWNING_DEFAULT = false; /** * Road Height */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java index 2825aa047..84eb86db4 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java @@ -86,6 +86,10 @@ public enum Command { * */ SET("set", "s"), + /** + * + */ + SETUP("setup"), /** * */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Denied.java index 16f134c87..ba4607432 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Denied.java @@ -32,9 +32,9 @@ public class Denied extends SubCommand { } private boolean hasBeenOnServer(String name) { - Player plr = Bukkit.getPlayerExact(name); + Player plr = Bukkit.getPlayer(name); if (plr == null) { - OfflinePlayer oplr = Bukkit.getOfflinePlayer(name); + OfflinePlayer oplr = Bukkit.getPlayer(name); if (oplr == null) { return false; } else { @@ -77,8 +77,8 @@ public class Denied extends SubCommand { return true; } UUID uuid = null; - if ((Bukkit.getPlayerExact(args[1]) != null)) { - uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); + if ((Bukkit.getPlayer(args[1]) != null)) { + uuid = Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } @@ -115,8 +115,8 @@ public class Denied extends SubCommand { return true; } UUID uuid = null; - if (Bukkit.getPlayerExact(args[1])!=null) { - uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); + if (Bukkit.getPlayer(args[1])!=null) { + uuid = Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java index e5525a7bc..ada76c272 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java @@ -29,7 +29,7 @@ public class Helpers extends SubCommand { } private boolean hasBeenOnServer(String name) { - Player plr = Bukkit.getPlayerExact(name); + Player plr = Bukkit.getPlayer(name); if (plr == null) { OfflinePlayer oplr = Bukkit.getOfflinePlayer(name); if (oplr == null) { @@ -74,8 +74,8 @@ public class Helpers extends SubCommand { return true; } UUID uuid = null; - if ((Bukkit.getPlayerExact(args[1]) != null)) { - uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); + if ((Bukkit.getPlayer(args[1]) != null)) { + uuid = Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } @@ -105,8 +105,8 @@ public class Helpers extends SubCommand { return true; } UUID uuid = null; - if (Bukkit.getPlayerExact(args[1]) != null) { - uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); + if (Bukkit.getPlayer(args[1]) != null) { + uuid = Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java index 1d8ffa50a..2c1cc2509 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java @@ -83,7 +83,7 @@ public class Info extends SubCommand { String info = C.PLOT_INFO.s(); info = info.replaceAll("%alias%", plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"); - info = info.replaceAll("%id%", plot.id.x + ";" + plot.id.y); + info = info.replaceAll("%id%", plot.id.toString()); info = info.replaceAll("%biome%", getBiomeAt(plot).toString()); info = info.replaceAll("%owner%", owner); info = info.replaceAll("%time%", plot.settings.getChangeTime() ? plot.settings.getTime() + "" : "default"); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java index b3748a554..754f903f5 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java @@ -29,7 +29,7 @@ public class Trusted extends SubCommand { } private boolean hasBeenOnServer(String name) { - Player plr = Bukkit.getPlayerExact(name); + Player plr = Bukkit.getPlayer(name); if (plr == null) { OfflinePlayer oplr = Bukkit.getOfflinePlayer(name); if (oplr == null) { @@ -74,8 +74,8 @@ public class Trusted extends SubCommand { return true; } UUID uuid = null; - if ((Bukkit.getPlayerExact(args[1]) != null)) { - uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); + if ((Bukkit.getPlayer(args[1]) != null)) { + uuid = Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } @@ -105,8 +105,8 @@ public class Trusted extends SubCommand { return true; } UUID uuid = null; - if (Bukkit.getPlayerExact(args[1]) != null) { - uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); + if (Bukkit.getPlayer(args[1]) != null) { + uuid = Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java index 43b1d3b26..37c4cc8e5 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -12,6 +12,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.World; +import com.google.common.base.Charsets; import com.intellectualcrafters.plot.PlotHomePosition; import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.PlotMain; @@ -40,31 +41,7 @@ public class PlotMeConverter { PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has started"); PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata..."); ArrayList createdPlots = new ArrayList(); - Map uuidMap = new HashMap(); boolean online = Bukkit.getServer().getOnlineMode(); - if (!online) { - File playersFolder = new File("world" + File.separator + "playerdata"); - String[] dat = playersFolder.list(new FilenameFilter() { - @Override - public boolean accept(File f, String s) { - return s.endsWith(".dat"); - } - }); - for (String current : dat) { - UUID uuid = null; - try { - uuid = UUID.fromString(current.replaceAll(".dat$", "")); - } catch (Exception e) { - - } - if (uuid != null) { - String name = Bukkit.getOfflinePlayer(uuid).getName(); - if (name != null) { - uuidMap.put(name, uuid); - } - } - } - } for (World world : Bukkit.getWorlds()) { HashMap plots = PlotManager.getPlots(world); if (plots != null) { @@ -115,16 +92,18 @@ public class PlotMeConverter { for (String user : plot.getAllowed().split(",")) { if (user.equals("*")) { psAdded.add(DBFunc.everyone); - } else if (uuidMap.containsKey(user)) { - psAdded.add(uuidMap.get(user)); + } else { + UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8)); + psAdded.add(uuid); } } try { for (String user : plot.getDenied().split(",")) { if (user.equals("*")) { psDenied.add(DBFunc.everyone); - } else if (uuidMap.containsKey(user)) { - psDenied.add(uuidMap.get(user)); + } else { + UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8)); + psDenied.add(uuid); } } } catch (Throwable e) { @@ -144,9 +123,7 @@ public class PlotMeConverter { pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false }); } else { String owner = plot.getOwner(); - if (uuidMap.containsKey(owner)) { - pl = new com.intellectualcrafters.plot.Plot(id, uuidMap.get(owner), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false }); - } + pl = new com.intellectualcrafters.plot.Plot(id, UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false }); } // TODO createPlot doesn't add helpers / denied diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 68db79abe..750265712 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -166,6 +166,42 @@ public class PlayerEvents implements Listener { } } + public void plotEntry(Player player, Plot plot) { + if (plot.hasOwner()) { + if (C.TITLE_ENTERED_PLOT.s().length() > 2) { + String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName()); + String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); + ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()); + ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()); + Title title = new Title(sTitleMain, sTitleSub, 10, 20, 10); + title.setTitleColor(sTitleMainColor); + title.setSubtitleColor(sTitleSubColor); + title.setTimingsToTicks(); + title.send(player); + } + { + PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot); + Bukkit.getPluginManager().callEvent(callEvent); + } + PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage()); + if (plot.settings.getRain()) { + PlayerFunctions.togglePlotWeather(player, plot); + } + if (plot.settings.getChangeTime()) { + PlayerFunctions.togglePlotTime(player, plot); + } + } + } + public void plotExit(Player player, Plot plot) { + { + PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); + Bukkit.getPluginManager().callEvent(callEvent); + } + player.resetPlayerTime(); + player.resetPlayerWeather(); + PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage()); + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void PlayerMove(PlayerMoveEvent event) { try { @@ -178,45 +214,15 @@ public class PlayerEvents implements Listener { } if (enteredPlot(from,to)) { Plot plot = getCurrentPlot(event.getTo()); - if (plot.hasOwner()) { - if (C.TITLE_ENTERED_PLOT.s().length() > 2) { - String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName()); - String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); - ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()); - ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()); - Title title = new Title(sTitleMain, sTitleSub, 10, 20, 10); - title.setTitleColor(sTitleMainColor); - title.setSubtitleColor(sTitleSubColor); - title.setTimingsToTicks(); - title.send(player); - } - { - PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot); - Bukkit.getPluginManager().callEvent(callEvent); - } - boolean admin = player.hasPermission("plots.admin"); - - PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage()); - if (plot.deny_entry(player) && !admin) { - event.setCancelled(true); - return; - } - if (plot.settings.getRain()) { - PlayerFunctions.togglePlotWeather(player, plot); - } - if (plot.settings.getChangeTime()) { - PlayerFunctions.togglePlotTime(player, plot); - } + boolean admin = player.hasPermission("plots.admin"); + if (plot.deny_entry(player) && !admin) { + event.setCancelled(true); + return; } + plotEntry(player, plot); } else if (leftPlot(event.getFrom(), event.getTo())) { Plot plot = getCurrentPlot(event.getFrom()); - { - PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); - Bukkit.getPluginManager().callEvent(callEvent); - } - event.getPlayer().resetPlayerTime(); - event.getPlayer().resetPlayerWeather(); - PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage()); + plotExit(player, plot); } } } catch (Exception e) { @@ -518,6 +524,9 @@ public class PlayerEvents implements Listener { if (!isPlotWorld(world)) { return; } + if (event.getEntity() instanceof Player) { + return; + } if (!isInPlot(event.getLocation())) { event.setCancelled(true); } @@ -557,6 +566,10 @@ public class PlayerEvents implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTeleport(PlayerTeleportEvent event) { + + Location f = event.getFrom(); + Location t = event.getTo(); + if (isPlotWorld(event.getTo())) { if (isInPlot(event.getTo())) { Plot plot = getCurrentPlot(event.getTo()); @@ -564,6 +577,17 @@ public class PlayerEvents implements Listener { PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED); event.setCancelled(true); } + else { + if (enteredPlot(f, t)) { + plotEntry(event.getPlayer(), plot); + } + } + } + else { + if (leftPlot(f, t)) { + Plot plot = getCurrentPlot(event.getTo()); + plotExit(event.getPlayer(), plot); + } } if ((event.getTo().getBlockX() >= 29999999) || (event.getTo().getBlockX() <= -29999999) || (event.getTo().getBlockZ() >= 29999999) || (event.getTo().getBlockZ() <= -29999999)) { event.setCancelled(true); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java index e5ef8b734..9ad868de8 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -127,14 +127,18 @@ public class WorldEditListener implements Listener { Player p = e.getPlayer(); Location t = e.getTo(); Location f = e.getFrom(); - if (!isPlotWorld(t)) { - if (isPlotWorld(f)) { - PWE.removeMask(p); - } else { - return; - } + if (t==null) { + PWE.removeMask(p); + return; + } + if (isPlotWorld(t)) { + PWE.setMask(p, t); + return; + } + if (f!=null && isPlotWorld(f)) { + PWE.removeMask(p); + return; } - PWE.setMask(p, t); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)