plot settings

This commit is contained in:
boy0001 2015-01-12 03:25:33 +11:00
parent 040045eed5
commit d4393caaf4
6 changed files with 155 additions and 178 deletions

View File

@ -209,10 +209,6 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
*/ */
private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots; private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
/**
* If plotme converter is enabled
*/
private static boolean CONVERT_PLOTME = enablePlotMe();
/** /**
* Return an instance of MySQL * Return an instance of MySQL
*/ */
@ -899,7 +895,7 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
public static void worldLoad(WorldLoadEvent event) { public static void worldLoad(WorldLoadEvent event) {
if (!UUIDHandler.CACHED) { if (!UUIDHandler.CACHED) {
UUIDHandler.cacheAll(); UUIDHandler.cacheAll();
if (CONVERT_PLOTME) { if (Settings.CONVERT_PLOTME && Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
try { try {
new PlotMeConverter(PlotMain.getMain()).runAsync(); new PlotMeConverter(PlotMain.getMain()).runAsync();
} catch (final Exception e) { } catch (final Exception e) {
@ -1322,50 +1318,12 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
Logger.setup(log); Logger.setup(log);
Logger.add(LogLevel.GENERAL, "Logger enabled"); Logger.add(LogLevel.GENERAL, "Logger enabled");
} }
public static boolean enablePlotMe() {
if (!Settings.CONVERT_PLOTME) {
return false;
}
File file = new File(new File("").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe-Core.jar");
if (file.exists()) {
sendConsoleSenderMessage("&b==== Copying 'PlotMe-Core.jar' to 'PlotMe_JAR_relocated' for conversion purposes ===");
sendConsoleSenderMessage("&c - If you do not wish to convert, please stop the server now and set 'plotme-convert.enabled' to false");
sendConsoleSenderMessage("&3 - Please ignore the below stacktrace...");
try {
File to = new File(new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe_JAR_relocated" + File.separator + "PlotMe-Core.jar");
File parent = to.getParentFile();
if(!parent.exists()){
parent.mkdirs();
}
to.createNewFile();
Files.copy(file, to);
file.delete();
} catch (IOException e) {
e.printStackTrace();
}
try {
Thread.sleep(5000);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
return true;
}
file = new File(new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe.jar");
if (file.exists()) {
return true;
}
return false;
}
/** /**
* On Load. * On Load.
*/ */
@Override @Override
final public void onEnable() { final public void onEnable() {
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
CONVERT_PLOTME = true;
}
PlotMain.main = this; PlotMain.main = this;
// Setup the logger mechanics // Setup the logger mechanics
setupLogger(); setupLogger();

View File

@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
public class WE_Anywhere extends SubCommand { public class WE_Anywhere extends SubCommand {
public WE_Anywhere() { public WE_Anywhere() {
super("weanywhere", "plots.worldedit.bypass", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true); super("weanywhere", "plots.admin", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true);
} }
@Override @Override
@ -39,9 +39,15 @@ public class WE_Anywhere extends SubCommand {
PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server"); PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server");
return false; return false;
} }
PWE.removeMask(plr);
PlayerFunctions.sendMessage(plr, "&6Removed your WorldEdit mask"); if (PWE.hasMask(plr)) {
PWE.removeMask(plr);
PlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask");
}
else {
PWE.setMask(plr, plr.getLocation());
PlayerFunctions.sendMessage(plr, "&6Updated your WorldEdit mask");
}
return true; return true;
} }
} }

View File

@ -21,26 +21,29 @@
package com.intellectualcrafters.plot.database; package com.intellectualcrafters.plot.database;
import com.intellectualcrafters.plot.PlotMain; import java.io.File;
import com.intellectualcrafters.plot.generator.HybridGen; import java.io.IOException;
import com.intellectualcrafters.plot.object.Plot; import java.sql.Connection;
import com.intellectualcrafters.plot.object.PlotId; import java.sql.DriverManager;
import com.intellectualcrafters.plot.util.UUIDHandler; import java.sql.ResultSet;
import com.sk89q.worldedit.util.YAMLConfiguration; import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import java.io.File; import com.intellectualcrafters.plot.PlotMain;
import java.io.IOException; import com.intellectualcrafters.plot.generator.HybridGen;
import java.sql.Connection; import com.intellectualcrafters.plot.object.Plot;
import java.sql.ResultSet; import com.intellectualcrafters.plot.object.PlotId;
import java.sql.Statement; import com.intellectualcrafters.plot.util.UUIDHandler;
import java.util.*;
/** /**
* Created 2014-08-17 for PlotSquared * Created 2014-08-17 for PlotSquared
@ -49,11 +52,12 @@ import java.util.*;
* @author Empire92 * @author Empire92
*/ */
public class PlotMeConverter { public class PlotMeConverter {
/** /**
* PlotMain Object * PlotMain Object
*/ */
private final PlotMain plugin; private final PlotMain plugin;
/** /**
* Constructor * Constructor
* *
@ -62,56 +66,51 @@ public class PlotMeConverter {
public PlotMeConverter(final PlotMain plugin) { public PlotMeConverter(final PlotMain plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
private void sendMessage(final String message) { private void sendMessage(final String message) {
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7" + message); PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7" + message);
} }
public void runAsync() throws Exception { public void runAsync() throws Exception {
// We have to make it wait a couple of seconds // We have to make it wait a couple of seconds
Bukkit.getScheduler().runTaskLater(this.plugin, new Runnable() { Bukkit.getScheduler().runTaskLaterAsynchronously(this.plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
sendMessage("Conversion has started"); sendMessage("Conversion has started");
sendMessage("Connecting to PlotMe DB"); sendMessage("Connecting to PlotMe DB");
final ArrayList<Plot> createdPlots = new ArrayList<>(); final ArrayList<Plot> createdPlots = new ArrayList<>();
String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator; final String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
File plotMeFile = new File(dataFolder + "config.yml"); final File plotMeFile = new File(dataFolder + "config.yml");
final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile); final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile);
int count = 0; int count = 0;
Connection connection; Connection connection;
if (plotConfig.getBoolean("usemySQL")) { if (plotConfig.getBoolean("usemySQL")) {
String user = plotConfig.getString("mySQLuname"); final String user = plotConfig.getString("mySQLuname");
String password = plotConfig.getString("mySQLpass"); final String password = plotConfig.getString("mySQLpass");
String con = plotConfig.getString("mySQLconn").replaceAll("jdbc:mysql://", ""); final String con = plotConfig.getString("mySQLconn");
String host = con.split(":")[0]; connection = DriverManager.getConnection(con, user, password);
String port = con.split(":")[1].split("/")[0]; } else {
String database = con.split(":")[1].split("/")[1]; connection = new SQLite(PlotMain.getMain(), dataFolder + File.separator + "plots.db").openConnection();
MySQL mySQL = new MySQL(PlotMain.getMain(), host, port, database, user, password);
connection = mySQL.openConnection();
}
else {
connection = new SQLite(PlotMain.getMain(), dataFolder + File.separator +"plots.db").openConnection();
} }
sendMessage("Collecting plot data"); sendMessage("Collecting plot data");
ResultSet r; ResultSet r;
Statement stmt; Statement stmt;
HashMap<String, Integer> plotSize = new HashMap<>(); final HashMap<String, Integer> plotSize = new HashMap<>();
HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>(); final HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
Set<String> worlds = plotConfig.getConfigurationSection("worlds").getKeys(false); final Set<String> worlds = plotConfig.getConfigurationSection("worlds").getKeys(false);
stmt = connection.createStatement(); stmt = connection.createStatement();
r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); r = stmt.executeQuery("SELECT * FROM `plotmePlots`");
while (r.next()) { while (r.next()) {
count++; count++;
PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
String name = r.getString("owner"); final String name = r.getString("owner");
String world = r.getString("world"); final String world = r.getString("world");
if (!plotSize.containsKey(world)) { if (!plotSize.containsKey(world)) {
int size = r.getInt("topZ") - r.getInt("bottomZ"); final int size = r.getInt("topZ") - r.getInt("bottomZ");
plotSize.put(world,size); plotSize.put(world, size);
plots.put(world, new HashMap<PlotId, Plot>()); plots.put(world, new HashMap<PlotId, Plot>());
} }
@ -119,28 +118,26 @@ public class PlotMeConverter {
if (owner == null) { if (owner == null) {
if (name.equals("*")) { if (name.equals("*")) {
owner = DBFunc.everyone; owner = DBFunc.everyone;
} } else {
else { sendMessage("&cCould not identify owner for plot: " + id);
sendMessage("&cCould not identify owner for plot: "+id);
continue; continue;
} }
} }
Plot plot = new Plot(id, owner, new ArrayList<UUID>() , new ArrayList<UUID>(), world); final Plot plot = new Plot(id, owner, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
plots.get(world).put(id, plot); plots.get(world).put(id, plot);
} }
r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`"); r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`");
while (r.next()) { while (r.next()) {
PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
String name = r.getString("player"); final String name = r.getString("player");
String world = r.getString("world"); final String world = r.getString("world");
UUID helper = UUIDHandler.getUUID(name); UUID helper = UUIDHandler.getUUID(name);
if (helper == null) { if (helper == null) {
if (name.equals("*")) { if (name.equals("*")) {
helper = DBFunc.everyone; helper = DBFunc.everyone;
} } else {
else { sendMessage("&6Could not identify helper for plot: " + id);
sendMessage("&6Could not identify helper for plot: "+id);
continue; continue;
} }
} }
@ -151,16 +148,15 @@ public class PlotMeConverter {
r = stmt.executeQuery("SELECT * FROM `plotmeDenied`"); r = stmt.executeQuery("SELECT * FROM `plotmeDenied`");
while (r.next()) { while (r.next()) {
PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
String name = r.getString("player"); final String name = r.getString("player");
String world = r.getString("world"); final String world = r.getString("world");
UUID denied = UUIDHandler.getUUID(name); UUID denied = UUIDHandler.getUUID(name);
if (denied == null) { if (denied == null) {
if (name.equals("*")) { if (name.equals("*")) {
denied = DBFunc.everyone; denied = DBFunc.everyone;
} } else {
else { sendMessage("&6Could not identify denied for plot: " + id);
sendMessage("&6Could not identify denied for plot: "+id);
continue; continue;
} }
} }
@ -171,27 +167,27 @@ public class PlotMeConverter {
sendMessage("Collected " + count + " plots from PlotMe"); sendMessage("Collected " + count + " plots from PlotMe");
for (String world : plots.keySet()) { for (final String world : plots.keySet()) {
sendMessage("Copying config for: "+world); sendMessage("Copying config for: " + world);
try { try {
final Integer pathwidth = plotConfig.getInt("worlds." + world + ".PathWidth"); // final Integer pathwidth = plotConfig.getInt("worlds." + world + ".PathWidth"); //
PlotMain.config.set("worlds." + world + ".road.width", pathwidth); PlotMain.config.set("worlds." + world + ".road.width", pathwidth);
final Integer plotsize = plotConfig.getInt("worlds." + world + ".PlotSize"); // final Integer plotsize = plotConfig.getInt("worlds." + world + ".PlotSize"); //
PlotMain.config.set("worlds." + world + ".plot.size", plotsize); PlotMain.config.set("worlds." + world + ".plot.size", plotsize);
final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); // final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); //
PlotMain.config.set("worlds." + world + ".wall.block", wallblock); PlotMain.config.set("worlds." + world + ".wall.block", wallblock);
final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); // final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); //
PlotMain.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); PlotMain.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); // final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); //
PlotMain.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); PlotMain.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId"); final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId");
PlotMain.config.set("worlds." + world + ".road.block", road); PlotMain.config.set("worlds." + world + ".road.block", road);
final Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); // final Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
PlotMain.config.set("worlds." + world + ".road.height", height); PlotMain.config.set("worlds." + world + ".road.height", height);
} catch (final Exception e) { } catch (final Exception e) {
@ -199,44 +195,42 @@ public class PlotMeConverter {
} }
} }
File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml"); final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
if (PLOTME_DG_FILE.exists()) { if (PLOTME_DG_FILE.exists()) {
YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE); final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
try { try {
for (String world : plots.keySet()) { for (final String world : plots.keySet()) {
final Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + world + ".PathWidth"); // final Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + world + ".PathWidth"); //
PlotMain.config.set("worlds." + world + ".road.width", pathwidth); PlotMain.config.set("worlds." + world + ".road.width", pathwidth);
final Integer plotsize = PLOTME_DG_YML.getInt("worlds." + world + ".PlotSize"); // final Integer plotsize = PLOTME_DG_YML.getInt("worlds." + world + ".PlotSize"); //
PlotMain.config.set("worlds." + world + ".plot.size", plotsize); PlotMain.config.set("worlds." + world + ".plot.size", plotsize);
final String wallblock = PLOTME_DG_YML.getString("worlds." + world + ".WallBlock"); // final String wallblock = PLOTME_DG_YML.getString("worlds." + world + ".WallBlock"); //
PlotMain.config.set("worlds." + world + ".wall.block", wallblock); PlotMain.config.set("worlds." + world + ".wall.block", wallblock);
final String floor = PLOTME_DG_YML.getString("worlds." + world + ".PlotFloorBlock"); // final String floor = PLOTME_DG_YML.getString("worlds." + world + ".PlotFloorBlock"); //
PlotMain.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); PlotMain.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
final String filling = PLOTME_DG_YML.getString("worlds." + world + ".FillBlock"); // final String filling = PLOTME_DG_YML.getString("worlds." + world + ".FillBlock"); //
PlotMain.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); PlotMain.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
final String road = PLOTME_DG_YML.getString("worlds." + world + ".RoadMainBlock"); final String road = PLOTME_DG_YML.getString("worlds." + world + ".RoadMainBlock");
PlotMain.config.set("worlds." + world + ".road.block", road); PlotMain.config.set("worlds." + world + ".road.block", road);
final Integer height = PLOTME_DG_YML.getInt("worlds." + world + ".RoadHeight"); // final Integer height = PLOTME_DG_YML.getInt("worlds." + world + ".RoadHeight"); //
PlotMain.config.set("worlds." + world + ".road.height", height); PlotMain.config.set("worlds." + world + ".road.height", height);
} }
} } catch (final Exception e) {
catch (Exception e) {
} }
} }
for (String world : plots.keySet()) { for (final String world : plots.keySet()) {
int duplicate = 0; int duplicate = 0;
for (Plot plot : plots.get(world).values()) { for (final Plot plot : plots.get(world).values()) {
if (!PlotMain.getPlots(world).containsKey(plot.id)) { if (!PlotMain.getPlots(world).containsKey(plot.id)) {
createdPlots.add(plot); createdPlots.add(plot);
} } else {
else {
duplicate++; duplicate++;
} }
} }
@ -245,7 +239,6 @@ public class PlotMeConverter {
} }
} }
sendMessage("Creating plot DB"); sendMessage("Creating plot DB");
DBFunc.createPlots(createdPlots); DBFunc.createPlots(createdPlots);
sendMessage("Creating settings/helpers DB"); sendMessage("Creating settings/helpers DB");
@ -256,56 +249,63 @@ public class PlotMeConverter {
} catch (final IOException e) { } catch (final IOException e) {
sendMessage(" - &cFailed to save configuration."); sendMessage(" - &cFailed to save configuration.");
} }
boolean MV = false;
boolean MW = false;
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
MV = true;
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
MW = true;
}
for (final String worldname : worlds) {
final World world = Bukkit.getWorld(worldname);
sendMessage("Reloading generator for world: '" + worldname + "'...");
PlotMain.removePlotWorld(worldname);
if (MV) {
// unload
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + worldname);
try {
Thread.sleep(1000);
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
}
// load
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + worldname + " normal -g PlotSquared");
} else if (MW) {
// unload
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + worldname);
try {
Thread.sleep(1000);
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
}
// load
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + worldname + " plugin:PlotSquared");
} else {
Bukkit.getServer().unloadWorld(world, true);
final World myworld = WorldCreator.name(worldname).generator(new HybridGen(worldname)).createWorld();
myworld.save();
}
}
PlotMain.setAllPlotsRaw(DBFunc.getPlots());
sendMessage("Conversion has finished");
PlotMain.sendConsoleSenderMessage("&cAlthough the server may be functional in it's current state, it is recommended that you restart the server and remove PlotMe to finalize the installation. Please make careful note of any warning messages that may have showed up during conversion.");
} Bukkit.getScheduler().scheduleSyncDelayedTask(PlotMain.getMain(), new Runnable() {
catch (Exception e) { @Override
e.printStackTrace(); public void run() {
try {
boolean MV = false;
boolean MW = false;
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
MV = true;
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
MW = true;
}
for (final String worldname : worlds) {
final World world = Bukkit.getWorld(worldname);
sendMessage("Reloading generator for world: '" + worldname + "'...");
PlotMain.removePlotWorld(worldname);
if (MV) {
// unload
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + worldname);
try {
Thread.sleep(1000);
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
}
// load
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + worldname + " normal -g PlotSquared");
} else if (MW) {
// unload
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + worldname);
try {
Thread.sleep(1000);
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
}
// load
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + worldname + " plugin:PlotSquared");
} else {
Bukkit.getServer().unloadWorld(world, true);
final World myworld = WorldCreator.name(worldname).generator(new HybridGen(worldname)).createWorld();
myworld.save();
}
}
PlotMain.setAllPlotsRaw(DBFunc.getPlots());
sendMessage("Conversion has finished");
PlotMain.sendConsoleSenderMessage("&cAlthough the server may be functional in it's current state, it is recommended that you restart the server and remove PlotMe to finalize the installation. Please make careful note of any warning messages that may have showed up during conversion.");
} catch (final Exception e) {
e.printStackTrace();
}
}
});
} catch (final Exception e) {
} }
} }
}, 20); }, 20);

View File

@ -253,10 +253,8 @@ import java.util.Set;
if (!isPlotWorld(q)) { if (!isPlotWorld(q)) {
if (isPlotWorld(f)) { if (isPlotWorld(f)) {
PWE.removeMask(p); PWE.removeMask(p);
return;
} else {
return;
} }
return;
} }
PWE.setMask(p, q); PWE.setMask(p, q);
} }

View File

@ -156,6 +156,9 @@ import java.util.Set;
public ArrayList<PlotComment> getComments(final int tier) { public ArrayList<PlotComment> getComments(final int tier) {
final ArrayList<PlotComment> c = new ArrayList<>(); final ArrayList<PlotComment> c = new ArrayList<>();
if (this.comments == null) {
return c;
}
for (final PlotComment comment : this.comments) { for (final PlotComment comment : this.comments) {
if (comment.tier == tier) { if (comment.tier == tier) {
c.add(comment); c.add(comment);

View File

@ -52,7 +52,9 @@ import org.bukkit.entity.Player;
} else { } else {
s = PlotMain.worldEdit.getSession(p); s = PlotMain.worldEdit.getSession(p);
} }
if (!PlotMain.isPlotWorld(p.getWorld())) {
removeMask(p);
}
final PlotId id = PlayerFunctions.getPlot(l); final PlotId id = PlayerFunctions.getPlot(l);
if (id != null) { if (id != null) {
final Plot plot = PlotMain.getPlots(l.getWorld()).get(id); final Plot plot = PlotMain.getPlots(l.getWorld()).get(id);
@ -94,6 +96,16 @@ import org.bukkit.entity.Player;
// "WorldEdit == Null?"); // "WorldEdit == Null?");
} }
} }
public static boolean hasMask(final Player p) {
LocalSession s;
if (PlotMain.worldEdit == null) {
s = WorldEdit.getInstance().getSession(p.getName());
} else {
s = PlotMain.worldEdit.getSession(p);
}
return !noMask(s);
}
public static boolean noMask(final LocalSession s) { public static boolean noMask(final LocalSession s) {
return s.getMask() == null; return s.getMask() == null;