mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c476e07c28
@ -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;
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
|
||||
UUIDHandler.startFetch(this);
|
||||
// UUIDHandler.startFetch(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<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.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<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)));
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -86,6 +86,10 @@ public enum Command {
|
||||
*
|
||||
*/
|
||||
SET("set", "s"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
SETUP("setup"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>();
|
||||
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
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<String, Plot> 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
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user