From cd9c80a65fef0d20e88391a6ee6e6ceedf5f8fe7 Mon Sep 17 00:00:00 2001 From: gravityfox Date: Fri, 27 Nov 2015 13:04:08 -0800 Subject: [PATCH] Update a few things. Bump to 0.8.7 --- build.gradle | 2 +- .../net/gravityfox/foxguard/FoxGuardMain.java | 7 ++-- .../foxguard/commands/CommandAdd.java | 10 +++--- .../foxguard/commands/CommandCreate.java | 4 +-- .../foxguard/commands/CommandDelete.java | 4 +-- .../foxguard/commands/CommandDetail.java | 4 +-- .../foxguard/commands/CommandFlush.java | 6 ++-- .../foxguard/commands/CommandList.java | 10 +++--- .../foxguard/commands/CommandModify.java | 4 +-- .../foxguard/commands/CommandSubtract.java | 6 ++-- .../foxguard/flagsets/PassiveFlagSet.java | 5 +-- .../foxguard/flagsets/SimpleFlagSet.java | 22 ++++++------- .../net/gravityfox/foxguard/util/Aliases.java | 33 +++++++++---------- .../foxguard/util/CallbackHashMap.java | 5 ++- 14 files changed, 61 insertions(+), 61 deletions(-) diff --git a/build.gradle b/build.gradle index b821395..5627f7d 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ import java.nio.file.Files import java.nio.file.StandardCopyOption group 'tk.elektrofuchse.fox.foxguard' -version '0.8.6-SNAPSHOT' +version '0.8.7-SNAPSHOT' apply plugin: 'java' diff --git a/src/main/java/net/gravityfox/foxguard/FoxGuardMain.java b/src/main/java/net/gravityfox/foxguard/FoxGuardMain.java index a3eb5c7..0c0ec09 100644 --- a/src/main/java/net/gravityfox/foxguard/FoxGuardMain.java +++ b/src/main/java/net/gravityfox/foxguard/FoxGuardMain.java @@ -56,7 +56,7 @@ import java.io.File; import java.sql.SQLException; -import static net.gravityfox.foxguard.util.Aliases.flagSetsAliases; +import static net.gravityfox.foxguard.util.Aliases.FLAG_SETS_ALIASES; /** * Created by Fox on 8/16/2015. @@ -65,7 +65,7 @@ @Plugin(id = "foxguard", name = "FoxGuard", version = FoxGuardMain.PLUGIN_VERSION) public class FoxGuardMain { - public static final String PLUGIN_VERSION = "0.8.6"; + public static final String PLUGIN_VERSION = "0.8.7"; private static FoxGuardMain instance; @@ -181,7 +181,7 @@ private void registerCommands() { fgFlagSetDispatcher.register(new CommandPriority(), "priority", "prio", "level", "rank"); - fgDispatcher.register(fgFlagSetDispatcher, flagSetsAliases); + fgDispatcher.register(fgFlagSetDispatcher, FLAG_SETS_ALIASES); game.getCommandDispatcher().register(this, fgDispatcher, "foxguard", "foxg", "fguard", "fg"); } @@ -195,6 +195,7 @@ private void registerListeners() { private void configurePermissions() { getPermissionService().getDefaultData().setPermission(SubjectData.GLOBAL_CONTEXT, "foxguard.command.info", Tristate.TRUE); + getPermissionService().getDefaultData().setPermission(SubjectData.GLOBAL_CONTEXT, "foxguard.override", Tristate.FALSE); } public Logger getLogger() { diff --git a/src/main/java/net/gravityfox/foxguard/commands/CommandAdd.java b/src/main/java/net/gravityfox/foxguard/commands/CommandAdd.java index 1608eb6..536ac5c 100644 --- a/src/main/java/net/gravityfox/foxguard/commands/CommandAdd.java +++ b/src/main/java/net/gravityfox/foxguard/commands/CommandAdd.java @@ -70,7 +70,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm .append(getUsage(source)) .build()); return CommandResult.empty(); - } else if (isAlias(regionsAliases, args[0])) { + } else if (isAlias(REGIONS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); int flag = 0; Optional optWorld = FGHelper.parseWorld(args[1], FoxGuardMain.getInstance().getGame().getServer()); @@ -90,7 +90,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm source.sendMessage(Texts.of(TextColors.GREEN, "Successfully added Region to your state buffer!")); return CommandResult.success(); - } else if (isAlias(flagSetsAliases, args[0])) { + } else if (isAlias(FLAG_SETS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); IFlagSet flagSet = FGManager.getInstance().getFlagSet(args[1]); if (flagSet == null) @@ -101,7 +101,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm source.sendMessage(Texts.of(TextColors.GREEN, "Successfully added FlagSet to your state buffer!")); return CommandResult.success(); - } else if (isAlias(positionsAliases, args[0])) { + } else if (isAlias(POSITIONS_ALIASES, args[0])) { int x, y, z; Vector3i pPos = player.getLocation().getBlockPosition(); if (args.length == 1) { @@ -162,7 +162,7 @@ public Optional getHelp(CommandSource source) { @Override public Text getUsage(CommandSource source) { if (source instanceof Player) - return Texts.of("detail ] | flagset> "); - else return Texts.of("detail | flagset> "); + return Texts.of("add ] | flagset> "); + else return Texts.of("add | flagset> "); } } diff --git a/src/main/java/net/gravityfox/foxguard/commands/CommandCreate.java b/src/main/java/net/gravityfox/foxguard/commands/CommandCreate.java index 6beeb68..8e95a75 100644 --- a/src/main/java/net/gravityfox/foxguard/commands/CommandCreate.java +++ b/src/main/java/net/gravityfox/foxguard/commands/CommandCreate.java @@ -72,7 +72,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm .build()); return CommandResult.empty(); //---------------------------------------------------------------------------------------------------------------------- - } else if (isAlias(regionsAliases, args[0])) { + } else if (isAlias(REGIONS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); int flag = 0; Optional optWorld = FGHelper.parseWorld(args[1], FoxGuardMain.getInstance().getGame().getServer()); @@ -103,7 +103,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm player.sendMessage(Texts.of(TextColors.GREEN, "Region created successfully")); return CommandResult.success(); //---------------------------------------------------------------------------------------------------------------------- - } else if (isAlias(flagSetsAliases, args[0])) { + } else if (isAlias(FLAG_SETS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); if (args[1].matches("^.*[^0-9a-zA-Z_$].*$")) throw new ArgumentParseException(Texts.of("Name must be alphanumeric!"), args[1], 1); diff --git a/src/main/java/net/gravityfox/foxguard/commands/CommandDelete.java b/src/main/java/net/gravityfox/foxguard/commands/CommandDelete.java index 49db3a3..284226e 100644 --- a/src/main/java/net/gravityfox/foxguard/commands/CommandDelete.java +++ b/src/main/java/net/gravityfox/foxguard/commands/CommandDelete.java @@ -70,7 +70,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm .append(getUsage(source)) .build()); return CommandResult.empty(); - } else if (isAlias(regionsAliases, args[0])) { + } else if (isAlias(REGIONS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); int flag = 0; Optional optWorld = FGHelper.parseWorld(args[1], FoxGuardMain.getInstance().getGame().getServer()); @@ -88,7 +88,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm throw new ArgumentParseException(Texts.of("No Region exists with that name!"), args[1 + flag], 1 + flag); player.sendMessage(Texts.of(TextColors.GREEN, "Region deleted successfully!")); - } else if (isAlias(flagSetsAliases, args[0])) { + } else if (isAlias(FLAG_SETS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); if (args[1].equalsIgnoreCase(GlobalFlagSet.NAME)) throw new CommandException(Texts.of("You may not delete the global FlagSet!")); diff --git a/src/main/java/net/gravityfox/foxguard/commands/CommandDetail.java b/src/main/java/net/gravityfox/foxguard/commands/CommandDetail.java index 4c42772..25a4279 100644 --- a/src/main/java/net/gravityfox/foxguard/commands/CommandDetail.java +++ b/src/main/java/net/gravityfox/foxguard/commands/CommandDetail.java @@ -71,7 +71,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm .append(getUsage(source)) .build()); return CommandResult.empty(); - } else if (isAlias(regionsAliases, args[0])) { + } else if (isAlias(REGIONS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); int flag = 0; Optional optWorld = FGHelper.parseWorld(args[1], FoxGuardMain.getInstance().getGame().getServer()); @@ -100,7 +100,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm "\n" + flagSet.getShortTypeName() + " : " + flagSet.getName()))); player.sendMessage(builder.build()); - } else if (isAlias(flagSetsAliases, args[0])) { + } else if (isAlias(FLAG_SETS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); IFlagSet flagSet = FGManager.getInstance().getFlagSet(args[1]); diff --git a/src/main/java/net/gravityfox/foxguard/commands/CommandFlush.java b/src/main/java/net/gravityfox/foxguard/commands/CommandFlush.java index 4b9bfb6..9398384 100644 --- a/src/main/java/net/gravityfox/foxguard/commands/CommandFlush.java +++ b/src/main/java/net/gravityfox/foxguard/commands/CommandFlush.java @@ -71,9 +71,9 @@ public CommandResult process(CommandSource source, String arguments) throws Comm } public InternalCommandState.StateField getType(String input) { - if (contains(regionsAliases, input)) return InternalCommandState.StateField.REGIONS; - else if (contains(flagSetsAliases, input)) return InternalCommandState.StateField.FLAGSETS; - else if (contains(positionsAliases, input)) return InternalCommandState.StateField.POSITIONS; + if (contains(REGIONS_ALIASES, input)) return InternalCommandState.StateField.REGIONS; + else if (contains(FLAG_SETS_ALIASES, input)) return InternalCommandState.StateField.FLAGSETS; + else if (contains(POSITIONS_ALIASES, input)) return InternalCommandState.StateField.POSITIONS; else return null; } diff --git a/src/main/java/net/gravityfox/foxguard/commands/CommandList.java b/src/main/java/net/gravityfox/foxguard/commands/CommandList.java index f3cd79e..04f9f94 100644 --- a/src/main/java/net/gravityfox/foxguard/commands/CommandList.java +++ b/src/main/java/net/gravityfox/foxguard/commands/CommandList.java @@ -46,8 +46,8 @@ import java.util.ListIterator; import java.util.Optional; -import static net.gravityfox.foxguard.util.Aliases.flagSetsAliases; -import static net.gravityfox.foxguard.util.Aliases.regionsAliases; +import static net.gravityfox.foxguard.util.Aliases.FLAG_SETS_ALIASES; +import static net.gravityfox.foxguard.util.Aliases.REGIONS_ALIASES; /** * Created by Fox on 8/18/2015. @@ -73,7 +73,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm .append(getUsage(source)) .build()); return CommandResult.empty(); - } else if (contains(regionsAliases, args[0])) { + } else if (contains(REGIONS_ALIASES, args[0])) { List regionList = new LinkedList<>(); boolean allFlag = true; int worldOffset = 0; @@ -104,7 +104,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm if (regionListIterator.hasNext()) output.append(Texts.of("\n")); } source.sendMessage(output.build()); - } else if (contains(flagSetsAliases, args[0])) { + } else if (contains(FLAG_SETS_ALIASES, args[0])) { List flagSetList = FGManager.getInstance().getFlagSetsListCopy(); /*try { @@ -166,6 +166,6 @@ public Optional getHelp(CommandSource source) { @Override public Text getUsage(CommandSource source) { - return Texts.of("list ] | flagsets> [page]"); + return Texts.of("list ] | flagsets>"); } } diff --git a/src/main/java/net/gravityfox/foxguard/commands/CommandModify.java b/src/main/java/net/gravityfox/foxguard/commands/CommandModify.java index 89dacc8..b2a1c35 100644 --- a/src/main/java/net/gravityfox/foxguard/commands/CommandModify.java +++ b/src/main/java/net/gravityfox/foxguard/commands/CommandModify.java @@ -70,7 +70,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm .append(getUsage(source)) .build()); return CommandResult.empty(); - } else if (isAlias(regionsAliases, args[0])) { + } else if (isAlias(REGIONS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); int flag = 0; Optional optWorld = FGHelper.parseWorld(args[1], FoxGuardMain.getInstance().getGame().getServer()); @@ -88,7 +88,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm FGCommandMainDispatcher.getInstance().getStateMap().get(player), player); if (success) source.sendMessage(Texts.of(TextColors.GREEN, "Successfully modified!")); else source.sendMessage(Texts.of(TextColors.RED, "Modification Failed!")); - } else if (isAlias(flagSetsAliases, args[0])) { + } else if (isAlias(FLAG_SETS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); IFlagSet flagSet = FGManager.getInstance().getFlagSet(args[1]); if (flagSet == null) diff --git a/src/main/java/net/gravityfox/foxguard/commands/CommandSubtract.java b/src/main/java/net/gravityfox/foxguard/commands/CommandSubtract.java index f2190f1..0d9efba 100644 --- a/src/main/java/net/gravityfox/foxguard/commands/CommandSubtract.java +++ b/src/main/java/net/gravityfox/foxguard/commands/CommandSubtract.java @@ -69,7 +69,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm .append(getUsage(source)) .build()); return CommandResult.empty(); - } else if (isAlias(regionsAliases, args[0])) { + } else if (isAlias(REGIONS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name!")); int flag = 0; Optional optWorld = FGHelper.parseWorld(args[1], FoxGuardMain.getInstance().getGame().getServer()); @@ -97,7 +97,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm FGCommandMainDispatcher.getInstance().getStateMap().get(player).selectedRegions.remove(region); source.sendMessage(Texts.of(TextColors.GREEN, "Successfully removed Region from your state buffer!")); return CommandResult.success(); - } else if (isAlias(flagSetsAliases, args[0])) { + } else if (isAlias(FLAG_SETS_ALIASES, args[0])) { if (args.length < 2) throw new CommandException(Texts.of("Must specify a name or a number!")); IFlagSet flagSet; try { @@ -116,7 +116,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm FGCommandMainDispatcher.getInstance().getStateMap().get(player).selectedFlagSets.remove(flagSet); source.sendMessage(Texts.of(TextColors.GREEN, "Successfully removed FlagSet from your state buffer!")); return CommandResult.success(); - } else if (isAlias(positionsAliases, args[0])) { + } else if (isAlias(POSITIONS_ALIASES, args[0])) { int index = FGCommandMainDispatcher.getInstance().getStateMap().get(player).positions.size(); if (args.length > 1) { try { diff --git a/src/main/java/net/gravityfox/foxguard/flagsets/PassiveFlagSet.java b/src/main/java/net/gravityfox/foxguard/flagsets/PassiveFlagSet.java index 21f7612..1a6d898 100644 --- a/src/main/java/net/gravityfox/foxguard/flagsets/PassiveFlagSet.java +++ b/src/main/java/net/gravityfox/foxguard/flagsets/PassiveFlagSet.java @@ -73,6 +73,7 @@ public PassiveFlagSet(String name, int priority, CallbackHashMap 0) { - if (isAlias(ownerAliases, args[1])) { + if (isAlias(OWNER_ALIASES, args[1])) { if (args.length > 1) { UserOperations op; if (args[2].equalsIgnoreCase("add")) { @@ -149,7 +150,7 @@ public boolean modify(String arguments, InternalCommandState state, CommandSourc return false; } - } else if (isAlias(setAliases, args[0])) { + } else if (isAlias(SET_ALIASES, args[0])) { if (args.length > 1) { Flags flag = flagFrom(args[1]); if (flag == null) { diff --git a/src/main/java/net/gravityfox/foxguard/flagsets/SimpleFlagSet.java b/src/main/java/net/gravityfox/foxguard/flagsets/SimpleFlagSet.java index 1451e5f..365a7bb 100644 --- a/src/main/java/net/gravityfox/foxguard/flagsets/SimpleFlagSet.java +++ b/src/main/java/net/gravityfox/foxguard/flagsets/SimpleFlagSet.java @@ -83,12 +83,12 @@ public boolean modify(String arguments, InternalCommandState state, CommandSourc String[] args = {}; if (!arguments.isEmpty()) args = arguments.split(" +"); if (args.length > 0) { - if (isAlias(groupsAliases, args[0])) { + if (isAlias(GROUPS_ALIASES, args[0])) { if (args.length > 1) { List list; - if (isAlias(ownerAliases, args[1])) { + if (isAlias(OWNER_ALIASES, args[1])) { list = this.ownerList; - } else if (isAlias(memberAliases, args[1])) { + } else if (isAlias(MEMBER_ALIASES, args[1])) { list = this.memberList; } else { source.sendMessage(Texts.of(TextColors.RED, "Not a valid group!")); @@ -157,26 +157,26 @@ public boolean modify(String arguments, InternalCommandState state, CommandSourc source.sendMessage(Texts.of(TextColors.RED, "Must specify a group!")); return false; } - } else if (isAlias(permissionAliases, args[0])) { + } else if (isAlias(PERMISSION_ALIASES, args[0])) { return true; - } else if (isAlias(passiveAliases, args[0])) { + } else if (isAlias(PASSIVE_ALIASES, args[0])) { if (args.length > 1) { - if (isAlias(trueAliases, args[1])) { + if (isAlias(TRUE_ALIASES, args[1])) { this.passiveOption = PassiveOptions.ALLOW; return true; - } else if (isAlias(falseAliases, args[1])) { + } else if (isAlias(FALSE_ALIASES, args[1])) { this.passiveOption = PassiveOptions.DENY; return true; - } else if (isAlias(passthroughAliases, args[1])) { + } else if (isAlias(PASSTHROUGH_ALIASES, args[1])) { this.passiveOption = PassiveOptions.PASSTHROUGH; return true; - } else if (isAlias(ownerAliases, args[1])) { + } else if (isAlias(OWNER_ALIASES, args[1])) { this.passiveOption = PassiveOptions.OWNER; return true; - } else if (isAlias(memberAliases, args[1])) { + } else if (isAlias(MEMBER_ALIASES, args[1])) { this.passiveOption = PassiveOptions.MEMBER; return true; - } else if (isAlias(defaultAliases, args[1])) { + } else if (isAlias(DEFAULT_ALIASES, args[1])) { this.passiveOption = PassiveOptions.DEFAULT; return true; } else { diff --git a/src/main/java/net/gravityfox/foxguard/util/Aliases.java b/src/main/java/net/gravityfox/foxguard/util/Aliases.java index fe51aff..b555d66 100644 --- a/src/main/java/net/gravityfox/foxguard/util/Aliases.java +++ b/src/main/java/net/gravityfox/foxguard/util/Aliases.java @@ -33,21 +33,20 @@ */ public class Aliases { - public static final String[] regionsAliases = {"regions", "region", "reg", "r"}; - public static final String[] flagSetsAliases = {"flagsets", "flagset", "flags", "flag", "f"}; - public static final String[] positionsAliases = {"positions", "position", "points", "point", "locations", "location", "pos", "loc", "locs", "p"}; - public static final String[] ownerAliases = {"owners", "owner", "master", "masters", "creator", "creators", + public static final String[] REGIONS_ALIASES = {"regions", "region", "reg", "r"}; + public static final String[] FLAG_SETS_ALIASES = {"flagsets", "flagset", "flags", "flag", "f"}; + public static final String[] POSITIONS_ALIASES = {"positions", "position", "points", "point", "locations", "location", "pos", "loc", "locs", "p"}; + public static final String[] OWNER_ALIASES = {"owners", "owner", "master", "masters", "creator", "creators", "admin", "admins", "administrator", "administrators", "mod", "mods"}; - public static final String[] permissionAliases = {"permissions", "permission", "perms", "perm", "flags", "flag"}; - public static final String[] passiveAliases = {"passive", "causeless", "userless", "environment"}; - public static final String[] memberAliases = {"member", "members", "user", "users", "player", "players"}; - public static final String[] defaultAliases = {"default", "nonmember", "nonmembers", "everyone", "other"}; - public static final String[] groupsAliases = {"group", "groups"}; - public static final String[] activeflagsAliases = {"activeflags", "active"}; - public static final String[] trueAliases = {"true", "t", "allow", "a"}; - public static final String[] falseAliases = {"false", "f", "deny", "d"}; - public static final String[] passthroughAliases = {"passthrough", "pass", "p", "undefined", "undef", "un", "u"}; - public static final String[] setAliases = {"set", "flag", "rule"}; + public static final String[] PERMISSION_ALIASES = {"permissions", "permission", "perms", "perm", "flags", "flag"}; + public static final String[] PASSIVE_ALIASES = {"passive", "causeless", "userless", "environment"}; + public static final String[] MEMBER_ALIASES = {"member", "members", "user", "users", "player", "players"}; + public static final String[] DEFAULT_ALIASES = {"default", "nonmember", "nonmembers", "everyone", "other"}; + public static final String[] GROUPS_ALIASES = {"group", "groups"}; + public static final String[] TRUE_ALIASES = {"true", "t", "allow", "a"}; + public static final String[] FALSE_ALIASES = {"false", "f", "deny", "d"}; + public static final String[] PASSTHROUGH_ALIASES = {"passthrough", "pass", "p", "undefined", "undef", "un", "u"}; + public static final String[] SET_ALIASES = {"set", "flag", "rule"}; public static boolean isAlias(String[] aliases, String input) { for (String alias : aliases) { @@ -57,11 +56,11 @@ public static boolean isAlias(String[] aliases, String input) { } public static Tristate tristateFrom(String name) { - if (isAlias(trueAliases, name)) { + if (isAlias(TRUE_ALIASES, name)) { return Tristate.TRUE; - } else if (isAlias(falseAliases, name)) { + } else if (isAlias(FALSE_ALIASES, name)) { return Tristate.FALSE; - } else if (isAlias(passthroughAliases, name)) { + } else if (isAlias(PASSTHROUGH_ALIASES, name)) { return Tristate.UNDEFINED; } else { return null; diff --git a/src/main/java/net/gravityfox/foxguard/util/CallbackHashMap.java b/src/main/java/net/gravityfox/foxguard/util/CallbackHashMap.java index 27c7dc5..9a47a93 100644 --- a/src/main/java/net/gravityfox/foxguard/util/CallbackHashMap.java +++ b/src/main/java/net/gravityfox/foxguard/util/CallbackHashMap.java @@ -42,9 +42,8 @@ public CallbackHashMap(BiFunction, V> callback) { @Override public V get(Object key) { - V value = super.get(key); - if (value != null) { - return value; + if(containsKey(key)){ + return super.get(key); } else { return callback.apply(key, this); }