mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Added flag reservation
This commit is contained in:
parent
7c55aa488c
commit
c774e8b375
@ -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.11.23</version>
|
<version>2.11.24</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -718,6 +718,7 @@ public class PlotSquared {
|
|||||||
for (final String flag : intFlags) {
|
for (final String flag : intFlags) {
|
||||||
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue()));
|
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue()));
|
||||||
}
|
}
|
||||||
|
FlagManager.addFlag(new AbstractFlag("modified-blocks", new FlagValue.IntegerValue()), true);
|
||||||
FlagManager.addFlag(new AbstractFlag("disable-physics", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("disable-physics", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
||||||
|
@ -71,6 +71,10 @@ public class FlagCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other");
|
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (args.length > 1 && FlagManager.isReserved(args[1])) {
|
||||||
|
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "info": {
|
case "info": {
|
||||||
if (!Permissions.hasPermission(player, "plots.set.flag")) {
|
if (!Permissions.hasPermission(player, "plots.set.flag")) {
|
||||||
|
@ -106,7 +106,7 @@ public class Set extends SubCommand {
|
|||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
af = new AbstractFlag(args[1].toLowerCase());
|
af = new AbstractFlag(args[1].toLowerCase());
|
||||||
}
|
}
|
||||||
if (!FlagManager.getFlags().contains(af)) {
|
if (!FlagManager.getFlags().contains(af) || FlagManager.isReserved(af.getKey())) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_FLAG);
|
MainUtil.sendMessage(plr, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,44 @@ public class FlagManager {
|
|||||||
// - Plot clear interval
|
// - Plot clear interval
|
||||||
// - Mob cap
|
// - Mob cap
|
||||||
// - customized plot composition
|
// - customized plot composition
|
||||||
|
|
||||||
|
private final static HashSet<String> reserved = new HashSet<>();
|
||||||
|
|
||||||
private final static HashSet<AbstractFlag> flags = new HashSet<>();
|
private final static HashSet<AbstractFlag> flags = new HashSet<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reserve a flag so that it cannot be set by players
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void reserveFlag(String flag) {
|
||||||
|
reserved.add(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get if a flag is reserved
|
||||||
|
* @param flag
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isReserved(String flag) {
|
||||||
|
return reserved.contains(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the reserved flags
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static HashSet<String> getReservedFlags() {
|
||||||
|
return (HashSet<String>) reserved.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unreserve a flag
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void unreserveFlag(String flag) {
|
||||||
|
reserved.remove(flag);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register an AbstractFlag with PlotSquared
|
* Register an AbstractFlag with PlotSquared
|
||||||
*
|
*
|
||||||
@ -60,6 +96,10 @@ public class FlagManager {
|
|||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
public static boolean addFlag(AbstractFlag af) {
|
public static boolean addFlag(AbstractFlag af) {
|
||||||
|
return addFlag(af, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean addFlag(AbstractFlag af, boolean reserved) {
|
||||||
PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af);
|
PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af);
|
||||||
for (PlotWorld plotworld : PlotSquared.getPlotWorldObjects()) {
|
for (PlotWorld plotworld : PlotSquared.getPlotWorldObjects()) {
|
||||||
Flag flag = plotworld.DEFAULT_FLAGS.get(af.getKey());
|
Flag flag = plotworld.DEFAULT_FLAGS.get(af.getKey());
|
||||||
@ -75,7 +115,11 @@ public class FlagManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (getFlag(af.getKey()) == null) && flags.add(af);
|
if ((getFlag(af.getKey()) == null) && flags.add(af)) {
|
||||||
|
if (reserved) reserveFlag(af.getKey());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Flag getSettingFlag(final String world, final PlotSettings settings, final String id) {
|
public static Flag getSettingFlag(final String world, final PlotSettings settings, final String id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user