Fixing all broken references

This commit is contained in:
sauilitired 2015-07-03 11:45:00 +02:00
parent ebe80350dc
commit f6de97a512
21 changed files with 80 additions and 189 deletions

View File

@ -41,14 +41,15 @@ public class PlotSquared implements PlotSquaredMain {
private final HashMap<String, PlotWorld> plotworlds = new HashMap<>(); private final HashMap<String, PlotWorld> plotworlds = new HashMap<>();
private final HashMap<String, PlotManager> plotmanagers = new HashMap<>(); private final HashMap<String, PlotManager> plotmanagers = new HashMap<>();
public WorldEditPlugin worldEdit = null; public WorldEditPlugin worldEdit = null;
public File configFile;
public YamlConfiguration config;
public YamlConfiguration storage;
public IPlotMain IMP = null; // Specific implementation of PlotSquared
public TaskManager TASK;
private File styleFile; private File styleFile;
private YamlConfiguration style; private YamlConfiguration style;
private File configFile;
private YamlConfiguration config;
private File storageFile; private File storageFile;
private YamlConfiguration storage;
private File FILE = null; // This file private File FILE = null; // This file
private IPlotMain IMP = null; // Specific implementation of PlotSquared
private String VERSION = null; private String VERSION = null;
private boolean LOADING_WORLD = false; private boolean LOADING_WORLD = false;
private LinkedHashMap<String, HashMap<PlotId, Plot>> plots; private LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
@ -77,7 +78,7 @@ public class PlotSquared implements PlotSquaredMain {
if (getJavaVersion() < 1.8) { if (getJavaVersion() < 1.8) {
log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance"); log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
} }
TaskManager TASK = IMP.getTaskManager(); this.TASK = IMP.getTaskManager();
if (C.ENABLED.s().length() > 0) { if (C.ENABLED.s().length() > 0) {
log(C.ENABLED.s()); log(C.ENABLED.s());
} }
@ -405,7 +406,7 @@ public class PlotSquared implements PlotSquaredMain {
final PlotGenerator plotGenerator; final PlotGenerator plotGenerator;
final PlotManager plotManager; final PlotManager plotManager;
final String path = "worlds." + world; final String path = "worlds." + world;
if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) { if (!LOADING_WORLD && (generator != null)) {
plotGenerator = generator; plotGenerator = generator;
plotWorld = plotGenerator.getNewPlotWorld(world); plotWorld = plotGenerator.getNewPlotWorld(world);
plotManager = plotGenerator.getPlotManager(); plotManager = plotGenerator.getPlotManager();
@ -582,99 +583,6 @@ public class PlotSquared implements PlotSquaredMain {
return true; return true;
} }
@Override
public boolean setupPlotWorld(final String world, final String id) {
if ((id != null) && (id.length() > 0)) {
// save configuration
final String[] split = id.split(",");
final HybridPlotWorld plotworld = new HybridPlotWorld(world);
final int width = SquarePlotWorld.PLOT_WIDTH_DEFAULT;
final int gap = SquarePlotWorld.ROAD_WIDTH_DEFAULT;
final int height = ClassicPlotWorld.PLOT_HEIGHT_DEFAULT;
final PlotBlock[] floor = ClassicPlotWorld.TOP_BLOCK_DEFAULT;
final PlotBlock[] main = ClassicPlotWorld.MAIN_BLOCK_DEFAULT;
final PlotBlock wall = ClassicPlotWorld.WALL_FILLING_DEFAULT;
final PlotBlock border = ClassicPlotWorld.WALL_BLOCK_DEFAULT;
for (final String element : split) {
final String[] pair = element.split("=");
if (pair.length != 2) {
log("&cNo value provided for: &7" + element);
return false;
}
final String key = pair[0].toLowerCase();
final String value = pair[1];
try {
switch (key) {
case "s":
case "size": {
SquarePlotWorld.PLOT_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue();
break;
}
case "g":
case "gap": {
SquarePlotWorld.ROAD_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue();
break;
}
case "h":
case "height": {
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
break;
}
case "f":
case "floor": {
ClassicPlotWorld.TOP_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value);
break;
}
case "m":
case "main": {
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value);
break;
}
case "w":
case "wall": {
ClassicPlotWorld.WALL_FILLING_DEFAULT = Configuration.BLOCK.parseString(value);
break;
}
case "b":
case "border": {
ClassicPlotWorld.WALL_BLOCK_DEFAULT = Configuration.BLOCK.parseString(value);
break;
}
default: {
log("&cKey not found: &7" + element);
return false;
}
}
} catch (final Exception e) {
e.printStackTrace();
log("&cInvalid value: &7" + value + " in arg " + element);
return false;
}
}
try {
final String root = "worlds." + world;
if (!config.contains(root)) {
config.createSection(root);
}
plotworld.saveConfiguration(config.getConfigurationSection(root));
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = height;
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = height;
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = height;
ClassicPlotWorld.TOP_BLOCK_DEFAULT = floor;
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = main;
ClassicPlotWorld.WALL_BLOCK_DEFAULT = border;
ClassicPlotWorld.WALL_FILLING_DEFAULT = wall;
SquarePlotWorld.PLOT_WIDTH_DEFAULT = width;
SquarePlotWorld.ROAD_WIDTH_DEFAULT = gap;
} catch (final Exception e) {
e.printStackTrace();
}
}
return true;
}
@Override @Override
public Connection getConnection() { public Connection getConnection() {
return connection; return connection;
@ -782,7 +690,6 @@ public class PlotSquared implements PlotSquaredMain {
} else { } else {
log(C.PREFIX + "&cNo storage type is set!"); log(C.PREFIX + "&cNo storage type is set!");
IMP.disable(); IMP.disable();
return;
} }
} }

