Fix error if PlotSquared v5 is not installed

This commit is contained in:
Eric 2020-04-26 15:21:18 +02:00
parent 1736196a05
commit a402423b4b
2 changed files with 11 additions and 14 deletions

View File

@ -11,16 +11,15 @@ import de.epiceric.shopchest.ShopChest;
import java.util.Locale; import java.util.Locale;
public class PlotSquaredOldShopFlag { public class PlotSquaredOldShopFlag {
private static boolean registered = false;
public enum Group { public enum Group {
OWNERS, MEMBERS, TRUSTED, EVERYONE, NONE OWNERS, MEMBERS, TRUSTED, EVERYONE, NONE
} }
public static GroupFlag CREATE_SHOP = new GroupFlag("create-shop"); public static final GroupFlag CREATE_SHOP = new GroupFlag("create-shop");
public static GroupFlag USE_SHOP = new GroupFlag("use-shop"); public static final GroupFlag USE_SHOP = new GroupFlag("use-shop");
public static GroupFlag USE_ADMIN_SHOP = new GroupFlag("use-admin-shop"); public static final GroupFlag USE_ADMIN_SHOP = new GroupFlag("use-admin-shop");
private static boolean registered = false;
public static void register(ShopChest plugin) { public static void register(ShopChest plugin) {
if (registered) return; if (registered) return;
@ -42,7 +41,7 @@ public class PlotSquaredOldShopFlag {
*/ */
public static boolean isFlagAllowedOnPlot(Plot plot, GroupFlag flag, Player p) { public static boolean isFlagAllowedOnPlot(Plot plot, GroupFlag flag, Player p) {
if (plot != null && flag != null) { if (plot != null && flag != null) {
Group group = plot.getFlag(flag, PlotSquaredOldShopFlag.Group.NONE); Group group = plot.getFlag(flag, Group.NONE);
ShopChest.getInstance().debug("Flag " + flag.getName() + " is set to " + group); ShopChest.getInstance().debug("Flag " + flag.getName() + " is set to " + group);
switch (group) { switch (group) {
@ -65,7 +64,6 @@ public class PlotSquaredOldShopFlag {
} }
public static class GroupFlag extends Flag<Group> { public static class GroupFlag extends Flag<Group> {
public GroupFlag(String name) { public GroupFlag(String name) {
super(name); super(name);
} }
@ -94,6 +92,7 @@ public class PlotSquaredOldShopFlag {
case "all": case "all":
return Group.EVERYONE; return Group.EVERYONE;
case "deny": case "deny":
case "disallow":
case "false": case "false":
case "no": case "no":
case "0": case "0":
@ -110,5 +109,4 @@ public class PlotSquaredOldShopFlag {
return "Flag value must be a group: 'owner' , 'members', 'trusted', 'everyone' or 'none'"; return "Flag value must be a group: 'owner' , 'members', 'trusted', 'everyone' or 'none'";
} }
} }
} }

View File

@ -26,14 +26,13 @@ public class PlotSquaredShopFlag {
.map(value -> String.valueOf(value).toLowerCase(Locale.ENGLISH)) .map(value -> String.valueOf(value).toLowerCase(Locale.ENGLISH))
.toArray(String[]::new); .toArray(String[]::new);
public static final GroupFlag<?> CREATE_SHOP = new CreateShopFlag(Group.MEMBERS);
public static final GroupFlag<?> USE_SHOP = new UseShopFlag(Group.EVERYONE);
private static boolean registered = false; private static boolean registered = false;
public static final CreateShopFlag CREATE_SHOP = new CreateShopFlag(Group.MEMBERS);
public static final UseShopFlag USE_SHOP = new UseShopFlag(Group.EVERYONE);
public static void register(ShopChest plugin) { public static void register(ShopChest plugin) {
if (registered) if (registered) return;
return;
GlobalFlagContainer.getInstance().addFlag(CREATE_SHOP); GlobalFlagContainer.getInstance().addFlag(CREATE_SHOP);
GlobalFlagContainer.getInstance().addFlag(USE_SHOP); GlobalFlagContainer.getInstance().addFlag(USE_SHOP);