mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-22 16:05:02 +00:00
Completed and ready to test
This commit is contained in:
parent
aaf9511673
commit
74ed10c376
43 changed files with 578 additions and 1202 deletions
|
@ -4,8 +4,9 @@ import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
|||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.SubCommand;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
@ -378,11 +379,9 @@ public class PlotAPI {
|
|||
*
|
||||
* @param flag Flag that should be registered
|
||||
*
|
||||
* @see FlagManager#addFlag(AbstractFlag)
|
||||
* @see AbstractFlag
|
||||
*/
|
||||
public void addFlag(AbstractFlag flag) {
|
||||
FlagManager.addFlag(flag);
|
||||
public void addFlag(Flag<?> flag) {
|
||||
Flags.getFlags().add(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -177,17 +177,11 @@ public class LikePlotMeConverter {
|
|||
Integer pathWidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||
PS.get().config.set("worlds." + world + ".road.width", pathWidth);
|
||||
|
||||
int pathHeight = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if (pathHeight == 0) {
|
||||
pathHeight = 64;
|
||||
}
|
||||
int pathHeight = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight", 64); //
|
||||
PS.get().config.set("worlds." + world + ".road.height", pathHeight);
|
||||
PS.get().config.set("worlds." + world + ".wall.height", pathHeight);
|
||||
PS.get().config.set("worlds." + world + ".plot.height", pathHeight);
|
||||
int plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize", 32); //
|
||||
if (plotSize == 0) {
|
||||
plotSize = 32;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.size", plotSize);
|
||||
String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44"); //
|
||||
PS.get().config.set("worlds." + world + ".wall.block", wallblock);
|
||||
|
@ -199,10 +193,7 @@ public class LikePlotMeConverter {
|
|||
PS.get().config.set("worlds." + world + ".road.block", road);
|
||||
int height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if (height == 0) {
|
||||
height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
||||
if (height == 0) {
|
||||
height = 64;
|
||||
}
|
||||
height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight", 64); //
|
||||
}
|
||||
PS.get().config.set("worlds." + actualWorldName + ".road.height", height);
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.height", height);
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.intellectualcrafters.plot.PS;
|
|||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.flag.NumericFlag;
|
||||
import com.intellectualcrafters.plot.flag.IntegerFlag;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
|
@ -1370,9 +1370,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
this.lastRadius = event.getRadius() + 1;
|
||||
}
|
||||
|
||||
public boolean checkEntity(Plot plot, NumericFlag<Integer>... flags) {
|
||||
public boolean checkEntity(Plot plot, IntegerFlag... flags) {
|
||||
int[] mobs = null;
|
||||
for (NumericFlag<Integer> flag : flags) {
|
||||
for (IntegerFlag flag : flags) {
|
||||
int i;
|
||||
switch (flag.getName()) {
|
||||
case "entity-cap":
|
||||
|
|
|
@ -101,11 +101,11 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
||||
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
||||
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
||||
PS.get().config.set("worlds." + world + ".generator.type", object.type);
|
||||
PS.get().config.set("worlds." + world + ".generator.terrain", object.terrain);
|
||||
PS.get().config.set("worlds." + world + ".generator.plugin", object.plotManager);
|
||||
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||
PS.get().config.set("worlds." + world + ".generator.init", object.setupGenerator);
|
||||
}
|
||||
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||
if (gen != null && gen.isFull()) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.intellectualcrafters.configuration;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
|
@ -540,6 +542,7 @@ public class MemorySection implements ConfigurationSection {
|
|||
List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
PS.get().IMP.log(path + " is null");
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,6 @@ import com.intellectualcrafters.plot.database.Database;
|
|||
import com.intellectualcrafters.plot.database.MySQL;
|
||||
import com.intellectualcrafters.plot.database.SQLManager;
|
||||
import com.intellectualcrafters.plot.database.SQLite;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
|
@ -40,8 +37,6 @@ import com.intellectualcrafters.plot.util.ExpireManager;
|
|||
import com.intellectualcrafters.plot.util.InventoryUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.PlotGameMode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
|
@ -164,7 +159,6 @@ public class PS {
|
|||
setupConfigs();
|
||||
this.translationFile = new File(this.IMP.getDirectory() + File.separator + "translations" + File.separator + "PlotSquared.use_THIS.yml");
|
||||
C.load(this.translationFile);
|
||||
setupDefaultFlags();
|
||||
setupDatabase();
|
||||
CommentManager.registerDefaultInboxes();
|
||||
// Tasks
|
||||
|
@ -488,21 +482,18 @@ public class PS {
|
|||
|
||||
public PlotArea getPlotArea(String world, String id) {
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
if (areas == null) {
|
||||
if (areas == null || id == null) {
|
||||
return null;
|
||||
}
|
||||
if (areas.length == 1) {
|
||||
return areas[0];
|
||||
} else if (id == null) {
|
||||
return null;
|
||||
} else {
|
||||
for (PlotArea area : areas) {
|
||||
if (StringMan.isEqual(id, area.id)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
for (PlotArea area : areas) {
|
||||
if (StringMan.isEqual(id, area.id)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PlotArea getPlotAreaAbs(String world, String id) {
|
||||
|
@ -1346,28 +1337,38 @@ public class PS {
|
|||
if (!this.plotAreaHasCollision && !this.plotAreaHashCheck.add(world.hashCode())) {
|
||||
this.plotAreaHasCollision = true;
|
||||
}
|
||||
Set<String> worlds = this.config.contains("worlds") ? this.config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>();
|
||||
Set<String> worlds;
|
||||
if (this.config.contains("worlds")) {
|
||||
worlds = this.config.getConfigurationSection("worlds").getKeys(false);
|
||||
} else {
|
||||
worlds = new HashSet<>();
|
||||
}
|
||||
String path = "worlds." + world;
|
||||
ConfigurationSection worldSection = this.config.getConfigurationSection(path);
|
||||
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
|
||||
int type;
|
||||
if (worldSection != null) {
|
||||
type = worldSection.getInt("generator.type", 0);
|
||||
} else {
|
||||
type = 0;
|
||||
}
|
||||
if (type == 0) {
|
||||
if (this.plotAreaMap.containsKey(world)) {
|
||||
debug("World possibly already loaded: " + world);
|
||||
return;
|
||||
}
|
||||
IndependentPlotGenerator pg;
|
||||
IndependentPlotGenerator plotGenerator;
|
||||
if (baseGenerator != null && baseGenerator.isFull()) {
|
||||
pg = baseGenerator.getPlotGenerator();
|
||||
plotGenerator = baseGenerator.getPlotGenerator();
|
||||
} else if (worldSection != null) {
|
||||
String secondaryGeneratorName = worldSection.getString("generator.plugin");
|
||||
GeneratorWrapper<?> secondaryGenerator = this.IMP.getGenerator(world, secondaryGeneratorName);
|
||||
if (secondaryGenerator != null && secondaryGenerator.isFull()) {
|
||||
pg = secondaryGenerator.getPlotGenerator();
|
||||
plotGenerator = secondaryGenerator.getPlotGenerator();
|
||||
} else {
|
||||
String primaryGeneratorName = worldSection.getString("generator.init");
|
||||
GeneratorWrapper<?> primaryGenerator = this.IMP.getGenerator(world, primaryGeneratorName);
|
||||
if (primaryGenerator != null && primaryGenerator.isFull()) {
|
||||
pg = primaryGenerator.getPlotGenerator();
|
||||
plotGenerator = primaryGenerator.getPlotGenerator();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -1376,10 +1377,10 @@ public class PS {
|
|||
return;
|
||||
}
|
||||
// Conventional plot generator
|
||||
PlotArea plotArea = pg.getNewPlotArea(world, null, null, null);
|
||||
PlotManager plotManager = pg.getNewPlotManager();
|
||||
PlotArea plotArea = plotGenerator.getNewPlotArea(world, null, null, null);
|
||||
PlotManager plotManager = plotGenerator.getNewPlotManager();
|
||||
PS.log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
PS.log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + pg);
|
||||
PS.log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + plotGenerator);
|
||||
PS.log(C.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
||||
PS.log(C.PREFIX + "&3 - manager: &7" + plotManager.getClass().getName());
|
||||
if (!this.config.contains(path)) {
|
||||
|
@ -1395,7 +1396,7 @@ public class PS {
|
|||
}
|
||||
// Now add it
|
||||
addPlotArea(plotArea);
|
||||
pg.initialize(plotArea);
|
||||
plotGenerator.initialize(plotArea);
|
||||
plotArea.setupBorder();
|
||||
} else {
|
||||
if (!worlds.contains(world)) {
|
||||
|
@ -1805,136 +1806,6 @@ public class PS {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the default flags for PlotSquared.
|
||||
* - Create the flags
|
||||
* - Register with FlagManager and parse raw flag values
|
||||
*/
|
||||
public void setupDefaultFlags() {
|
||||
List<String> booleanFlags =
|
||||
Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles",
|
||||
"pve", "pvp",
|
||||
"no-worldedit", "redstone");
|
||||
List<String> intervalFlags = Arrays.asList("feed", "heal");
|
||||
List<String> stringFlags = Arrays.asList("greeting", "farewell");
|
||||
List<String> intFlags = Arrays.asList("misc-cap", "entity-cap", "mob-cap", "animal-cap", "hostile-cap", "vehicle-cap", "music");
|
||||
for (String flag : stringFlags) {
|
||||
FlagManager.addFlag(new AbstractFlag(flag));
|
||||
}
|
||||
for (String flag : intervalFlags) {
|
||||
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.IntervalValue()));
|
||||
}
|
||||
for (String flag : booleanFlags) {
|
||||
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue()));
|
||||
}
|
||||
for (String flag : intFlags) {
|
||||
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue()));
|
||||
}
|
||||
FlagManager.addFlag(new AbstractFlag("done", new FlagValue.StringValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("analysis", new FlagValue.IntegerListValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("disable-physics", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("mob-place", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("hostile-attack", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("animal-interact", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("animal-attack", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("tamed-interact", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("tamed-attack", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("player-interact", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("misc-interact", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("misc-place", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("misc-break", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("hanging-interact", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("hanging-place", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("hanging-break", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("vehicle-use", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("vehicle-place", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("vehicle-break", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("device-interact", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("place", new FlagValue.PlotBlockListValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("break", new FlagValue.PlotBlockListValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("use", new FlagValue.PlotBlockListValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("blocked-cmds", new FlagValue.StringListValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("ice-melt", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("soil-dry", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("grass-grow", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("mycel-grow", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("vine-grow", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("block-ignition", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("block-burn", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("fire-spread", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("snow-melt", new FlagValue.BooleanValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("keep") {
|
||||
@Override
|
||||
public Object parseValueRaw(String value) {
|
||||
if (MathMan.isInteger(value)) {
|
||||
return Long.parseLong(value);
|
||||
}
|
||||
switch (value.toLowerCase()) {
|
||||
case "true":
|
||||
return true;
|
||||
case "false":
|
||||
return false;
|
||||
default:
|
||||
return MainUtil.timeToSec(value) * 1000 + System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
FlagManager.addFlag(new AbstractFlag("gamemode") {
|
||||
|
||||
@Override
|
||||
public PlotGameMode parseValueRaw(String value) {
|
||||
switch (value.toLowerCase()) {
|
||||
case "survival":
|
||||
case "s":
|
||||
case "0":
|
||||
return PlotGameMode.SURVIVAL;
|
||||
case "creative":
|
||||
case "c":
|
||||
case "1":
|
||||
return PlotGameMode.CREATIVE;
|
||||
case "adventure":
|
||||
case "a":
|
||||
case "2":
|
||||
return PlotGameMode.ADVENTURE;
|
||||
case "spectator":
|
||||
case "3":
|
||||
return PlotGameMode.SPECTATOR;
|
||||
default:
|
||||
return PlotGameMode.NOT_SET;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
FlagManager.addFlag(new AbstractFlag("price", new FlagValue.UnsignedDoubleValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("time", new FlagValue.LongValue()));
|
||||
FlagManager.addFlag(new AbstractFlag("weather") {
|
||||
|
||||
@Override
|
||||
public PlotWeather parseValueRaw(String value) {
|
||||
switch (value.toLowerCase()) {
|
||||
case "rain":
|
||||
case "storm":
|
||||
case "on":
|
||||
case "lightning":
|
||||
case "thunder":
|
||||
return PlotWeather.RAIN;
|
||||
case "clear":
|
||||
case "off":
|
||||
case "sun":
|
||||
return PlotWeather.CLEAR;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
FlagManager.addFlag(new AbstractFlag("description", new FlagValue.StringValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the default configuration (settings.yml)
|
||||
*/
|
||||
|
|
|
@ -193,7 +193,7 @@ public class Condense extends SubCommand {
|
|||
MainUtil.sendMessage(plr, "=== INPUT EVAL ===");
|
||||
MainUtil.sendMessage(plr, "INPUT RADIUS: " + radius);
|
||||
MainUtil.sendMessage(plr, "ESTIMATED MOVES: " + userMove);
|
||||
MainUtil.sendMessage(plr, "ESTIMATED TIME: " + "No idea, times will drastically change based on the system performance and load");
|
||||
MainUtil.sendMessage(plr, "ESTIMATED TIME: No idea, times will drastically change based on the system performance and load");
|
||||
MainUtil.sendMessage(plr, "&e - Radius is measured in plot width");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class FlagCmd extends SubCommand {
|
|||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return super.getUsage().replaceAll("<flag>", StringMan.join(Flags.getFlags(), "|"));
|
||||
return super.getUsage();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,9 +64,13 @@ public class FlagCmd extends SubCommand {
|
|||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other");
|
||||
return false;
|
||||
}
|
||||
if (args.length > 1 && FlagManager.isReserved(FlagManager.getFlag(args[1]))) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
return false;
|
||||
Flag<?> flag = null;
|
||||
if (args.length > 1) {
|
||||
flag = FlagManager.getFlag(args[1]);
|
||||
if (flag == null || FlagManager.isReserved(flag)) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "info": {
|
||||
|
@ -78,12 +82,6 @@ public class FlagCmd extends SubCommand {
|
|||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||
return false;
|
||||
}
|
||||
Flag<?> flag = FlagManager.getFlag(args[1]);
|
||||
if (flag == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||
return false;
|
||||
}
|
||||
// flag key
|
||||
MainUtil.sendMessage(player, C.FLAG_KEY, flag.getName());
|
||||
// flag type
|
||||
|
@ -101,22 +99,17 @@ public class FlagCmd extends SubCommand {
|
|||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set <flag> <value>");
|
||||
return false;
|
||||
}
|
||||
Flag<?> af = FlagManager.getFlag(args[1].toLowerCase());
|
||||
if (af == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
return false;
|
||||
}
|
||||
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase())) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase());
|
||||
return false;
|
||||
}
|
||||
Object parsed = af.parseValue(value);
|
||||
Object parsed = flag.parseValue(value);
|
||||
if (parsed == null) {
|
||||
MainUtil.sendMessage(player, "&c" + af.getValueDescription());
|
||||
MainUtil.sendMessage(player, "&c" + flag.getValueDescription());
|
||||
return false;
|
||||
}
|
||||
boolean result = plot.setFlag(af, parsed);
|
||||
boolean result = plot.setFlag(flag, parsed);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
|
@ -125,42 +118,42 @@ public class FlagCmd extends SubCommand {
|
|||
return true;
|
||||
}
|
||||
case "remove": {
|
||||
if (!Permissions.hasPermission(player, "plots.flagValue.remove")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flagValue.remove");
|
||||
if (!Permissions.hasPermission(player, "plots.flag.remove")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove");
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flagValue remove <flagValue> [values]");
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
|
||||
return false;
|
||||
}
|
||||
Flag<?> flag1 = FlagManager.getFlag(args[1].toLowerCase());
|
||||
if (flag1 == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
return false;
|
||||
}
|
||||
Optional<?> flagValue = plot.getFlag(flag1);
|
||||
if (!Permissions.hasPermission(player, "plots.set.flagValue." + args[1].toLowerCase())) {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flagValue." + args[1].toLowerCase());
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||
return false;
|
||||
}
|
||||
for (String entry : args[2].split(",")) {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flagValue." + args[1].toLowerCase() + "." + entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flagValue." + args[1].toLowerCase() + "." + entry);
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flagValue.isPresent()) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
if (args.length == 3 && flag1 instanceof ListFlag) {
|
||||
if (args.length == 3 && flag instanceof ListFlag) {
|
||||
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
boolean listFlag = ((Collection) plot.getFlags().get(flag1)).remove(flag1.parseValue(value));
|
||||
Optional<? extends Collection> flag1 = plot.getFlag((Flag<? extends Collection<?>>) flag);
|
||||
if (flag1.isPresent()) {
|
||||
boolean o = flag1.get().remove(flag.parseValue(value));
|
||||
if (o) {
|
||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_REMOVED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
DBFunc.setFlags(plot, plot.getFlags());
|
||||
return true;
|
||||
} else {
|
||||
boolean result = plot.removeFlag(flag1);
|
||||
boolean result = plot.removeFlag(flag);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_REMOVED);
|
||||
return false;
|
||||
|
@ -178,11 +171,6 @@ public class FlagCmd extends SubCommand {
|
|||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add <flag> <values>");
|
||||
return false;
|
||||
}
|
||||
Flag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||
if (af == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
return false;
|
||||
}
|
||||
for (String entry : args[2].split(",")) {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry);
|
||||
|
@ -190,18 +178,26 @@ public class FlagCmd extends SubCommand {
|
|||
}
|
||||
}
|
||||
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
Object parsed = af.parseValue(value);
|
||||
Object parsed = flag.parseValue(value);
|
||||
if (parsed == null) {
|
||||
MainUtil.sendMessage(player, "&c" + af.getValueDescription());
|
||||
MainUtil.sendMessage(player, "&c" + flag.getValueDescription());
|
||||
return false;
|
||||
}
|
||||
Optional<?> flag = plot.getFlag(af);
|
||||
if (flag.isPresent()) {
|
||||
if (af instanceof ListFlag) {
|
||||
((Collection) flag.get()).addAll((Collection) parsed);
|
||||
Object val = parsed;
|
||||
if (flag instanceof ListFlag) {
|
||||
Optional<? extends Collection> flag1 = plot.getFlag((Flag<? extends Collection<?>>) flag);
|
||||
if (flag1.isPresent()) {
|
||||
boolean o = flag1.get().addAll((Collection) parsed);
|
||||
if (o) {
|
||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||
val = flag1.get();
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean result = FlagManager.addPlotFlag(plot, af, parsed);
|
||||
boolean result = plot.setFlag(flag, val);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
|
@ -213,17 +209,17 @@ public class FlagCmd extends SubCommand {
|
|||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.list");
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
if (args.length > 1) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list");
|
||||
return false;
|
||||
}
|
||||
HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
||||
for (Flag flag1 : Flags.getFlags()) {
|
||||
String type = flag1.getClass().getSimpleName().replaceAll("Value", "");
|
||||
for (Flag<?> flag1 : Flags.getFlags()) {
|
||||
String type = flag1.getClass().getSimpleName();
|
||||
if (!flags.containsKey(type)) {
|
||||
flags.put(type, new ArrayList<String>());
|
||||
}
|
||||
//todo flags.get(type).add(flag1.getKey());
|
||||
flags.get(type).add(flag1.getName());
|
||||
}
|
||||
String message = "";
|
||||
String prefix = "";
|
||||
|
|
|
@ -111,7 +111,7 @@ public class Info extends SubCommand {
|
|||
if (info == null) {
|
||||
MainUtil.sendMessage(player,
|
||||
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aexpires&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
|
||||
+ "&aowner&7, " + "&arating");
|
||||
+ "&aowner&7, &arating");
|
||||
return false;
|
||||
}
|
||||
full = true;
|
||||
|
|
|
@ -2,7 +2,8 @@ package com.intellectualcrafters.plot.commands;
|
|||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
|
@ -160,13 +161,8 @@ public class Set extends SubCommand {
|
|||
return this.component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
|
||||
}
|
||||
// flag
|
||||
AbstractFlag af;
|
||||
try {
|
||||
af = new AbstractFlag(args[0].toLowerCase());
|
||||
} catch (Exception e) {
|
||||
af = new AbstractFlag("");
|
||||
}
|
||||
if (Flags.getFlags().contains(af)) {
|
||||
Flag<?> flag = FlagManager.getFlag(args[0].toLowerCase());
|
||||
if (Flags.getFlags().contains(flag)) {
|
||||
StringBuilder a = new StringBuilder();
|
||||
if (args.length > 1) {
|
||||
for (int x = 1; x < args.length; x++) {
|
||||
|
|
|
@ -86,7 +86,7 @@ public class Setup extends SubCommand {
|
|||
object.setupGenerator = args[0];
|
||||
object.current++;
|
||||
String partial = "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots";
|
||||
MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
||||
MainUtil.sendMessage(plr, "&6What world type do you want?\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
||||
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
|
||||
break;
|
||||
case 1: // choose world type
|
||||
|
|
|
@ -41,6 +41,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
|
||||
public class SQLManager implements AbstractDB {
|
||||
|
||||
// Public final
|
||||
public final String SET_OWNER;
|
||||
public final String GET_ALL_PLOTS;
|
||||
|
@ -515,7 +516,7 @@ public class SQLManager implements AbstractDB {
|
|||
});
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&7[WARN] " + "Failed to set all helpers for plots");
|
||||
PS.debug("&7[WARN] Failed to set all helpers for plots");
|
||||
try {
|
||||
SQLManager.this.connection.commit();
|
||||
} catch (SQLException e1) {
|
||||
|
@ -526,7 +527,7 @@ public class SQLManager implements AbstractDB {
|
|||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&7[WARN] " + "Failed to set all helpers for plots");
|
||||
PS.debug("&7[WARN] Failed to set all helpers for plots");
|
||||
try {
|
||||
SQLManager.this.connection.commit();
|
||||
} catch (SQLException e1) {
|
||||
|
@ -699,7 +700,7 @@ public class SQLManager implements AbstractDB {
|
|||
} catch (SQLException e) {
|
||||
if (this.mySQL) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&cERROR 1: " + " | " + objList.get(0).getClass().getCanonicalName());
|
||||
PS.debug("&cERROR 1: | " + objList.get(0).getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
@ -737,8 +738,8 @@ public class SQLManager implements AbstractDB {
|
|||
preparedStmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&cERROR 2: " + " | " + objList.get(0).getClass().getCanonicalName());
|
||||
PS.debug("&6[WARN] " + "Could not bulk save!");
|
||||
PS.debug("&cERROR 2: | " + objList.get(0).getClass().getCanonicalName());
|
||||
PS.debug("&6[WARN] Could not bulk save!");
|
||||
try {
|
||||
String nonBulk = mod.getCreateSQL();
|
||||
PreparedStatement preparedStmt = this.connection.prepareStatement(nonBulk);
|
||||
|
@ -747,7 +748,7 @@ public class SQLManager implements AbstractDB {
|
|||
mod.setSQL(preparedStmt, obj);
|
||||
preparedStmt.addBatch();
|
||||
} catch (SQLException e3) {
|
||||
PS.debug("&c[ERROR] " + "Failed to save " + obj + "!");
|
||||
PS.debug("&c[ERROR] Failed to save " + obj + "!");
|
||||
}
|
||||
}
|
||||
PS.debug("&aBatch 3");
|
||||
|
@ -755,7 +756,7 @@ public class SQLManager implements AbstractDB {
|
|||
preparedStmt.close();
|
||||
} catch (SQLException e3) {
|
||||
e3.printStackTrace();
|
||||
PS.debug("&c[ERROR] " + "Failed to save all!");
|
||||
PS.debug("&c[ERROR] Failed to save all!");
|
||||
}
|
||||
}
|
||||
if (whenDone != null) {
|
||||
|
@ -770,17 +771,18 @@ public class SQLManager implements AbstractDB {
|
|||
return getCreateMySQL(size, "INSERT INTO `" + SQLManager.this.prefix
|
||||
+ "plot_settings`(`plot_plot_id`,`biome`,`rain`,`custom_time`,`time`,`deny_entry`,`alias`,`flags`,`merged`,"
|
||||
+ "`position`) VALUES ",
|
||||
10);
|
||||
10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateSQLite(int size) {
|
||||
return getCreateSQLite(
|
||||
size,
|
||||
"INSERT INTO `"
|
||||
+ SQLManager.this.prefix
|
||||
+ "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position`",
|
||||
10);
|
||||
size,
|
||||
"INSERT INTO `"
|
||||
+ SQLManager.this.prefix
|
||||
+ "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS "
|
||||
+ "`deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position`",
|
||||
10);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -888,11 +890,12 @@ public class SQLManager implements AbstractDB {
|
|||
@Override
|
||||
public String getCreateSQLite(int size) {
|
||||
return getCreateSQLite(
|
||||
size,
|
||||
"INSERT INTO `"
|
||||
+ SQLManager.this.prefix
|
||||
+ "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` ",
|
||||
10);
|
||||
size,
|
||||
"INSERT INTO `"
|
||||
+ SQLManager.this.prefix
|
||||
+ "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS "
|
||||
+ "`deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` ",
|
||||
10);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1010,7 +1013,7 @@ public class SQLManager implements AbstractDB {
|
|||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
return SQLManager.this.connection
|
||||
.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)");
|
||||
.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)");
|
||||
}
|
||||
});
|
||||
addNotifyTask(whenDone);
|
||||
|
@ -1023,7 +1026,9 @@ public class SQLManager implements AbstractDB {
|
|||
*/
|
||||
@Override
|
||||
public void createTables() throws SQLException {
|
||||
String[] tables = new String[] { "plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings", "cluster", "player_meta" };
|
||||
String[] tables =
|
||||
new String[]{"plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings", "cluster",
|
||||
"player_meta"};
|
||||
DatabaseMetaData meta = this.connection.getMetaData();
|
||||
int create = 0;
|
||||
for (String s : tables) {
|
||||
|
@ -1039,203 +1044,204 @@ public class SQLManager implements AbstractDB {
|
|||
}
|
||||
boolean addConstraint = create == tables.length;
|
||||
PS.debug("Creating tables");
|
||||
Statement stmt = this.connection.createStatement();
|
||||
if (this.mySQL) {
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot` ("
|
||||
+ "`id` INT(11) NOT NULL AUTO_INCREMENT,"
|
||||
+ "`plot_id_x` INT(11) NOT NULL,"
|
||||
+ "`plot_id_z` INT(11) NOT NULL,"
|
||||
+ "`owner` VARCHAR(40) NOT NULL,"
|
||||
+ "`world` VARCHAR(45) NOT NULL,"
|
||||
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
|
||||
+ "PRIMARY KEY (`id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||
stmt
|
||||
.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_helpers` ("
|
||||
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_comments` ("
|
||||
+ "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL,"
|
||||
+ "`comment` VARCHAR(40) NOT NULL,"
|
||||
+ "`inbox` VARCHAR(40) NOT NULL,"
|
||||
+ "`timestamp` INT(11) NOT NULL,"
|
||||
+ "`sender` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_trusted` ("
|
||||
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_settings` ("
|
||||
+ " `plot_plot_id` INT(11) NOT NULL,"
|
||||
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||
+ " `rain` INT(1) DEFAULT 0,"
|
||||
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||
+ " `time` INT(11) DEFAULT '8000',"
|
||||
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||
+ " `merged` INT(11) DEFAULT NULL,"
|
||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||
+ " PRIMARY KEY (`plot_plot_id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_rating` ( `plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
if (addConstraint) {
|
||||
stmt.addBatch("ALTER TABLE `"
|
||||
try (Statement stmt = this.connection.createStatement()) {
|
||||
if (this.mySQL) {
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_settings` ADD CONSTRAINT `"
|
||||
+ "plot` ("
|
||||
+ "`id` INT(11) NOT NULL AUTO_INCREMENT,"
|
||||
+ "`plot_id_x` INT(11) NOT NULL,"
|
||||
+ "`plot_id_z` INT(11) NOT NULL,"
|
||||
+ "`owner` VARCHAR(40) NOT NULL,"
|
||||
+ "`world` VARCHAR(45) NOT NULL,"
|
||||
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
|
||||
+ "PRIMARY KEY (`id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||
stmt
|
||||
.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `"
|
||||
+ "plot_helpers` ("
|
||||
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot` (`id`) ON DELETE CASCADE");
|
||||
+ "plot_comments` ("
|
||||
+ "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL,"
|
||||
+ "`comment` VARCHAR(40) NOT NULL,"
|
||||
+ "`inbox` VARCHAR(40) NOT NULL,"
|
||||
+ "`timestamp` INT(11) NOT NULL,"
|
||||
+ "`sender` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_trusted` ("
|
||||
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_settings` ("
|
||||
+ " `plot_plot_id` INT(11) NOT NULL,"
|
||||
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||
+ " `rain` INT(1) DEFAULT 0,"
|
||||
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||
+ " `time` INT(11) DEFAULT '8000',"
|
||||
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||
+ " `merged` INT(11) DEFAULT NULL,"
|
||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||
+ " PRIMARY KEY (`plot_plot_id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_rating` ( `plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL) ENGINE=InnoDB "
|
||||
+ "DEFAULT CHARSET=utf8");
|
||||
if (addConstraint) {
|
||||
stmt.addBatch("ALTER TABLE `"
|
||||
+ this.prefix
|
||||
+ "plot_settings` ADD CONSTRAINT `"
|
||||
+ this.prefix
|
||||
+ "plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `"
|
||||
+ this.prefix
|
||||
+ "plot` (`id`) ON DELETE CASCADE");
|
||||
}
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster` ("
|
||||
+ "`id` INT(11) NOT NULL AUTO_INCREMENT,"
|
||||
+ "`pos1_x` INT(11) NOT NULL,"
|
||||
+ "`pos1_z` INT(11) NOT NULL,"
|
||||
+ "`pos2_x` INT(11) NOT NULL,"
|
||||
+ "`pos2_z` INT(11) NOT NULL,"
|
||||
+ "`owner` VARCHAR(40) NOT NULL,"
|
||||
+ "`world` VARCHAR(45) NOT NULL,"
|
||||
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
|
||||
+ "PRIMARY KEY (`id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster_helpers` ("
|
||||
+ "`cluster_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster_invited` ("
|
||||
+ "`cluster_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster_settings` ("
|
||||
+ " `cluster_id` INT(11) NOT NULL,"
|
||||
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||
+ " `rain` INT(1) DEFAULT 0,"
|
||||
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||
+ " `time` INT(11) DEFAULT '8000',"
|
||||
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||
+ " `merged` INT(11) DEFAULT NULL,"
|
||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||
+ " PRIMARY KEY (`cluster_id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "player_meta` ("
|
||||
+ " `meta_id` INT(11) NOT NULL AUTO_INCREMENT,"
|
||||
+ " `uuid` VARCHAR(40) NOT NULL,"
|
||||
+ " `key` VARCHAR(32) NOT NULL,"
|
||||
+ " `value` blob NOT NULL,"
|
||||
+ " PRIMARY KEY (`meta_id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
} else {
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot` ("
|
||||
+ "`id` INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
+ "`plot_id_x` INT(11) NOT NULL,"
|
||||
+ "`plot_id_z` INT(11) NOT NULL,"
|
||||
+ "`owner` VARCHAR(45) NOT NULL,"
|
||||
+ "`world` VARCHAR(45) NOT NULL,"
|
||||
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL)");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL)");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL)");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_comments` ("
|
||||
+ "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL,"
|
||||
+ "`comment` VARCHAR(40) NOT NULL,"
|
||||
+ "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL,"
|
||||
+ "`sender` VARCHAR(40) NOT NULL"
|
||||
+ ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_settings` ("
|
||||
+ " `plot_plot_id` INT(11) NOT NULL,"
|
||||
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||
+ " `rain` INT(1) DEFAULT 0,"
|
||||
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||
+ " `time` INT(11) DEFAULT '8000',"
|
||||
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||
+ " `merged` INT(11) DEFAULT NULL,"
|
||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||
+ " PRIMARY KEY (`plot_plot_id`)"
|
||||
+ ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix
|
||||
+ "plot_rating` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL)");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster` ("
|
||||
+ "`id` INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
+ "`pos1_x` INT(11) NOT NULL,"
|
||||
+ "`pos1_z` INT(11) NOT NULL,"
|
||||
+ "`pos2_x` INT(11) NOT NULL,"
|
||||
+ "`pos2_z` INT(11) NOT NULL,"
|
||||
+ "`owner` VARCHAR(40) NOT NULL,"
|
||||
+ "`world` VARCHAR(45) NOT NULL,"
|
||||
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP"
|
||||
+ ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (`cluster_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL)");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (`cluster_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL)");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster_settings` ("
|
||||
+ " `cluster_id` INT(11) NOT NULL,"
|
||||
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||
+ " `rain` INT(1) DEFAULT 0,"
|
||||
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||
+ " `time` INT(11) DEFAULT '8000',"
|
||||
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||
+ " `merged` INT(11) DEFAULT NULL,"
|
||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||
+ " PRIMARY KEY (`cluster_id`)"
|
||||
+ ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "player_meta` ("
|
||||
+ " `meta_id` INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
+ " `uuid` VARCHAR(40) NOT NULL,"
|
||||
+ " `key` VARCHAR(32) NOT NULL,"
|
||||
+ " `value` blob NOT NULL"
|
||||
+ ")");
|
||||
}
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster` ("
|
||||
+ "`id` INT(11) NOT NULL AUTO_INCREMENT,"
|
||||
+ "`pos1_x` INT(11) NOT NULL,"
|
||||
+ "`pos1_z` INT(11) NOT NULL,"
|
||||
+ "`pos2_x` INT(11) NOT NULL,"
|
||||
+ "`pos2_z` INT(11) NOT NULL,"
|
||||
+ "`owner` VARCHAR(40) NOT NULL,"
|
||||
+ "`world` VARCHAR(45) NOT NULL,"
|
||||
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
|
||||
+ "PRIMARY KEY (`id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster_helpers` ("
|
||||
+ "`cluster_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster_invited` ("
|
||||
+ "`cluster_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster_settings` ("
|
||||
+ " `cluster_id` INT(11) NOT NULL,"
|
||||
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||
+ " `rain` INT(1) DEFAULT 0,"
|
||||
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||
+ " `time` INT(11) DEFAULT '8000',"
|
||||
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||
+ " `merged` INT(11) DEFAULT NULL,"
|
||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||
+ " PRIMARY KEY (`cluster_id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "player_meta` ("
|
||||
+ " `meta_id` INT(11) NOT NULL AUTO_INCREMENT,"
|
||||
+ " `uuid` VARCHAR(40) NOT NULL,"
|
||||
+ " `key` VARCHAR(32) NOT NULL,"
|
||||
+ " `value` blob NOT NULL,"
|
||||
+ " PRIMARY KEY (`meta_id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
} else {
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot` ("
|
||||
+ "`id` INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
+ "`plot_id_x` INT(11) NOT NULL,"
|
||||
+ "`plot_id_z` INT(11) NOT NULL,"
|
||||
+ "`owner` VARCHAR(45) NOT NULL,"
|
||||
+ "`world` VARCHAR(45) NOT NULL,"
|
||||
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_comments` ("
|
||||
+ "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL,"
|
||||
+ "`comment` VARCHAR(40) NOT NULL,"
|
||||
+ "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL,"
|
||||
+ "`sender` VARCHAR(40) NOT NULL"
|
||||
+ ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "plot_settings` ("
|
||||
+ " `plot_plot_id` INT(11) NOT NULL,"
|
||||
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||
+ " `rain` INT(1) DEFAULT 0,"
|
||||
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||
+ " `time` INT(11) DEFAULT '8000',"
|
||||
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||
+ " `merged` INT(11) DEFAULT NULL,"
|
||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||
+ " PRIMARY KEY (`plot_plot_id`)"
|
||||
+ ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix
|
||||
+ "plot_rating` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL)");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster` ("
|
||||
+ "`id` INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
+ "`pos1_x` INT(11) NOT NULL,"
|
||||
+ "`pos1_z` INT(11) NOT NULL,"
|
||||
+ "`pos2_x` INT(11) NOT NULL,"
|
||||
+ "`pos2_z` INT(11) NOT NULL,"
|
||||
+ "`owner` VARCHAR(40) NOT NULL,"
|
||||
+ "`world` VARCHAR(45) NOT NULL,"
|
||||
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP"
|
||||
+ ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL,"
|
||||
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "cluster_settings` ("
|
||||
+ " `cluster_id` INT(11) NOT NULL,"
|
||||
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||
+ " `rain` INT(1) DEFAULT 0,"
|
||||
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||
+ " `time` INT(11) DEFAULT '8000',"
|
||||
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||
+ " `merged` INT(11) DEFAULT NULL,"
|
||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||
+ " PRIMARY KEY (`cluster_id`)"
|
||||
+ ")");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ this.prefix
|
||||
+ "player_meta` ("
|
||||
+ " `meta_id` INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
+ " `uuid` VARCHAR(40) NOT NULL,"
|
||||
+ " `key` VARCHAR(32) NOT NULL,"
|
||||
+ " `value` blob NOT NULL"
|
||||
+ ")");
|
||||
stmt.executeBatch();
|
||||
stmt.clearBatch();
|
||||
}
|
||||
stmt.executeBatch();
|
||||
stmt.clearBatch();
|
||||
stmt.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1390,7 +1396,7 @@ public class SQLManager implements AbstractDB {
|
|||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
return SQLManager.this.connection
|
||||
.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)");
|
||||
.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1779,7 +1785,8 @@ public class SQLManager implements AbstractDB {
|
|||
} else if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cENTRY " + id + " in `plot_denied` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
PS.debug("&cENTRY " + id
|
||||
+ " in `plot_denied` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, this.prefix + "plot_denied", "plot_plot_id");
|
||||
|
@ -1818,12 +1825,12 @@ public class SQLManager implements AbstractDB {
|
|||
String[] flags_string;
|
||||
String myflags = resultSet.getString("flags");
|
||||
if (myflags == null) {
|
||||
flags_string = new String[] {};
|
||||
flags_string = new String[]{};
|
||||
} else {
|
||||
if (!myflags.isEmpty()) {
|
||||
flags_string = myflags.split(",");
|
||||
} else {
|
||||
flags_string = new String[] {};
|
||||
flags_string = new String[]{};
|
||||
}
|
||||
}
|
||||
HashMap<Flag<?>, Object> flags = new HashMap<>();
|
||||
|
@ -1881,7 +1888,7 @@ public class SQLManager implements AbstractDB {
|
|||
PS.debug("&c[WARNING] - Please create the world/s or remove the plots using the purge command");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
PS.debug("&7[WARN] " + "Failed to load plots.");
|
||||
PS.debug("&7[WARN] Failed to load plots.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return newPlots;
|
||||
|
@ -2041,11 +2048,11 @@ public class SQLManager implements AbstractDB {
|
|||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&c[ERROR] " + "FAILED TO PURGE PLOTS!");
|
||||
PS.debug("&c[ERROR] FAILED TO PURGE PLOTS!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
PS.debug("&6[INFO] " + "SUCCESSFULLY PURGED " + uniqueIds.size() + " PLOTS!");
|
||||
PS.debug("&6[INFO] SUCCESSFULLY PURGED " + uniqueIds.size() + " PLOTS!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2057,28 +2064,28 @@ public class SQLManager implements AbstractDB {
|
|||
public void run() {
|
||||
try (PreparedStatement stmt = SQLManager.this.connection
|
||||
.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z` FROM `" + SQLManager.this.prefix + "plot` WHERE `world` = ?")) {
|
||||
stmt.setString(1, area.toString());
|
||||
Set<Integer> ids;
|
||||
try (ResultSet r = stmt.executeQuery()) {
|
||||
ids = new HashSet<>();
|
||||
while (r.next()) {
|
||||
PlotId plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
||||
if (plots.contains(plot_id)) {
|
||||
ids.add(r.getInt("id"));
|
||||
}
|
||||
stmt.setString(1, area.toString());
|
||||
Set<Integer> ids;
|
||||
try (ResultSet r = stmt.executeQuery()) {
|
||||
ids = new HashSet<>();
|
||||
while (r.next()) {
|
||||
PlotId plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
||||
if (plots.contains(plot_id)) {
|
||||
ids.add(r.getInt("id"));
|
||||
}
|
||||
}
|
||||
purgeIds(ids);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&c[ERROR] " + "FAILED TO PURGE AREA '" + area + "'!");
|
||||
}
|
||||
purgeIds(ids);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&c[ERROR] FAILED TO PURGE AREA '" + area + "'!");
|
||||
}
|
||||
for (Iterator<PlotId> iterator = plots.iterator(); iterator.hasNext(); ) {
|
||||
PlotId plotId = iterator.next();
|
||||
iterator.remove();
|
||||
PlotId id = new PlotId(plotId.x, plotId.y);
|
||||
area.removePlot(id);
|
||||
}
|
||||
area.removePlot(id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2345,7 +2352,7 @@ public class SQLManager implements AbstractDB {
|
|||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
PS.debug("&7[WARN] " + "Failed to fetch rating for plot " + plot.getId().toString());
|
||||
PS.debug("&7[WARN] Failed to fetch rating for plot " + plot.getId().toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return map;
|
||||
|
@ -2634,12 +2641,12 @@ public class SQLManager implements AbstractDB {
|
|||
String[] flags_string;
|
||||
String myflags = r.getString("flags");
|
||||
if (myflags == null) {
|
||||
flags_string = new String[] {};
|
||||
flags_string = new String[]{};
|
||||
} else {
|
||||
if (!myflags.isEmpty()) {
|
||||
flags_string = myflags.split(",");
|
||||
} else {
|
||||
flags_string = new String[] {};
|
||||
flags_string = new String[]{};
|
||||
}
|
||||
}
|
||||
HashMap<Flag<?>, Object> flags = new HashMap<>();
|
||||
|
@ -2681,7 +2688,7 @@ public class SQLManager implements AbstractDB {
|
|||
PS.debug("&c[WARNING] - Please create the world/s or remove the clusters using the purge command");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
PS.debug("&7[WARN] " + "Failed to load clusters.");
|
||||
PS.debug("&7[WARN] Failed to load clusters.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return newClusters;
|
||||
|
@ -2808,7 +2815,7 @@ public class SQLManager implements AbstractDB {
|
|||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
return SQLManager.this.connection
|
||||
.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "cluster_settings`(`cluster_id`, `alias`) VALUES(?, ?" + ")");
|
||||
.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "cluster_settings`(`cluster_id`, `alias`) VALUES(?, ?)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2908,7 +2915,6 @@ public class SQLManager implements AbstractDB {
|
|||
stmt.executeBatch();
|
||||
stmt.clearBatch();
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
|
@ -3082,7 +3088,7 @@ public class SQLManager implements AbstractDB {
|
|||
}
|
||||
try (PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `"
|
||||
+ SQLManager.this.prefix
|
||||
+ "cluster` SET `world` = ? WHERE `world` = ? AND `pos1_x` <= ? AND `pos1_z` <= ? AND `pos2_x` >= ? AND `pos2_z` >= ?")) {
|
||||
+ "cluster` SET `world` = ? WHERE `world` = ? AND `pos1_x` <= ? AND `pos1_z` <= ? AND `pos2_x` >= ? AND `pos2_z` >= ?")) {
|
||||
stmt.setString(1, newWorld);
|
||||
stmt.setString(2, oldWorld);
|
||||
stmt.setInt(3, max.x);
|
||||
|
|
|
@ -12,9 +12,9 @@ public abstract class StmtMod<T> {
|
|||
public String getCreateMySQL(int size, String query, int params) {
|
||||
StringBuilder statement = new StringBuilder(query);
|
||||
for (int i = 0; i < size - 1; i++) {
|
||||
statement.append("(" + StringMan.repeat(",?", params).substring(1) + "),");
|
||||
statement.append("(").append(StringMan.repeat(",?", params).substring(1)).append("),");
|
||||
}
|
||||
statement.append("(" + StringMan.repeat(",?", params).substring(1) + ")");
|
||||
statement.append("(").append(StringMan.repeat(",?", params).substring(1)).append(")");
|
||||
return statement.toString();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public abstract class StmtMod<T> {
|
|||
StringBuilder statement = new StringBuilder(query);
|
||||
String modParams = StringMan.repeat(",?", params).substring(1);
|
||||
for (int i = 0; i < size - 1; i++) {
|
||||
statement.append("UNION SELECT " + modParams + " ");
|
||||
statement.append("UNION SELECT ").append(modParams).append(" ");
|
||||
}
|
||||
return statement.toString();
|
||||
}
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
/**
|
||||
* Created 2014-09-23 for PlotSquared
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class AbstractFlag<T extends FlagValue> {
|
||||
public final String key;
|
||||
public final T value = null;
|
||||
|
||||
public AbstractFlag(String key) {
|
||||
this(key, new FlagValue.StringValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* AbstractFlag is a parameter used in creating a new Flag<br>
|
||||
* The key must be alphabetical characters and <= 16 characters in length
|
||||
* @param key
|
||||
*/
|
||||
public AbstractFlag(String key, FlagValue<?> value) {
|
||||
this.key = key.toLowerCase();
|
||||
//if (value == null) {
|
||||
// this.value = new FlagValue.StringValue();
|
||||
//} else {
|
||||
// this.value = value;
|
||||
//}
|
||||
}
|
||||
|
||||
public boolean isList() {
|
||||
return this.value instanceof FlagValue.ListValue;
|
||||
}
|
||||
|
||||
public Object parseValueRaw(String value) {
|
||||
try {
|
||||
return this.value.parse(value);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(Object t) {
|
||||
return this.value.toString(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* AbstractFlag key
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.key.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof AbstractFlag)) {
|
||||
return false;
|
||||
}
|
||||
AbstractFlag otherObj = (AbstractFlag) other;
|
||||
return otherObj.key.equals(this.key);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
public class DoubleFlag extends Flag<Double> {
|
||||
|
||||
public DoubleFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override public Double parseValue(String value) {
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return "Flag value must be a number.";
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package com.intellectualcrafters.plot.flag;
|
|||
|
||||
public class Flag<V> {
|
||||
|
||||
private AbstractFlag key;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
|
@ -16,19 +15,6 @@ public class Flag<V> {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AbstractFlag used in creating the flag.
|
||||
*
|
||||
* @return AbstractFlag
|
||||
*/
|
||||
public AbstractFlag getAbstractFlag() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String getValueString() {
|
||||
return this.key.toString(this.name);
|
||||
}
|
||||
|
||||
public String valueToString(Object value) {
|
||||
return null;
|
||||
}
|
||||
|
@ -43,10 +29,10 @@ public class Flag<V> {
|
|||
}
|
||||
|
||||
public String getValueDescription() {
|
||||
return null;
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public final String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.EventUtil;
|
|||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -24,15 +25,14 @@ import java.util.Set;
|
|||
public class FlagManager {
|
||||
|
||||
|
||||
private static final HashSet<? extends Flag<?>>
|
||||
reserved = Sets.newHashSet();//todo MattBDev: Ask Empire what a reserved flag is
|
||||
private static final HashSet<Flag<?>> reserved = Sets.newHashSet(Flags.ANALYSIS, Flags.DONE);
|
||||
|
||||
/**
|
||||
* Reserve a flag so that it cannot be set by players
|
||||
* @param flag
|
||||
*/
|
||||
public static void reserveFlag(String flag) {
|
||||
//reserved.add(flag);
|
||||
public static void reserveFlag(Flag<?> flag) {
|
||||
reserved.add(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,36 +48,21 @@ public class FlagManager {
|
|||
* Get the reserved flags
|
||||
* @return
|
||||
*/
|
||||
public static HashSet<Flag<?>> getReservedFlags() {
|
||||
return (HashSet<Flag<?>>) reserved.clone();
|
||||
public static Set<Flag<?>> getReservedFlags() {
|
||||
return Collections.unmodifiableSet(reserved);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unreserve a flag
|
||||
* @param flag
|
||||
*/
|
||||
public static void unreserveFlag(String flag) {
|
||||
public static void unreserveFlag(Flag<?> flag) {
|
||||
reserved.remove(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an AbstractFlag with PlotSquared
|
||||
*
|
||||
* @param af Flag to register
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
public static boolean addFlag(AbstractFlag af) {
|
||||
//todo MattBDev: Remove this
|
||||
return true;
|
||||
//return addFlag(af, false);
|
||||
}
|
||||
|
||||
public static String toString(HashMap<Flag<?>, Object> flags) {
|
||||
//todo MattBDev: Fix this for flags to work.
|
||||
//noinspection StringBufferReplaceableByString,MismatchedQueryAndUpdateOfStringBuilder
|
||||
StringBuilder flag_string = new StringBuilder();
|
||||
/* int i = 0;
|
||||
int i = 0;
|
||||
Flag<?> flag;
|
||||
for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) {
|
||||
flag = entry.getKey();
|
||||
|
@ -86,7 +71,7 @@ public class FlagManager {
|
|||
}
|
||||
flag_string.append(flag.getName() + ":" + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´"));
|
||||
i++;
|
||||
}*/
|
||||
}
|
||||
return flag_string.toString();
|
||||
}
|
||||
|
||||
|
@ -122,14 +107,14 @@ public class FlagManager {
|
|||
* @param flag
|
||||
* @param value
|
||||
*/
|
||||
public static <V> boolean addPlotFlag(Plot origin, Flag<V> flag, V value) {
|
||||
public static <V> boolean addPlotFlag(Plot origin, Flag<V> flag, Object value) {
|
||||
boolean result = EventUtil.manager.callFlagAdd(flag, origin);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
for (Plot plot : origin.getConnectedPlots()) {
|
||||
plot.getFlags().put(flag, value);
|
||||
plot.reEnter();
|
||||
plot.reEnter(); //TODO fix this so FlagTest will run during compile
|
||||
DBFunc.setFlags(plot, plot.getFlags());
|
||||
}
|
||||
return true;
|
||||
|
@ -246,7 +231,7 @@ public class FlagManager {
|
|||
*/
|
||||
public static List<Flag> getFlags(PlotPlayer player) {
|
||||
List<Flag> returnFlags = new ArrayList<>();
|
||||
for (Flag flag : Flags.flags) {
|
||||
for (Flag flag : Flags.getFlags()) {
|
||||
if (Permissions.hasPermission(player, "plots.set.flag." + flag.getName().toLowerCase())) {
|
||||
returnFlags.add(flag);
|
||||
}
|
||||
|
@ -262,39 +247,20 @@ public class FlagManager {
|
|||
* @return AbstractFlag
|
||||
*/
|
||||
public static Flag<?> getFlag(String string) {
|
||||
for (Flag flag : Flags.flags) {
|
||||
for (Flag flag : Flags.getFlags()) {
|
||||
if (flag.getName().equalsIgnoreCase(string)) {
|
||||
if (isReserved(flag)) {
|
||||
return null;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an AbstractFlag by a string
|
||||
*
|
||||
* @param string Flag Key
|
||||
* @param create If to create the flag if it does not exist
|
||||
*
|
||||
* @return AbstractFlag
|
||||
*/
|
||||
public static Flag getFlag(String string, boolean create) {
|
||||
for (Flag flag : Flags.getFlags()) {
|
||||
if (flag.getName().equalsIgnoreCase(string)) {
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
if (getFlag(string) == null && create) {
|
||||
//return new AbstractFlag(string);
|
||||
}
|
||||
return getFlag(string);
|
||||
}
|
||||
|
||||
public static HashMap<Flag<?>, Object> parseFlags(List<String> flagstrings) {
|
||||
HashMap<Flag<?>, Object> map = new HashMap<>();
|
||||
//todo MattBDev: Fix this
|
||||
/*
|
||||
|
||||
for (String key : flagstrings) {
|
||||
String[] split;
|
||||
if (key.contains(";")) {
|
||||
|
@ -302,15 +268,11 @@ public class FlagManager {
|
|||
} else {
|
||||
split = key.split(":");
|
||||
}
|
||||
Flag flag;
|
||||
if (split.length == 1) {
|
||||
flag = new Flag(getFlag(split[0]), "");
|
||||
} else {
|
||||
flag = new Flag(getFlag(split[0], true), split[1]);
|
||||
}
|
||||
map.put(flag.getKey(), flag);
|
||||
Flag<?> flag = getFlag(split[0]);
|
||||
Object value = flag.parseValue(split[1]);
|
||||
map.put(flag, value);
|
||||
}
|
||||
*/
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,470 +0,0 @@
|
|||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FlagValue<T> {
|
||||
|
||||
public FlagValue() {
|
||||
}
|
||||
|
||||
public String toString(T t) {
|
||||
return t.toString();
|
||||
}
|
||||
|
||||
public abstract T getValue(Object t);
|
||||
|
||||
public abstract T parse(String t);
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
interface ListValue extends Cloneable {
|
||||
|
||||
void add(Object t, String value);
|
||||
|
||||
void remove(Object t, String value);
|
||||
}
|
||||
|
||||
public static class BooleanValue extends FlagValue<Boolean> {
|
||||
|
||||
@Override
|
||||
public Boolean getValue(Object t) {
|
||||
return (Boolean) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean parse(String t) {
|
||||
switch (t.toLowerCase()) {
|
||||
case "1":
|
||||
case "yes":
|
||||
case "allow":
|
||||
case "true":
|
||||
return true;
|
||||
case "0":
|
||||
case "no":
|
||||
case "deny":
|
||||
case "false":
|
||||
return false;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a boolean (true|false)";
|
||||
}
|
||||
}
|
||||
|
||||
public static class IntegerValue extends FlagValue<Integer> {
|
||||
|
||||
@Override
|
||||
public Integer getValue(Object t) {
|
||||
return (Integer) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer parse(String t) {
|
||||
try {
|
||||
return Integer.parseInt(t);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a whole number";
|
||||
}
|
||||
}
|
||||
|
||||
public static class IntervalValue extends FlagValue<Integer[]> {
|
||||
|
||||
@Override
|
||||
public String toString(Integer[] t) {
|
||||
return t[0] + " " + t[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer[] getValue(Object t) {
|
||||
return (Integer[]) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer[] parse(String t) {
|
||||
int seconds;
|
||||
int amount;
|
||||
String[] values = t.split(" ");
|
||||
if (values.length < 2) {
|
||||
seconds = 1;
|
||||
try {
|
||||
amount = Integer.parseInt(values[0]);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
amount = Integer.parseInt(values[0]);
|
||||
seconds = Integer.parseInt(values[1]);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new Integer[]{amount, seconds};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Value(s) must be numeric. /plot set flag <flag> <interval> [amount]";
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnsignedIntegerValue extends FlagValue<Integer> {
|
||||
|
||||
@Override
|
||||
public Integer getValue(Object t) {
|
||||
return (Integer) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer parse(String t) {
|
||||
try {
|
||||
int value = Integer.parseInt(t);
|
||||
if (value < 0) {
|
||||
return null;
|
||||
}
|
||||
return value;
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a positive whole number (includes 0)";
|
||||
}
|
||||
}
|
||||
|
||||
public static class DoubleValue extends FlagValue<Double> {
|
||||
|
||||
@Override
|
||||
public Double getValue(Object t) {
|
||||
return (Double) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double parse(String t) {
|
||||
try {
|
||||
return Double.parseDouble(t);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a number (negative decimals are allowed)";
|
||||
}
|
||||
}
|
||||
|
||||
public static class LongValue extends FlagValue<Long> {
|
||||
|
||||
@Override
|
||||
public Long getValue(Object t) {
|
||||
return (Long) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long parse(String t) {
|
||||
try {
|
||||
return Long.parseLong(t);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a whole number (large numbers allowed)";
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnsignedLongValue extends FlagValue<Long> {
|
||||
|
||||
@Override
|
||||
public Long getValue(Object t) {
|
||||
return (Long) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long parse(String t) {
|
||||
try {
|
||||
long value = Long.parseLong(t);
|
||||
if (value < 0) {
|
||||
return null;
|
||||
}
|
||||
return value;
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a positive whole number (large numbers allowed)";
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnsignedDoubleValue extends FlagValue<Double> {
|
||||
|
||||
@Override
|
||||
public Double getValue(Object t) {
|
||||
return (Double) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double parse(String t) {
|
||||
try {
|
||||
double value = Double.parseDouble(t);
|
||||
if (value < 0) {
|
||||
return null;
|
||||
}
|
||||
return value;
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a positive number (decimals allowed)";
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlotBlockValue extends FlagValue<PlotBlock> {
|
||||
|
||||
@Override
|
||||
public PlotBlock getValue(Object t) {
|
||||
return (PlotBlock) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotBlock parse(String t) {
|
||||
try {
|
||||
String[] split = t.split(":");
|
||||
byte data;
|
||||
if (split.length == 2) {
|
||||
if ("*".equals(split[1])) {
|
||||
data = -1;
|
||||
} else {
|
||||
data = Byte.parseByte(split[1]);
|
||||
}
|
||||
} else {
|
||||
data = -1;
|
||||
}
|
||||
short id = Short.parseShort(split[0]);
|
||||
return new PlotBlock(id, data);
|
||||
} catch (Exception e) {
|
||||
StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(t);
|
||||
if (value == null || value.match > 1) {
|
||||
return null;
|
||||
}
|
||||
return value.best;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a number (negative decimals are allowed)";
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlotBlockListValue extends FlagValue<HashSet<PlotBlock>> implements ListValue {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String toString(HashSet<PlotBlock> t) {
|
||||
return StringMan.join(t, ",");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public HashSet<PlotBlock> getValue(Object t) {
|
||||
return (HashSet<PlotBlock>) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<PlotBlock> parse(String t) {
|
||||
HashSet<PlotBlock> list = new HashSet<>();
|
||||
for (String item : t.split(",")) {
|
||||
PlotBlock block;
|
||||
try {
|
||||
String[] split = item.split(":");
|
||||
byte data;
|
||||
if (split.length == 2) {
|
||||
if ("*".equals(split[1])) {
|
||||
data = -1;
|
||||
} else {
|
||||
data = Byte.parseByte(split[1]);
|
||||
}
|
||||
} else {
|
||||
data = -1;
|
||||
}
|
||||
short id = Short.parseShort(split[0]);
|
||||
block = new PlotBlock(id, data);
|
||||
} catch (Exception e) {
|
||||
StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(t);
|
||||
if (value == null || value.match > 1) {
|
||||
continue;
|
||||
}
|
||||
block = value.best;
|
||||
}
|
||||
list.add(block);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a block list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Object t, String value) {
|
||||
try {
|
||||
((HashSet<PlotBlock>) t).addAll(parse(value));
|
||||
} catch (Exception ignored) {
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Object t, String value) {
|
||||
try {
|
||||
for (PlotBlock item : parse(value)) {
|
||||
((HashSet<PlotBlock>) t).remove(item);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class IntegerListValue extends FlagValue<List<Integer>> implements ListValue {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String toString(List<Integer> t) {
|
||||
return StringMan.join(t, ",");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Integer> getValue(Object t) {
|
||||
return (List<Integer>) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> parse(String t) {
|
||||
String[] split = t.split(",");
|
||||
ArrayList<Integer> numbers = new ArrayList<>();
|
||||
for (String element : split) {
|
||||
numbers.add(Integer.parseInt(element));
|
||||
}
|
||||
return numbers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a integer list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Object t, String value) {
|
||||
try {
|
||||
((List<Integer>) t).addAll(parse(value));
|
||||
} catch (Exception ignored) {
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Object t, String value) {
|
||||
try {
|
||||
for (Integer item : parse(value)) {
|
||||
((List<Integer>) t).remove(item);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class StringListValue extends FlagValue<List<String>> implements ListValue {
|
||||
|
||||
@Override
|
||||
public String toString(final List<String> t) {
|
||||
return StringMan.join(t, ",");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getValue(final Object t) {
|
||||
return (List<String>) t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> parse(final String t) {
|
||||
return new ArrayList<>(Arrays.asList(t.split(",")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be a string list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(final Object t, final String value) {
|
||||
try {
|
||||
((List<String>) t).addAll(parse(value));
|
||||
} catch (final Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(final Object t, final String value) {
|
||||
try {
|
||||
for (final String item : parse(value)) {
|
||||
((List<String>) t).remove(item);
|
||||
}
|
||||
} catch (final Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class StringValue extends FlagValue<String> {
|
||||
|
||||
@Override
|
||||
public String parse(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Flag value must be alphanumeric. Some special characters are allowed.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(Object t) {
|
||||
return t.toString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,14 @@
|
|||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class Flags {
|
||||
|
||||
public static final NumericFlag<Integer> MUSIC = new NumericFlag<>("music");
|
||||
public static final IntegerFlag MUSIC = new IntegerFlag("music");
|
||||
public static final StringFlag DESCRIPTION = new StringFlag("description");
|
||||
public static final IntegerListFlag ANALYSIS = new IntegerListFlag("analysis");
|
||||
public static final StringFlag GREETING = new StringFlag("greeting");
|
||||
|
@ -20,10 +22,9 @@ public class Flags {
|
|||
public static final BooleanFlag NOTIFY_LEAVE = new BooleanFlag("notify-leave");
|
||||
public static final BooleanFlag TITLES = new BooleanFlag("titles");
|
||||
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
|
||||
public static final NumericFlag<Long> TIME = new NumericFlag<>("time");
|
||||
public static final LongFlag TIME = new LongFlag("time");
|
||||
public static final PlotWeatherFlag WEATHER = new PlotWeatherFlag("weather");
|
||||
public static final Flag<Object> KEEP = new Flag<>("keep");
|
||||
public static final NumericFlag<Double> PRICE = new NumericFlag<>("price");
|
||||
public static final DoubleFlag PRICE = new DoubleFlag("price");
|
||||
public static final BooleanFlag EXPLOSION = new BooleanFlag("explosion");
|
||||
public static final BooleanFlag GRASS_GROW = new BooleanFlag("grass-grow");
|
||||
public static final BooleanFlag VINE_GROW = new BooleanFlag("vine-grow");
|
||||
|
@ -65,20 +66,46 @@ public class Flags {
|
|||
public static final BooleanFlag PVP = new BooleanFlag("pvp");
|
||||
public static final BooleanFlag PVE = new BooleanFlag("pve");
|
||||
public static final BooleanFlag NO_WORLDEDIT = new BooleanFlag("no-worldedit");
|
||||
public static final NumericFlag<Integer> MISC_CAP = new NumericFlag<>("misc-cap");
|
||||
public static final NumericFlag<Integer> ENTITY_CAP = new NumericFlag<>("entity-cap");
|
||||
public static final NumericFlag<Integer> MOB_CAP = new NumericFlag<>("mob-cap");
|
||||
public static final NumericFlag<Integer> ANIMAL_CAP = new NumericFlag<>("animal-cap");
|
||||
public static final NumericFlag<Integer> HOSTILE_CAP = new NumericFlag<>("hostile-cap");
|
||||
public static final NumericFlag<Integer> VEHICLE_CAP = new NumericFlag<>("vehicle-cap");
|
||||
static final HashSet<? extends Flag<?>> flags = Sets.newHashSet(MUSIC, ANIMAL_CAP, HOSTILE_CAP, PVP, PVE, NO_WORLDEDIT);
|
||||
public static final IntegerFlag MISC_CAP = new IntegerFlag("misc-cap");
|
||||
public static final IntegerFlag ENTITY_CAP = new IntegerFlag("entity-cap");
|
||||
public static final IntegerFlag MOB_CAP = new IntegerFlag("mob-cap");
|
||||
public static final IntegerFlag ANIMAL_CAP = new IntegerFlag("animal-cap");
|
||||
public static final IntegerFlag HOSTILE_CAP = new IntegerFlag("hostile-cap");
|
||||
public static final IntegerFlag VEHICLE_CAP = new IntegerFlag("vehicle-cap");
|
||||
public static final Flag<?> KEEP = new Flag("keep") {
|
||||
@Override public Object parseValue(String value) {
|
||||
if (MathMan.isInteger(value)) {
|
||||
return Long.parseLong(value);
|
||||
}
|
||||
switch (value.toLowerCase()) {
|
||||
case "true":
|
||||
return true;
|
||||
case "false":
|
||||
return false;
|
||||
default:
|
||||
return MainUtil.timeToSec(value) * 1000 + System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
};
|
||||
private static final HashSet<Flag<?>> flags = Sets.newHashSet(MUSIC, DESCRIPTION, ANALYSIS, GREETING, FAREWELL, FEED, HEAL,
|
||||
GAMEMODE,
|
||||
DONE,
|
||||
REDSTONE,
|
||||
FLY, NOTIFY_LEAVE, NOTIFY_ENTER, TIME, WEATHER, KEEP, PRICE, EXPLOSION, GRASS_GROW, VINE_GROW, MYCEL_GROW, DISABLE_PHYSICS, SNOW_MELT,
|
||||
ICE_MELT,
|
||||
FIRE_SPREAD, BLOCK_BURN, BLOCK_IGNITION, SOIL_DRY, BLOCKED_CMDS, USE, BREAK, PLACE, DEVICE_INTERACT, VEHICLE_BREAK, VEHICLE_PLACE,
|
||||
VEHICLE_USE,
|
||||
HANGING_BREAK, HANGING_PLACE, HANGING_INTERACT, MISC_PLACE, MISC_BREAK, MISC_INTERACT, PLAYER_INTERACT, TAMED_ATTACK, TAMED_INTERACT,
|
||||
ANIMAL_ATTACK, ANIMAL_INTERACT, HOSTILE_ATTACK, HOSTILE_INTERACT, MOB_PLACE, FORCEFIELD, INVINCIBLE, ITEM_DROP, INSTABREAK,
|
||||
DROP_PROTECTION, PVP,
|
||||
PVE, NO_WORLDEDIT, MISC_CAP, ENTITY_CAP, MOB_CAP, ANIMAL_CAP, HOSTILE_CAP, VEHICLE_CAP);
|
||||
|
||||
/**
|
||||
* Get a list of registered AbstractFlag objects
|
||||
*
|
||||
* @return List (AbstractFlag)
|
||||
*/
|
||||
public static HashSet<? extends Flag<?>> getFlags() {
|
||||
public static HashSet<Flag<?>> getFlags() {
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ public class GameModeFlag extends Flag<PlotGameMode> {
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
@Override
|
||||
public String valueToString(Object value) {
|
||||
return ((PlotGameMode) value).getName();
|
||||
}
|
||||
|
||||
|
@ -35,7 +36,8 @@ public class GameModeFlag extends Flag<PlotGameMode> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
@Override
|
||||
public String getValueDescription() {
|
||||
return "Flag value must be a gamemode: 'creative' , 'survival', 'adventure' or 'spectator'";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
public class IntegerFlag extends Flag<Integer> {
|
||||
|
||||
public IntegerFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return "Flag value must be a whole number";
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override public Integer parseValue(String value) {
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
@ -10,14 +13,19 @@ public class IntegerListFlag extends ListFlag<List<Integer>> {
|
|||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return null;
|
||||
return StringMan.join((List<Integer>)value, ",");
|
||||
}
|
||||
|
||||
@Override public List<Integer> parseValue(String value) {
|
||||
return null;
|
||||
String[] split = value.split(",");
|
||||
ArrayList<Integer> numbers = new ArrayList<>();
|
||||
for (String element : split) {
|
||||
numbers.add(Integer.parseInt(element));
|
||||
}
|
||||
return numbers;
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return null;
|
||||
return "Flag value must be a integer list";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ public class IntervalFlag extends Flag<Integer[]> {
|
|||
|
||||
@Override
|
||||
public String valueToString(Object value) {
|
||||
return null;
|
||||
Integer[] value1 = (Integer[]) value;
|
||||
return value1[0] + " " + value1[1];
|
||||
}
|
||||
|
||||
@Override public Integer[] parseValue(String value) {
|
||||
|
|
|
@ -2,16 +2,8 @@ package com.intellectualcrafters.plot.flag;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class ListFlag<V extends Collection> extends Flag<V> {
|
||||
public abstract class ListFlag<V extends Collection<?>> extends Flag<V> {
|
||||
|
||||
/**
|
||||
* Flag object used to store basic information for a Plot. Flags are a
|
||||
* key/value pair. For a flag to be usable by a player, you need to
|
||||
* register it with PlotSquared.
|
||||
*
|
||||
|
||||
* @param name Flag name
|
||||
*/
|
||||
public ListFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
public class LongFlag extends Flag<Long> {
|
||||
|
||||
public LongFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override public Long parseValue(String value) {
|
||||
try {
|
||||
return Long.parseLong(value);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return "Flag value must be a whole number (large numbers allowed)";
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
public class NumericFlag<V extends Number> extends Flag<V> {
|
||||
|
||||
public NumericFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return super.getValueDescription();
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
|
|||
}
|
||||
short id = Short.parseShort(split[0]);
|
||||
block = new PlotBlock(id, data);
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
StringComparison<PlotBlock>.ComparisonResult str = WorldUtil.IMP.getClosestBlock(value);
|
||||
if (str == null || str.match > 1) {
|
||||
continue;
|
||||
|
@ -48,6 +48,6 @@ public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
|
|||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return null;
|
||||
return "Flag value must be a block list";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,29 @@ public class PlotWeatherFlag extends Flag<PlotWeather> {
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return null;
|
||||
@Override
|
||||
public String valueToString(Object value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override public PlotWeather parseValue(String value) {
|
||||
return null;
|
||||
switch (value.toLowerCase()) {
|
||||
case "rain":
|
||||
case "storm":
|
||||
case "on":
|
||||
case "lightning":
|
||||
case "thunder":
|
||||
return PlotWeather.RAIN;
|
||||
case "clear":
|
||||
case "off":
|
||||
case "sun":
|
||||
return PlotWeather.CLEAR;
|
||||
default:
|
||||
return PlotWeather.RESET;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return null;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ public class StringFlag extends Flag<String> {
|
|||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return ((String) value);
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override public String parseValue(String value) {
|
||||
return null;
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return null;
|
||||
return "Flag value must be alphanumeric. Some special characters are allowed.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,26 @@
|
|||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class StringListFlag extends ListFlag<List<String>> {
|
||||
|
||||
/**
|
||||
* Flag object used to store basic information for a Plot. Flags are a
|
||||
* key/value pair. For a flag to be usable by a player, you need to
|
||||
* register it with PlotSquared.
|
||||
*
|
||||
|
||||
* @param name Flag name
|
||||
*/
|
||||
public StringListFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return StringMan.join((List<String>) value, ",");
|
||||
}
|
||||
|
||||
@Override public List<String> parseValue(String value) {
|
||||
return new ArrayList<>(Arrays.asList(value.split(",")));
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return "Flag value must be a string list";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||
@Override
|
||||
public void exportTemplate(PlotArea plotworld) throws IOException {
|
||||
HashSet<FileBytes> files = new HashSet<>(
|
||||
Collections.singletonList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
|
||||
Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotworld))));
|
||||
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
|
||||
String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
|
||||
try {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class BO3 {
|
|||
|
||||
public String getFilename() {
|
||||
if (this.chunk.x == 0 && this.chunk.z == 0) {
|
||||
return this.name + "" + ".bo3";
|
||||
return this.name + ".bo3";
|
||||
} else {
|
||||
return this.name + ("_" + this.chunk.x + "_" + this.chunk.z) + ".bo3";
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "\"plotsquaredlocation\":{" + "\"x\":" + this.x + ",\"y\":" + this.y + ",\"z\":" + this.z + ",\"yaw\":" + this.yaw + ",\"pitch\":"
|
||||
return "\"plotsquaredlocation\":{\"x\":" + this.x + ",\"y\":" + this.y + ",\"z\":" + this.z + ",\"yaw\":" + this.yaw + ",\"pitch\":"
|
||||
+ this.pitch
|
||||
+ ",\"world\":\"" + this.world + "\"}";
|
||||
}
|
||||
|
|
|
@ -943,7 +943,7 @@ public class Plot {
|
|||
* @param value
|
||||
*/
|
||||
public <V> boolean setFlag(Flag<V> flag, Object value) {
|
||||
return FlagManager.addPlotFlag(this, flag, (V) value);
|
||||
return FlagManager.addPlotFlag(this, flag, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -349,6 +349,7 @@ public abstract class PlotArea {
|
|||
}
|
||||
for (Entry<String, Object> stringObjectEntry : options.entrySet()) {
|
||||
if (!config.contains(stringObjectEntry.getKey())) {
|
||||
PS.get().IMP.log(stringObjectEntry.toString());
|
||||
config.set(stringObjectEntry.getKey(), stringObjectEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public abstract class PlotManager {
|
|||
|
||||
public void exportTemplate(PlotArea plotworld) throws IOException {
|
||||
HashSet<FileBytes> files = new HashSet<>(
|
||||
Collections.singletonList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
|
||||
Collections.singletonList(new FileBytes("templates/tmp-data.yml", Template.getBytes(plotworld))));
|
||||
Template.zipAll(plotworld.worldname, files);
|
||||
}
|
||||
|
||||
|
|
|
@ -123,11 +123,11 @@ public class PlotSettings {
|
|||
}
|
||||
|
||||
public String getJoinMessage(PlotArea area) {
|
||||
Flag greeting = Flags.GREETING;
|
||||
if (greeting != null) {
|
||||
return greeting.getValueString();
|
||||
if (flags.containsKey(Flags.GREETING)) {
|
||||
return (String) flags.get(Flags.GREETING);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,11 +137,11 @@ public class PlotSettings {
|
|||
* @return Farewell flag
|
||||
*/
|
||||
public String getLeaveMessage(PlotArea plotArea) {
|
||||
Flag farewell = Flags.FAREWELL;
|
||||
if (farewell != null) {
|
||||
return farewell.getValueString();
|
||||
if (flags.containsKey(Flags.FAREWELL)) {
|
||||
return (String) flags.get(Flags.FAREWELL);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public Optional<ArrayList<PlotComment>> getComments(String inbox) {
|
||||
|
|
|
@ -264,7 +264,7 @@ public class ExpireManager {
|
|||
if (!plot.hasOwner() || Objects.equals(DBFunc.everyone, plot.owner) || UUIDHandler.getPlayer(plot.owner) != null || plot.getRunning() > 0) {
|
||||
return false;
|
||||
}
|
||||
Optional<Object> keep = plot.getFlag(Flags.KEEP);
|
||||
Optional<?> keep = plot.getFlag(Flags.KEEP);
|
||||
if (keep.isPresent()) {
|
||||
Object value = keep.get();
|
||||
if (value instanceof Boolean) {
|
||||
|
|
|
@ -709,7 +709,7 @@ public class MainUtil {
|
|||
String expires = C.UNKNOWN.s();
|
||||
if (Settings.AUTO_CLEAR) {
|
||||
if (plot.hasOwner()) {
|
||||
Optional<Object> keep = plot.getFlag(Flags.KEEP);
|
||||
Optional<?> keep = plot.getFlag(Flags.KEEP);
|
||||
if (keep.isPresent()) {
|
||||
Object value = keep.get();
|
||||
if (value instanceof Boolean) {
|
||||
|
|
|
@ -6,22 +6,26 @@ import static org.junit.Assert.assertThat;
|
|||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.database.AbstractDBTEst;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.EventUtilTest;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.core.IsCollectionContaining;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FlagTest {
|
||||
|
||||
private PlotBlock testBlock;
|
||||
private Object testBlock;
|
||||
private Flag<? extends Collection<?>> use = Flags.USE;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
@ -33,20 +37,19 @@ public class FlagTest {
|
|||
public void flagTest() throws Exception {
|
||||
Plot plot = new Plot(null, new PlotId(0, 0));
|
||||
plot.owner = UUID.fromString("84499644-ad72-454b-a19d-f28c28df382b");
|
||||
Flags.USE.parseValue("33,33:1,6:4");
|
||||
plot.setFlag(Flags.USE, Flags.USE.parseValue("33,33:1,6:4"));
|
||||
Optional<HashSet<PlotBlock>> flag = plot.getFlag(Flags.USE);
|
||||
//plot.setFlag(use, use.parseValue("33,33:1,6:4")); //TODO fix this so FlagTest will run during compile
|
||||
Optional<? extends Collection> flag = plot.getFlag(use);
|
||||
if (flag.isPresent()) {
|
||||
System.out.println(Flags.USE.valueToString(flag.get()));
|
||||
testBlock = new PlotBlock((short) 1, (byte) 0);
|
||||
flag.get().add(testBlock);
|
||||
}
|
||||
testBlock = new PlotBlock((short) 1, (byte) 0);
|
||||
flag.get().add(testBlock);
|
||||
if (flag.isPresent()) {
|
||||
System.out.println(Flags.USE.valueToString(flag.get()));
|
||||
}
|
||||
Optional<HashSet<PlotBlock>> flag2 = plot.getFlag(Flags.USE);
|
||||
if (flag2.isPresent()) {
|
||||
assertThat(flag2.get(), IsCollectionContaining.hasItem(testBlock));
|
||||
assertThat(flag2.get(), (Matcher<? super HashSet<PlotBlock>>) IsCollectionContaining.hasItem(testBlock));
|
||||
}
|
||||
if (flag.isPresent() && flag2.isPresent()) {
|
||||
assertEquals(flag.get(), flag2.get());
|
||||
|
|
|
@ -58,11 +58,11 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||
PS.get().config.set("worlds." + world + "." + step.getConstant(), step.getValue());
|
||||
}
|
||||
if (object.type != 0) {
|
||||
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
||||
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
||||
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
||||
PS.get().config.set("worlds." + world + ".generator.type", object.type);
|
||||
PS.get().config.set("worlds." + world + ".generator.terrain", object.terrain);
|
||||
PS.get().config.set("worlds." + world + ".generator.plugin", object.plotManager);
|
||||
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
||||
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||
PS.get().config.set("worlds." + world + ".generator.init", object.setupGenerator);
|
||||
}
|
||||
final PlotGenerator<WorldGenerator> gen = (PlotGenerator<WorldGenerator>) generators.get(object.setupGenerator);
|
||||
if ((gen != null) && (gen.generator instanceof SpongePlotGenerator)) {
|
||||
|
|
|
@ -115,11 +115,11 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
||||
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
||||
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
||||
PS.get().config.set("worlds." + world + ".generator.type", object.type);
|
||||
PS.get().config.set("worlds." + world + ".generator.terrain", object.terrain);
|
||||
PS.get().config.set("worlds." + world + ".generator.plugin", object.plotManager);
|
||||
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||
PS.get().config.set("worlds." + world + ".generator.init", object.setupGenerator);
|
||||
}
|
||||
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||
if (gen != null && gen.isFull()) {
|
||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Thu Mar 31 16:37:43 EDT 2016
|
||||
#Wed Apr 20 16:28:49 EDT 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip
|
||||
|
|
Loading…
Reference in a new issue