View File

@ -117,7 +117,7 @@ import java.util.Set;
* @see com.intellectualcrafters.plot.PlotSquared#config * @see com.intellectualcrafters.plot.PlotSquared#config
*/ */
public YamlConfiguration getConfig() { public YamlConfiguration getConfig() {
return PlotSquared.config; return PlotSquared.getInstance().config;
} }
/** /**
@ -126,7 +126,7 @@ import java.util.Set;
* @see com.intellectualcrafters.plot.PlotSquared#storage * @see com.intellectualcrafters.plot.PlotSquared#storage
*/ */
public YamlConfiguration getStorage() { public YamlConfiguration getStorage() {
return PlotSquared.storage; return PlotSquared.getInstance().storage;
} }
/** /**
@ -138,7 +138,7 @@ import java.util.Set;
* @see com.intellectualcrafters.plot.PlotSquared * @see com.intellectualcrafters.plot.PlotSquared
*/ */
public PlotSquared getMain() { public PlotSquared getMain() {
return PlotSquared.THIS; return PlotSquared.getInstance();
} }
/** /**
@ -612,7 +612,7 @@ import java.util.Set;
* @see com.intellectualcrafters.plot.PlotSquared * @see com.intellectualcrafters.plot.PlotSquared
*/ */
public PlotSquared getPlotSquared() { public PlotSquared getPlotSquared() {
return PlotSquared.THIS; return PlotSquared.getInstance();
} }
/** /**

View File

@ -130,16 +130,16 @@ public class Cluster extends SubCommand {
} }
PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world); PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
if (plotworld == null) { if (plotworld == null) {
PlotSquared.config.createSection("worlds." + world); PlotSquared.getInstance().config.createSection("worlds." + world);
PlotSquared.getInstance().loadWorld(world, null); PlotSquared.getInstance().loadWorld(world, null);
} }
else { else {
final String gen_string = PlotSquared.config.getString("worlds." + world + "." + "generator.plugin"); final String gen_string = PlotSquared.getInstance().config.getString("worlds." + world + "." + "generator.plugin");
PlotGenerator generator; PlotGenerator generator;
if (gen_string == null) { if (gen_string == null) {
generator = new HybridGen(world); generator = new HybridGen(world);
} else { } else {
generator = (PlotGenerator) PlotSquared.IMP.getGenerator(world, gen_string); generator = (PlotGenerator) PlotSquared.getInstance().IMP.getGenerator(world, gen_string);
} }
new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2); new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
} }

View File

@ -77,7 +77,7 @@ public class Condense extends SubCommand {
return false; return false;
} }
final int radius = Integer.parseInt(args[2]); final int radius = Integer.parseInt(args[2]);
final Collection<Plot> plots = PlotSquared.getPlots(worldname).values(); final Collection<Plot> plots = PlotSquared.getInstance().getPlots(worldname).values();
final int size = plots.size(); final int size = plots.size();
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
if (radius < minimum_radius) { if (radius < minimum_radius) {
@ -166,7 +166,7 @@ public class Condense extends SubCommand {
return false; return false;
} }
final int radius = Integer.parseInt(args[2]); final int radius = Integer.parseInt(args[2]);
final Collection<Plot> plots = PlotSquared.getPlots(worldname).values(); final Collection<Plot> plots = PlotSquared.getInstance().getPlots(worldname).values();
final int size = plots.size(); final int size = plots.size();
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1); final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
if (radius < minimum_radius) { if (radius < minimum_radius) {

View File

@ -208,7 +208,7 @@ public class DebugExec extends SubCommand {
Trim.sendMessage(" - MCA #: " + empty.size()); Trim.sendMessage(" - MCA #: " + empty.size());
Trim.sendMessage(" - CHUNKS: " + (empty.size() * 1024) + " (max)"); Trim.sendMessage(" - CHUNKS: " + (empty.size() * 1024) + " (max)");
Trim.sendMessage("Exporting log for manual approval..."); Trim.sendMessage("Exporting log for manual approval...");
final File file = new File(PlotSquared.IMP.getDirectory() + File.separator + "trim.txt"); final File file = new File(PlotSquared.getInstance().IMP.getDirectory() + File.separator + "trim.txt");
PrintWriter writer; PrintWriter writer;
try { try {
writer = new PrintWriter(file); writer = new PrintWriter(file);

View File

@ -256,19 +256,19 @@ public class DebugUUID extends SubCommand {
} }
if (newWrapper instanceof OfflineUUIDWrapper) { if (newWrapper instanceof OfflineUUIDWrapper) {
PlotSquared.config.set("UUID.force-lowercase", false); PlotSquared.getInstance().config.set("UUID.force-lowercase", false);
PlotSquared.config.set("UUID.offline", true); PlotSquared.getInstance().config.set("UUID.offline", true);
} }
else if (newWrapper instanceof LowerOfflineUUIDWrapper) { else if (newWrapper instanceof LowerOfflineUUIDWrapper) {
PlotSquared.config.set("UUID.force-lowercase", true); PlotSquared.getInstance().config.set("UUID.force-lowercase", true);
PlotSquared.config.set("UUID.offline", true); PlotSquared.getInstance().config.set("UUID.offline", true);
} }
else if (newWrapper instanceof DefaultUUIDWrapper) { else if (newWrapper instanceof DefaultUUIDWrapper) {
PlotSquared.config.set("UUID.force-lowercase", false); PlotSquared.getInstance().config.set("UUID.force-lowercase", false);
PlotSquared.config.set("UUID.offline", false); PlotSquared.getInstance().config.set("UUID.offline", false);
} }
try { try {
PlotSquared.config.save(PlotSquared.configFile); PlotSquared.getInstance().config.save(PlotSquared.getInstance().configFile);
} }
catch (Exception e) { catch (Exception e) {
MainUtil.sendConsoleMessage("Could not save configuration. It will need to be manuall set!"); MainUtil.sendConsoleMessage("Could not save configuration. It will need to be manuall set!");

View File

@ -131,7 +131,7 @@ public class Merge extends SubCommand {
HashSet<PlotId> multiPlots = new HashSet<>(); HashSet<PlotId> multiPlots = new HashSet<>();
final UUID u1 = plot.owner; final UUID u1 = plot.owner;
for (final PlotId myid : plots) { for (final PlotId myid : plots) {
final Plot myplot = PlotSquared.getPlots(world).get(myid); final Plot myplot = PlotSquared.getInstance().getPlots(world).get(myid);
if (myplot == null || myplot.owner == null) { if (myplot == null || myplot.owner == null) {
MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
return false; return false;

View File

@ -36,12 +36,12 @@ public class Reload extends SubCommand {
try { try {
// The following won't affect world generation, as that has to be // The following won't affect world generation, as that has to be
// loaded during startup unfortunately. // loaded during startup unfortunately.
PlotSquared.config.load(PlotSquared.configFile); PlotSquared.getInstance().config.load(PlotSquared.getInstance().configFile);
PlotSquared.getInstance().setupConfig(); PlotSquared.getInstance().setupConfig();
C.setupTranslations(); C.setupTranslations();
for (final String pw : PlotSquared.getInstance().getPlotWorlds()) { for (final String pw : PlotSquared.getInstance().getPlotWorlds()) {
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(pw); final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(pw);
plotworld.loadDefaultConfiguration(PlotSquared.config.getConfigurationSection("worlds." + pw)); plotworld.loadDefaultConfiguration(PlotSquared.getInstance().config.getConfigurationSection("worlds." + pw));
} }
MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); MainUtil.sendMessage(plr, C.RELOADED_CONFIGS);
} catch (final Exception e) { } catch (final Exception e) {

View File

@ -92,7 +92,7 @@ public class TP extends SubCommand {
} }
return null; return null;
} }
for (final Plot p : PlotSquared.getPlots(world).values()) { for (final Plot p : PlotSquared.getInstance().getPlots(world).values()) {
if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) {
return p; return p;
} }

View File

@ -48,12 +48,12 @@ public class Template extends SubCommand {
public static boolean extractAllFiles(String world, String template) { public static boolean extractAllFiles(String world, String template) {
byte[] buffer = new byte[2048]; byte[] buffer = new byte[2048];
try { try {
File folder = new File(PlotSquared.IMP.getDirectory() + File.separator + "templates"); File folder = new File(PlotSquared.getInstance().IMP.getDirectory() + File.separator + "templates");
if (!folder.exists()) { if (!folder.exists()) {
return false; return false;
} }
File input = new File(folder + File.separator + template + ".template"); File input = new File(folder + File.separator + template + ".template");
File output = PlotSquared.IMP.getDirectory(); File output = PlotSquared.getInstance().IMP.getDirectory();
if (!output.exists()) { if (!output.exists()) {
output.mkdirs(); output.mkdirs();
} }
@ -81,7 +81,7 @@ public class Template extends SubCommand {
} }
public static byte[] getBytes(PlotWorld plotworld) { public static byte[] getBytes(PlotWorld plotworld) {
ConfigurationSection section = PlotSquared.config.getConfigurationSection("worlds." + plotworld.worldname); ConfigurationSection section = PlotSquared.getInstance().config.getConfigurationSection("worlds." + plotworld.worldname);
YamlConfiguration config = new YamlConfiguration(); YamlConfiguration config = new YamlConfiguration();
String generator = SetupUtils.manager.getGenerator(plotworld); String generator = SetupUtils.manager.getGenerator(plotworld);
if (generator != null) { if (generator != null) {
@ -94,7 +94,7 @@ public class Template extends SubCommand {
} }
public static void zipAll(final String world, Set<FileBytes> files) throws IOException { public static void zipAll(final String world, Set<FileBytes> files) throws IOException {
File output = new File(PlotSquared.IMP.getDirectory() + File.separator + "templates"); File output = new File(PlotSquared.getInstance().IMP.getDirectory() + File.separator + "templates");
output.mkdirs(); output.mkdirs();
FileOutputStream fos = new FileOutputStream(output + File.separator + world + ".template"); FileOutputStream fos = new FileOutputStream(output + File.separator + world + ".template");
ZipOutputStream zos = new ZipOutputStream(fos); ZipOutputStream zos = new ZipOutputStream(fos);
@ -140,12 +140,12 @@ public class Template extends SubCommand {
MainUtil.sendMessage(plr, "&cInvalid template file: " + args[2] +".template"); MainUtil.sendMessage(plr, "&cInvalid template file: " + args[2] +".template");
return false; return false;
} }
File worldFile = new File(PlotSquared.IMP.getDirectory() + File.separator + "templates" + File.separator + "tmp-data.yml"); File worldFile = new File(PlotSquared.getInstance().IMP.getDirectory() + File.separator + "templates" + File.separator + "tmp-data.yml");
YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile); YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile);
PlotSquared.config.set("worlds." + world, worldConfig.get("")); PlotSquared.getInstance().config.set("worlds." + world, worldConfig.get(""));
try { try {
PlotSquared.config.save(PlotSquared.configFile); PlotSquared.getInstance().config.save(PlotSquared.getInstance().configFile);
PlotSquared.config.load(PlotSquared.configFile); PlotSquared.getInstance().config.load(PlotSquared.getInstance().configFile);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -120,7 +120,7 @@ public class Trim extends SubCommand {
empty.addAll(chunks); empty.addAll(chunks);
Trim.TASK = false; Trim.TASK = false;
TaskManager.runTaskAsync(whenDone); TaskManager.runTaskAsync(whenDone);
PlotSquared.TASK.cancelTask(Trim.TASK_ID); PlotSquared.getInstance().TASK.cancelTask(Trim.TASK_ID);
return; return;
} }
final Plot plot = plots.get(0); final Plot plot = plots.get(0);

View File

@ -814,8 +814,8 @@ public class SQLManager implements AbstractDB {
Statement stmt = null; Statement stmt = null;
try { try {
Set<String> worlds = new HashSet<>(); Set<String> worlds = new HashSet<>();
if (PlotSquared.config.contains("worlds")) { if (PlotSquared.getInstance().config.contains("worlds")) {
worlds = PlotSquared.config.getConfigurationSection("worlds").getKeys(false); worlds = PlotSquared.getInstance().config.getConfigurationSection("worlds").getKeys(false);
} }
final HashMap<String, UUID> uuids = new HashMap<String, UUID>(); final HashMap<String, UUID> uuids = new HashMap<String, UUID>();
final HashMap<String, Integer> noExist = new HashMap<String, Integer>(); final HashMap<String, Integer> noExist = new HashMap<String, Integer>();
@ -1686,8 +1686,8 @@ public class SQLManager implements AbstractDB {
Statement stmt = null; Statement stmt = null;
try { try {
Set<String> worlds = new HashSet<>(); Set<String> worlds = new HashSet<>();
if (PlotSquared.config.contains("worlds")) { if (PlotSquared.getInstance().config.contains("worlds")) {
worlds = PlotSquared.config.getConfigurationSection("worlds").getKeys(false); worlds = PlotSquared.getInstance().config.getConfigurationSection("worlds").getKeys(false);
} }
final HashMap<String, UUID> uuids = new HashMap<String, UUID>(); final HashMap<String, UUID> uuids = new HashMap<String, UUID>();
final HashMap<String, Integer> noExist = new HashMap<String, Integer>(); final HashMap<String, Integer> noExist = new HashMap<String, Integer>();

View File

@ -114,22 +114,6 @@ public class LikePlotMeConverter {
} }
} }
public void updateWorldYml(String plugin, String location) {
try {
Path path = Paths.get(location);
File file = new File(location);
if (!file.exists()) {
return;
}
Charset charset = StandardCharsets.UTF_8;
String content = new String(Files.readAllBytes(path), charset);
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
content = content.replaceAll(plugin, "PlotSquared");
Files.write(path, content.getBytes(charset));
} catch (Exception e) {
}
}
public boolean run(final APlotMeConnector connector) { public boolean run(final APlotMeConnector connector) {
try { try {
String dataFolder = getPlotMePath(); String dataFolder = getPlotMePath();
@ -166,23 +150,23 @@ public class LikePlotMeConverter {
try { try {
String actualWorldName = getWorld(world); String actualWorldName = getWorld(world);
final Integer pathwidth = plotConfig.getInt("worlds." + world + ".PathWidth"); // final Integer pathwidth = plotConfig.getInt("worlds." + world + ".PathWidth"); //
PlotSquared.config.set("worlds." + actualWorldName + ".road.width", pathwidth); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".road.width", pathwidth);
final Integer plotsize = plotConfig.getInt("worlds." + world + ".PlotSize"); // final Integer plotsize = plotConfig.getInt("worlds." + world + ".PlotSize"); //
PlotSquared.config.set("worlds." + actualWorldName + ".plot.size", plotsize); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".plot.size", plotsize);
final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); // final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); //
PlotSquared.config.set("worlds." + actualWorldName + ".wall.block", wallblock); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".wall.block", wallblock);
final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); // final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); //
PlotSquared.config.set("worlds." + actualWorldName + ".plot.floor", Arrays.asList(floor)); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".plot.floor", Arrays.asList(floor));
final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); // final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); //
PlotSquared.config.set("worlds." + actualWorldName + ".plot.filling", Arrays.asList(filling)); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".plot.filling", Arrays.asList(filling));
final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId"); final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId");
PlotSquared.config.set("worlds." + actualWorldName + ".road.block", road); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".road.block", road);
Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); // Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
if (height == null) { if (height == null) {
height = 64; height = 64;
} }
PlotSquared.config.set("worlds." + actualWorldName + ".road.height", height); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".road.height", height);
PlotSquared.config.save(PlotSquared.configFile); PlotSquared.getInstance().config.save(PlotSquared.getInstance().configFile);
} catch (final Exception e) { } catch (final Exception e) {
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
} }
@ -210,32 +194,32 @@ public class LikePlotMeConverter {
if (pathwidth == null) { if (pathwidth == null) {
pathwidth = 7; pathwidth = 7;
} }
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth); PlotSquared.getInstance().config.set("worlds." + world + ".road.width", pathwidth);
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); // Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
if (plotsize == null) { if (plotsize == null) {
plotsize = 32; plotsize = 32;
} }
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize); PlotSquared.getInstance().config.set("worlds." + world + ".plot.size", plotsize);
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); // String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
if (wallblock == null) { if (wallblock == null) {
wallblock = "44"; wallblock = "44";
} }
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock); PlotSquared.getInstance().config.set("worlds." + world + ".wall.block", wallblock);
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); // String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
if (floor == null) { if (floor == null) {
floor = "2"; floor = "2";
} }
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); PlotSquared.getInstance().config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); // String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
if (filling == null) { if (filling == null) {
filling = "3"; filling = "3";
} }
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); PlotSquared.getInstance().config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock"); String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
if (road == null) { if (road == null) {
road = "5"; road = "5";
} }
PlotSquared.config.set("worlds." + world + ".road.block", road); PlotSquared.getInstance().config.set("worlds." + world + ".road.block", road);
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
if ((height == null) || (height == 0)) { if ((height == null) || (height == 0)) {
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); // height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
@ -243,10 +227,10 @@ public class LikePlotMeConverter {
height = 64; height = 64;
} }
} }
PlotSquared.config.set("worlds." + actualWorldName + ".road.height", height); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".road.height", height);
PlotSquared.config.set("worlds." + actualWorldName + ".plot.height", height); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".plot.height", height);
PlotSquared.config.set("worlds." + actualWorldName + ".wall.height", height); PlotSquared.getInstance().config.set("worlds." + actualWorldName + ".wall.height", height);
PlotSquared.config.save(PlotSquared.configFile); PlotSquared.getInstance().config.save(PlotSquared.getInstance().configFile);
} }
} catch (final Exception e) { } catch (final Exception e) {
} }
@ -254,7 +238,7 @@ public class LikePlotMeConverter {
for (final String world : plots.keySet()) { for (final String world : plots.keySet()) {
int duplicate = 0; int duplicate = 0;
for (final Plot plot : plots.get(world).values()) { for (final Plot plot : plots.get(world).values()) {
if (!PlotSquared.getPlots(world).containsKey(plot.id)) { if (!PlotSquared.getInstance().getPlots(world).containsKey(plot.id)) {
createdPlots.add(plot); createdPlots.add(plot);
} else { } else {
duplicate++; duplicate++;
@ -279,7 +263,7 @@ public class LikePlotMeConverter {
}); });
sendMessage("Saving configuration..."); sendMessage("Saving configuration...");
try { try {
PlotSquared.config.save(PlotSquared.configFile); PlotSquared.getInstance().config.save(PlotSquared.getInstance().configFile);
} catch (final IOException e) { } catch (final IOException e) {
sendMessage(" - &cFailed to save configuration."); sendMessage(" - &cFailed to save configuration.");
} }

View File

@ -233,7 +233,7 @@ public class BukkitHybridUtils extends HybridUtils {
public void run() { public void run() {
int index = chunks.size() - 1; int index = chunks.size() - 1;
if (index == -1) { if (index == -1) {
PlotSquared.TASK.cancelTask(TaskManager.tasks.get(currentIndex)); PlotSquared.getInstance().TASK.cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.runTaskAsync(run); TaskManager.runTaskAsync(run);
return; return;
} }

View File

@ -44,7 +44,7 @@ public abstract class HybridUtils {
final Location pos4 = new Location(world, tx, ty, tz); final Location pos4 = new Location(world, tx, ty, tz);
final CompoundTag sideroad = SchematicHandler.manager.getCompoundTag(world, pos1, pos2); final CompoundTag sideroad = SchematicHandler.manager.getCompoundTag(world, pos1, pos2);
final CompoundTag intersection = SchematicHandler.manager.getCompoundTag(world, pos3, pos4); final CompoundTag intersection = SchematicHandler.manager.getCompoundTag(world, pos3, pos4);
final String dir = PlotSquared.IMP.getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator; final String dir = PlotSquared.getInstance().IMP.getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator;
SchematicHandler.manager.save(sideroad, dir + "sideroad.schematic"); SchematicHandler.manager.save(sideroad, dir + "sideroad.schematic");
SchematicHandler.manager.save(intersection, dir + "intersection.schematic"); SchematicHandler.manager.save(intersection, dir + "intersection.schematic");
plotworld.ROAD_SCHEMATIC_ENABLED = true; plotworld.ROAD_SCHEMATIC_ENABLED = true;

View File

@ -264,7 +264,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
final UUID uuid = pp.getUUID(); final UUID uuid = pp.getUUID();
UUIDHandler.add(name, uuid); UUIDHandler.add(name, uuid);
ExpireManager.dates.put(uuid, System.currentTimeMillis()); ExpireManager.dates.put(uuid, System.currentTimeMillis());
if (PlotSquared.worldEdit != null) { if (PlotSquared.getInstance().worldEdit != null) {
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
WEManager.bypass.add(pp.getName()); WEManager.bypass.add(pp.getName());
} }
@ -463,7 +463,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onWorldChanged(final PlayerChangedWorldEvent event) { public void onWorldChanged(final PlayerChangedWorldEvent event) {
final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer()); final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer());
if (PlotSquared.worldEdit != null) { if (PlotSquared.getInstance().worldEdit != null) {
if (!Permissions.hasPermission(player, "plots.worldedit.bypass")) { if (!Permissions.hasPermission(player, "plots.worldedit.bypass")) {
WEManager.bypass.remove(player.getName()); WEManager.bypass.remove(player.getName());
} }
@ -1126,11 +1126,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis()); ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis());
EventUtil.unregisterPlayer(pp); EventUtil.unregisterPlayer(pp);
if (PlotSquared.worldEdit != null) { if (PlotSquared.getInstance().worldEdit != null) {
WEManager.bypass.remove(pp.getName()); WEManager.bypass.remove(pp.getName());
} }
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
final Collection<Plot> plots = PlotSquared.getPlots(pp.getName()).values(); final Collection<Plot> plots = PlotSquared.getInstance().getPlots(pp.getName()).values();
for (final Plot plot : plots) { for (final Plot plot : plots) {
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world); final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world);
final PlotManager manager = PlotSquared.getInstance().getPlotManager(plot.world); final PlotManager manager = PlotSquared.getInstance().getPlotManager(plot.world);

View File

@ -33,7 +33,7 @@ public class WorldEvents implements Listener {
// //
PlotSquared.getInstance().loadWorld(name, (PlotGenerator) gen); PlotSquared.getInstance().loadWorld(name, (PlotGenerator) gen);
} else { } else {
if (PlotSquared.config.contains("worlds." + name)) { if (PlotSquared.getInstance().config.contains("worlds." + name)) {
PlotSquared.getInstance().loadWorld(name, null); PlotSquared.getInstance().loadWorld(name, null);
} }
} }

View File

@ -93,7 +93,7 @@ public class WEListener implements Listener {
} }
public boolean checkSelection(Player p, PlotPlayer pp, int modifier, long max, Cancellable e) { public boolean checkSelection(Player p, PlotPlayer pp, int modifier, long max, Cancellable e) {
final Selection selection = PlotSquared.worldEdit.getSelection(p); final Selection selection = PlotSquared.getInstance().worldEdit.getSelection(p);
if (selection == null) { if (selection == null) {
return true; return true;
} }

View File

@ -238,7 +238,7 @@ public class ExpireManager {
final String worldname = Bukkit.getWorlds().get(0).getName(); final String worldname = Bukkit.getWorlds().get(0).getName();
String foldername; String foldername;
String filename = null; String filename = null;
if (PlotSquared.IMP.checkVersion(1, 7, 5)) { if (PlotSquared.getInstance().IMP.checkVersion(1, 7, 5)) {
foldername = "playerdata"; foldername = "playerdata";
try { try {
final OfflinePlotPlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); final OfflinePlotPlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);

View File

@ -85,8 +85,8 @@ public class BukkitPlayerFunctions {
} }
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
final Plot plot1 = PlotSquared.getPlots(world).get(pos1); final Plot plot1 = PlotSquared.getInstance().getPlots(world).get(pos1);
final Plot plot2 = PlotSquared.getPlots(world).get(pos2); final Plot plot2 = PlotSquared.getInstance().getPlots(world).get(pos2);
if (plot1 != null) { if (plot1 != null) {
pos1 = MainUtil.getBottomPlot(plot1).id; pos1 = MainUtil.getBottomPlot(plot1).id;
} }
@ -118,8 +118,8 @@ public class BukkitPlayerFunctions {
if (id == null) { if (id == null) {
return null; return null;
} }
if (PlotSquared.getPlots(world).containsKey(id)) { if (PlotSquared.getInstance().getPlots(world).containsKey(id)) {
return PlotSquared.getPlots(world).get(id); return PlotSquared.getInstance().getPlots(world).get(id);
} }
return new Plot(id, null, new ArrayList<UUID>(), new ArrayList<UUID>(), world); return new Plot(id, null, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
} }

View File

@ -46,14 +46,14 @@ public class BukkitSetupUtils extends SetupUtils {
final ConfigurationNode[] steps = object.step; final ConfigurationNode[] steps = object.step;
final String world = object.world; final String world = object.world;
for (final ConfigurationNode step : steps) { for (final ConfigurationNode step : steps) {
PlotSquared.config.set("worlds." + world + "." + step.getConstant(), step.getValue()); PlotSquared.getInstance().config.set("worlds." + world + "." + step.getConstant(), step.getValue());
} }
if (object.type != 0) { if (object.type != 0) {
PlotSquared.config.set("worlds." + world + "." + "generator.type", object.type); PlotSquared.getInstance().config.set("worlds." + world + "." + "generator.type", object.type);
PlotSquared.config.set("worlds." + world + "." + "generator.terrain", object.terrain); PlotSquared.getInstance().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
PlotSquared.config.set("worlds." + world + "." + "generator.plugin", object.plotManager); PlotSquared.getInstance().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) { if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
PlotSquared.config.set("worlds." + world + "." + "generator.init", object.setupGenerator); PlotSquared.getInstance().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
} }
ChunkGenerator gen = generators.get(object.setupGenerator); ChunkGenerator gen = generators.get(object.setupGenerator);
if (gen instanceof PlotGenerator) { if (gen instanceof PlotGenerator) {
@ -61,7 +61,7 @@ public class BukkitSetupUtils extends SetupUtils {
} }
} }
try { try {
PlotSquared.config.save(PlotSquared.configFile); PlotSquared.getInstance().config.save(PlotSquared.getInstance().configFile);
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }