Merge remote-tracking branch 'origin/master'

This commit is contained in:
Sauilitired 2014-10-08 07:14:40 +02:00
commit c476e07c28
12 changed files with 115 additions and 99 deletions

View File

@ -33,12 +33,9 @@ public class PWE {
Plot plot = PlotMain.getPlots(l.getWorld()).get(id); Plot plot = PlotMain.getPlots(l.getWorld()).get(id);
if (plot != null) { if (plot != null) {
boolean r; 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 (!r) {
if ((plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) { if (p.hasPermission("plots.worldedit.bypass")) {
r = true;
} else if (p.hasPermission("plots.worldedit.bypass")) {
removeMask(p, s); removeMask(p, s);
return; return;
} }

View File

@ -729,7 +729,7 @@ public class PlotMain extends JavaPlugin {
} }
UUIDHandler.startFetch(this); // UUIDHandler.startFetch(this);
} }
/** /**

View File

@ -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_BLOCK_DEFAULT;
import static com.intellectualcrafters.plot.PlotWorld.WALL_FILLING_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.WALL_HEIGHT_DEFAULT;
import static com.intellectualcrafters.plot.PlotWorld.MOB_SPAWNING_DEFAULT;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
@ -94,7 +95,7 @@ public class PlotSquaredGen extends ChunkGenerator {
YamlConfiguration config = PlotMain.config; YamlConfiguration config = PlotMain.config;
this.plotworld = new PlotWorld(); this.plotworld = new PlotWorld();
Map<String, Object> options = new HashMap<String, Object>(); Map<String, Object> options = new HashMap<String, Object>();
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.auto_merge", AUTO_MERGE_DEFAULT);
options.put("worlds." + world + ".plot.height", PLOT_HEIGHT_DEFAULT); options.put("worlds." + world + ".plot.height", PLOT_HEIGHT_DEFAULT);
options.put("worlds." + world + ".plot.size", PLOT_WIDTH_DEFAULT); options.put("worlds." + world + ".plot.size", PLOT_WIDTH_DEFAULT);
@ -137,6 +138,7 @@ public class PlotSquaredGen extends ChunkGenerator {
} catch (IOException e) { } 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"); 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.AUTO_MERGE = config.getBoolean("worlds." + world + ".plot.auto_merge");
this.plotworld.PLOT_HEIGHT = config.getInt("worlds." + world + ".plot.height"); this.plotworld.PLOT_HEIGHT = config.getInt("worlds." + world + ".plot.height");
this.plotworld.PLOT_WIDTH = config.getInt("worlds." + world + ".plot.size"); this.plotworld.PLOT_WIDTH = config.getInt("worlds." + world + ".plot.size");
@ -210,7 +212,13 @@ public class PlotSquaredGen extends ChunkGenerator {
@Override @Override
public List<BlockPopulator> getDefaultPopulators(World world) { public List<BlockPopulator> 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))); return Arrays.asList((BlockPopulator) new XPopulator(PlotMain.getWorldSettings(world)));
} }

View File

@ -35,6 +35,8 @@ public class PlotWorld {
public boolean AUTO_MERGE; public boolean AUTO_MERGE;
public static boolean AUTO_MERGE_DEFAULT = false; public static boolean AUTO_MERGE_DEFAULT = false;
public boolean MOB_SPAWNING;
public static boolean MOB_SPAWNING_DEFAULT = false;
/** /**
* Road Height * Road Height
*/ */

View File

@ -86,6 +86,10 @@ public enum Command {
* *
*/ */
SET("set", "s"), SET("set", "s"),
/**
*
*/
SETUP("setup"),
/** /**
* *
*/ */

View File

@ -32,9 +32,9 @@ public class Denied extends SubCommand {
} }
private boolean hasBeenOnServer(String name) { private boolean hasBeenOnServer(String name) {
Player plr = Bukkit.getPlayerExact(name); Player plr = Bukkit.getPlayer(name);
if (plr == null) { if (plr == null) {
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name); OfflinePlayer oplr = Bukkit.getPlayer(name);
if (oplr == null) { if (oplr == null) {
return false; return false;
} else { } else {
@ -77,8 +77,8 @@ public class Denied extends SubCommand {
return true; return true;
} }
UUID uuid = null; UUID uuid = null;
if ((Bukkit.getPlayerExact(args[1]) != null)) { if ((Bukkit.getPlayer(args[1]) != null)) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); uuid = Bukkit.getPlayer(args[1]).getUniqueId();
} else { } else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
} }
@ -115,8 +115,8 @@ public class Denied extends SubCommand {
return true; return true;
} }
UUID uuid = null; UUID uuid = null;
if (Bukkit.getPlayerExact(args[1])!=null) { if (Bukkit.getPlayer(args[1])!=null) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); uuid = Bukkit.getPlayer(args[1]).getUniqueId();
} else { } else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
} }

