This commit is contained in:
MattBDev 2016-05-10 13:41:59 -04:00
parent e63b436edd
commit 3be0f74498
4 changed files with 47 additions and 30 deletions

View File

@ -733,17 +733,13 @@ public class SQLManager implements AbstractDB {
e.printStackTrace(); e.printStackTrace();
PS.debug("&cERROR 2: | " + objList.get(0).getClass().getCanonicalName()); PS.debug("&cERROR 2: | " + objList.get(0).getClass().getCanonicalName());
PS.debug("&6[WARN] Could not bulk save!"); PS.debug("&6[WARN] Could not bulk save!");
try { try (PreparedStatement preparedStmt = this.connection.prepareStatement(mod.getCreateSQL())) {
String nonBulk = mod.getCreateSQL(); for (T obj : objList) {
try (PreparedStatement preparedStmt = this.connection.prepareStatement(nonBulk)) { mod.setSQL(preparedStmt, obj);
for (T obj : objList) { preparedStmt.addBatch();
mod.setSQL(preparedStmt, obj);
preparedStmt.addBatch();
}
PS.debug("&aBatch 3");
preparedStmt.executeBatch();
preparedStmt.close();
} }
PS.debug("&aBatch 3");
preparedStmt.executeBatch();
} catch (SQLException e3) { } catch (SQLException e3) {
e3.printStackTrace(); e3.printStackTrace();
PS.debug("&c[ERROR] Failed to save all!"); PS.debug("&c[ERROR] Failed to save all!");
@ -1819,9 +1815,13 @@ public class SQLManager implements AbstractDB {
if (element.contains(":")) { if (element.contains(":")) {
String[] split = element.split(":"); String[] split = element.split(":");
try { try {
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("\u00B4", ","); String flag_str = split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
Flag<?> flag = FlagManager.getFlag(split[0]); Flag<?> flag = FlagManager.getFlag(split[0],false);
flags.put(flag, flag.parseValue(flag_str)); if (flag == null) {
PS.debug(String.format("No flag found for string value of: %s", split[0]));
} else {
flags.put(flag, flag.parseValue(flag_str));
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
exception = true; exception = true;
@ -1829,8 +1829,12 @@ public class SQLManager implements AbstractDB {
} else { } else {
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ","); element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) { if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
Flag flag = FlagManager.getFlag(element); Flag flag = FlagManager.getFlag(element,false);
flags.put(flag, flag.parseValue("")); if (flag == null) {
PS.debug(String.format("No flag found for string value of: %s", element));
} else {
flags.put(flag, flag.parseValue(""));
}
} else { } else {
PS.debug("INVALID FLAG: " + element); PS.debug("INVALID FLAG: " + element);
} }
@ -2624,27 +2628,25 @@ public class SQLManager implements AbstractDB {
flags_string = myflags.split(","); flags_string = myflags.split(",");
} }
HashMap<Flag<?>, Object> flags = new HashMap<>(); HashMap<Flag<?>, Object> flags = new HashMap<>();
boolean exception = false;
for (String element : flags_string) { for (String element : flags_string) {
if (element.contains(":")) { if (element.contains(":")) {
String[] split = element.split(":"); String[] split = element.split(":");
try { String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ","); Flag flag = FlagManager.getFlag(split[0],false);
Flag flag = FlagManager.getFlag(split[0]); if (flag == null) {
PS.debug(String.format("No flag found for string value of: %s", split[0]));
} else {
flags.put(flag, flag.parseValue(flag_str)); flags.put(flag, flag.parseValue(flag_str));
} catch (Exception e) {
e.printStackTrace();
exception = true;
} }
} else { } else {
Flag flag = FlagManager.getFlag(element); Flag flag = FlagManager.getFlag(element,false);
flags.put(flag, flag.parseValue("")); if (flag == null) {
PS.debug(String.format("No flag found for string value of: %s", element));
} else {
flags.put(flag, flag.parseValue(""));
}
} }
} }
if (exception) {
PS.debug("&cCluster " + id + " had an invalid flag. A fix has been attempted.");
PS.debug("&c" + myflags);
}
cluster.settings.flags = flags; cluster.settings.flags = flags;
} else { } else {
PS.debug("&cCluster " + id + " in cluster_settings does not exist. Please create the cluster or remove this entry."); PS.debug("&cCluster " + id + " in cluster_settings does not exist. Please create the cluster or remove this entry.");

View File

@ -257,6 +257,21 @@ public class FlagManager {
return null; return null;
} }
public static Flag<?> getFlag(String string, boolean ignoreReserved) {
for (Flag flag : Flags.getFlags()) {
if (flag.getName().equalsIgnoreCase(string)) {
if (!ignoreReserved) {
if (isReserved(flag)) {
return null;
}
}
return flag;
}
}
return null;
}
public static Map<Flag<?>, Object> parseFlags(List<String> flagstrings) { public static Map<Flag<?>, Object> parseFlags(List<String> flagstrings) {
HashMap<Flag<?>, Object> map = new HashMap<>(); HashMap<Flag<?>, Object> map = new HashMap<>();

View File

@ -158,7 +158,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
} }
try { try {
setupSchematics(); setupSchematics();
} catch (Exception e) { } catch (Exception ignored) {
PS.debug("&c - road schematics are disabled for this world."); PS.debug("&c - road schematics are disabled for this world.");
} }
} }

View File

@ -74,7 +74,7 @@ public class BlockLoc {
if (this.x == 0 && this.y == 0 && this.z == 0) { if (this.x == 0 && this.y == 0 && this.z == 0) {
return ""; return "";
} }
return this.x + "," + this.y + "," + this.z + "," + this.yaw + "," + this.pitch; return this.x + "," + this.y + ',' + this.z + ',' + this.yaw + ',' + this.pitch;
} }
} }