More lenient default flags

This commit is contained in:
boy0001 2015-03-10 21:48:20 +11:00
parent 073b0b612c
commit e6fc6e070e
3 changed files with 28 additions and 11 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.8.3</version> <version>2.8.4</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -339,8 +339,15 @@ public class FlagManager {
public static Flag[] parseFlags(final List<String> flagstrings) { public static Flag[] parseFlags(final List<String> flagstrings) {
final Flag[] flags = new Flag[flagstrings.size()]; final Flag[] flags = new Flag[flagstrings.size()];
for (int i = 0; i < flagstrings.size(); i++) { for (int i = 0; i < flagstrings.size(); i++) {
final String[] split = flagstrings.get(i).split(";"); final String[] split;
if (flagstrings.get(i).contains(";")) {
split = flagstrings.get(i).split(";");
}
else {
split = flagstrings.get(i).split(":");
}
if (split.length == 1) { if (split.length == 1) {
System.out.print(split[0]);
flags[i] = new Flag(getFlag(split[0], true), ""); flags[i] = new Flag(getFlag(split[0], true), "");
} else { } else {
flags[i] = new Flag(getFlag(split[0], true), split[1]); flags[i] = new Flag(getFlag(split[0], true), split[1]);

View File

@ -20,8 +20,10 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.object; package com.intellectualcrafters.plot.object;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -116,17 +118,25 @@ public abstract class PlotWorld {
this.SELL_PRICE = config.getDouble("economy.prices.sell"); this.SELL_PRICE = config.getDouble("economy.prices.sell");
this.PLOT_CHAT = config.getBoolean("chat.enabled"); this.PLOT_CHAT = config.getBoolean("chat.enabled");
this.WORLD_BORDER = config.getBoolean("world.border"); this.WORLD_BORDER = config.getBoolean("world.border");
final List<String> flags = config.getStringList("flags.default"); List<String> flags = config.getStringList("flags.default");
if (flags == null) { if (flags == null || flags.size() == 0) {
this.DEFAULT_FLAGS = new Flag[] {}; flags = config.getStringList("flags");
} else { if (flags == null || flags.size() == 0) {
try { flags = new ArrayList<String>();
this.DEFAULT_FLAGS = FlagManager.parseFlags(flags); ConfigurationSection section = config.getConfigurationSection("flags");
} catch (final Exception e) { Set<String> keys = section.getKeys(false);
PlotSquared.log("&cInvalid default flags for " + this.worldname + ": " + StringUtils.join(flags, ",")); for (String key : keys) {
this.DEFAULT_FLAGS = new Flag[] {}; flags.add(key + ";" + section.get(key));
}
} }
} }
try {
this.DEFAULT_FLAGS = FlagManager.parseFlags(flags);
} catch (final Exception e) {
e.printStackTrace();
PlotSquared.log("&cInvalid default flags for " + this.worldname + ": " + StringUtils.join(flags, ","));
this.DEFAULT_FLAGS = new Flag[] {};
}
this.PVP = config.getBoolean("event.pvp"); this.PVP = config.getBoolean("event.pvp");
this.PVE = config.getBoolean("event.pve"); this.PVE = config.getBoolean("event.pve");
this.SPAWN_EGGS = config.getBoolean("event.spawn.egg"); this.SPAWN_EGGS = config.getBoolean("event.spawn.egg");