View File

@ -29,7 +29,7 @@ public class Helpers extends SubCommand {
} }
private boolean hasBeenOnServer(String name) { private boolean hasBeenOnServer(String name) {
Player plr = Bukkit.getPlayerExact(name); Player plr = Bukkit.getPlayer(name);
if (plr == null) { if (plr == null) {
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name); OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
if (oplr == null) { if (oplr == null) {
@ -74,8 +74,8 @@ public class Helpers extends SubCommand {
return true; return true;
} }
UUID uuid = null; UUID uuid = null;
if ((Bukkit.getPlayerExact(args[1]) != null)) { if ((Bukkit.getPlayer(args[1]) != null)) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); uuid = Bukkit.getPlayer(args[1]).getUniqueId();
} else { } else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
} }
@ -105,8 +105,8 @@ public class Helpers extends SubCommand {
return true; return true;
} }
UUID uuid = null; UUID uuid = null;
if (Bukkit.getPlayerExact(args[1]) != null) { if (Bukkit.getPlayer(args[1]) != null) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); uuid = Bukkit.getPlayer(args[1]).getUniqueId();
} else { } else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
} }

View File

@ -83,7 +83,7 @@ public class Info extends SubCommand {
String info = C.PLOT_INFO.s(); String info = C.PLOT_INFO.s();
info = info.replaceAll("%alias%", plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"); 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("%biome%", getBiomeAt(plot).toString());
info = info.replaceAll("%owner%", owner); info = info.replaceAll("%owner%", owner);
info = info.replaceAll("%time%", plot.settings.getChangeTime() ? plot.settings.getTime() + "" : "default"); info = info.replaceAll("%time%", plot.settings.getChangeTime() ? plot.settings.getTime() + "" : "default");

View File

@ -29,7 +29,7 @@ public class Trusted extends SubCommand {
} }
private boolean hasBeenOnServer(String name) { private boolean hasBeenOnServer(String name) {
Player plr = Bukkit.getPlayerExact(name); Player plr = Bukkit.getPlayer(name);
if (plr == null) { if (plr == null) {
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name); OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
if (oplr == null) { if (oplr == null) {
@ -74,8 +74,8 @@ public class Trusted extends SubCommand {
return true; return true;
} }
UUID uuid = null; UUID uuid = null;
if ((Bukkit.getPlayerExact(args[1]) != null)) { if ((Bukkit.getPlayer(args[1]) != null)) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); uuid = Bukkit.getPlayer(args[1]).getUniqueId();
} else { } else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
} }
@ -105,8 +105,8 @@ public class Trusted extends SubCommand {
return true; return true;
} }
UUID uuid = null; UUID uuid = null;
if (Bukkit.getPlayerExact(args[1]) != null) { if (Bukkit.getPlayer(args[1]) != null) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); uuid = Bukkit.getPlayer(args[1]).getUniqueId();
} else { } else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
} }

View File

