mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-01 21:24:43 +02:00
Fix for sponge
This commit is contained in:
@ -20,9 +20,11 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
public class Flag {
|
||||
public class Flag implements Cloneable {
|
||||
private AbstractFlag key;
|
||||
private Object value;
|
||||
|
||||
@ -122,4 +124,24 @@ public class Flag {
|
||||
public int hashCode() {
|
||||
return key.getKey().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() {
|
||||
try {
|
||||
if (value == null) {
|
||||
return super.clone();
|
||||
}
|
||||
if (value instanceof Cloneable) {
|
||||
Method method = value.getClass().getDeclaredMethod("clone");
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
return new Flag(key, method.invoke(value));
|
||||
}
|
||||
return new Flag(key, key.parseValueRaw(value.toString()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,13 +129,13 @@ public class FlagManager {
|
||||
return null;
|
||||
}
|
||||
if (plotworld.DEFAULT_FLAGS.size() == 0) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
return plotworld.DEFAULT_FLAGS.get(id);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) {
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, key);
|
||||
if (flag == null) {
|
||||
@ -153,6 +153,11 @@ public class FlagManager {
|
||||
* @param plot
|
||||
* @param flag
|
||||
* @return Flag
|
||||
*/
|
||||
public static Flag getPlotFlag(final Plot plot, final String flag) {
|
||||
Flag result = getPlotFlagRaw(plot, flag);
|
||||
return result == null ? null : (Flag) result.clone();
|
||||
}
|
||||
|
||||
public static Flag getPlotFlagRaw(final Plot plot, final String flag) {
|
||||
if (!plot.hasOwner()) {
|
||||
@ -163,7 +168,7 @@ public class FlagManager {
|
||||
|
||||
public static boolean isPlotFlagTrue(final Plot plot, final String strFlag) {
|
||||
if (plot.owner == null) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
final Flag flag = getPlotFlagRaw(plot, strFlag);
|
||||
return !((flag == null) || !((Boolean) flag.getValue()));
|
||||
@ -171,7 +176,7 @@ public class FlagManager {
|
||||
|
||||
public static boolean isPlotFlagFalse(final Plot plot, final String strFlag) {
|
||||
if (plot.owner == null) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
final Flag flag = getPlotFlagRaw(plot, strFlag);
|
||||
if ((flag == null) || ((Boolean) flag.getValue())) {
|
||||
|
@ -286,7 +286,7 @@ public abstract class FlagValue<T> {
|
||||
return "Flag value must be a number (negative decimals are allowed)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface ListValue extends Cloneable {
|
||||
void add(final Object t, final String value);
|
||||
|
||||
|
Reference in New Issue
Block a user