@ -12,6 +12,7 @@ import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import com.google.common.base.Charsets;
import com.intellectualcrafters.plot.PlotHomePosition; import com.intellectualcrafters.plot.PlotHomePosition;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain; 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: &7Conversion has started");
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata..."); PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata...");
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>(); ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>();
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
boolean online = Bukkit.getServer().getOnlineMode(); 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()) { for (World world : Bukkit.getWorlds()) {
HashMap<String, Plot> plots = PlotManager.getPlots(world); HashMap<String, Plot> plots = PlotManager.getPlots(world);
if (plots != null) { if (plots != null) {
@ -115,16 +92,18 @@ public class PlotMeConverter {
for (String user : plot.getAllowed().split(",")) { for (String user : plot.getAllowed().split(",")) {
if (user.equals("*")) { if (user.equals("*")) {
psAdded.add(DBFunc.everyone); psAdded.add(DBFunc.everyone);
} else if (uuidMap.containsKey(user)) { } else {
psAdded.add(uuidMap.get(user)); UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
psAdded.add(uuid);
} }
} }
try { try {
for (String user : plot.getDenied().split(",")) { for (String user : plot.getDenied().split(",")) {
if (user.equals("*")) { if (user.equals("*")) {
psDenied.add(DBFunc.everyone); psDenied.add(DBFunc.everyone);
} else if (uuidMap.containsKey(user)) { } else {
psDenied.add(uuidMap.get(user)); UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
psDenied.add(uuid);
} }
} }
} catch (Throwable e) { } 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 }); 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 { } else {
String owner = plot.getOwner(); String owner = plot.getOwner();
if (uuidMap.containsKey(owner)) { 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 });
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 });
}
} }
// TODO createPlot doesn't add helpers / denied // TODO createPlot doesn't add helpers / denied

View File

@ -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) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void PlayerMove(PlayerMoveEvent event) { public void PlayerMove(PlayerMoveEvent event) {
try { try {
@ -178,45 +214,15 @@ public class PlayerEvents implements Listener {
} }
if (enteredPlot(from,to)) { if (enteredPlot(from,to)) {
Plot plot = getCurrentPlot(event.getTo()); Plot plot = getCurrentPlot(event.getTo());
if (plot.hasOwner()) { boolean admin = player.hasPermission("plots.admin");
if (C.TITLE_ENTERED_PLOT.s().length() > 2) { if (plot.deny_entry(player) && !admin) {
String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName()); event.setCancelled(true);
String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); return;
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);
}
} }
plotEntry(player, plot);
} else if (leftPlot(event.getFrom(), event.getTo())) { } else if (leftPlot(event.getFrom(), event.getTo())) {
Plot plot = getCurrentPlot(event.getFrom()); Plot plot = getCurrentPlot(event.getFrom());
{ plotExit(player, plot);
PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(callEvent);
}
event.getPlayer().resetPlayerTime();
event.getPlayer().resetPlayerWeather();
PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage());
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -518,6 +524,9 @@ public class PlayerEvents implements Listener {
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
} }
if (event.getEntity() instanceof Player) {
return;
}
if (!isInPlot(event.getLocation())) { if (!isInPlot(event.getLocation())) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -557,6 +566,10 @@ public class PlayerEvents implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
Location f = event.getFrom();
Location t = event.getTo();
if (isPlotWorld(event.getTo())) { if (isPlotWorld(event.getTo())) {
if (isInPlot(event.getTo())) { if (isInPlot(event.getTo())) {
Plot plot = getCurrentPlot(event.getTo()); Plot plot = getCurrentPlot(event.getTo());
@ -564,6 +577,17 @@ public class PlayerEvents implements Listener {
PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED); PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED);
event.setCancelled(true); 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)) { if ((event.getTo().getBlockX() >= 29999999) || (event.getTo().getBlockX() <= -29999999) || (event.getTo().getBlockZ() >= 29999999) || (event.getTo().getBlockZ() <= -29999999)) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -127,14 +127,18 @@ public class WorldEditListener implements Listener {
Player p = e.getPlayer(); Player p = e.getPlayer();
Location t = e.getTo(); Location t = e.getTo();
Location f = e.getFrom(); Location f = e.getFrom();
if (!isPlotWorld(t)) { if (t==null) {
if (isPlotWorld(f)) { PWE.removeMask(p);
PWE.removeMask(p); return;
} else { }
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) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)