diff --git a/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java index c671b55df..b2a2ea729 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java @@ -95,7 +95,7 @@ public class PlayerSelector for (PermissionGroup requiredGroup : groups) { - if (group.getIdentifier().equals(requiredGroup.getIdentifier())) + if (group == requiredGroup) { return true; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index 64dcdbccf..0fb9ff7b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -82,7 +82,7 @@ public class CoreClient { if (_primary == null) { - _primary = Managers.get(CoreClientManager.class).getPermissionManager().getGroup("player"); + _primary = PermissionGroup.PLAYER; } return _primary; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 428eb3f19..c62e356b9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -8,14 +8,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Objects; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiConsumer; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -115,14 +114,14 @@ public class CoreClientManager extends MiniPlugin private void generatePermissions() { - _perm.setPermission(_perm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(RANK_COMMAND_PERMISSION), true, true); - _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(ADD_RANK_COMMAND_PERMISSION), true, true); - _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(RANK_INFO_COMMAND_PERMISSION), true, true); - _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(LIST_RANKS_COMMAND_PERMISSION), true, true); - _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(REMOVE_RANK_COMMAND_PERMISSION), true, true); - _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(RESET_PLAYER_COMMAND_PERMISSION), true, true); - _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(SET_RANK_COMMAND_PERMISSION), true, true); + _perm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RANK_COMMAND_PERMISSION), true, true); + _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ADD_RANK_COMMAND_PERMISSION), true, true); + _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RANK_INFO_COMMAND_PERMISSION), true, true); + _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(LIST_RANKS_COMMAND_PERMISSION), true, true); + _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(REMOVE_RANK_COMMAND_PERMISSION), true, true); + _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESET_PLAYER_COMMAND_PERMISSION), true, true); + _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_RANK_COMMAND_PERMISSION), true, true); } private void checkForIllegalAccounts() @@ -313,22 +312,22 @@ public class CoreClientManager extends MiniPlugin } CoreClient client = Add(token.Name, uuid); - Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); + Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); - client.setAccountId(result.getLeft().intValue()); + client.setAccountId(result.getLeft()); if (result.getRight().getLeft() == null) { PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank); client.setPrimaryGroup(newGroup); - _repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null); + _repository.setPrimaryGroup(client.getAccountId(), newGroup, null); } else { - client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft())); + client.setPrimaryGroup(result.getRight().getLeft()); } - for (String id : result.getRight().getRight()) + for (PermissionGroup group : result.getRight().getRight()) { - client.addAdditionalGroup(_perm.getGroup(id)); + client.addAdditionalGroup(group); } Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); @@ -388,22 +387,22 @@ public class CoreClientManager extends MiniPlugin token = gson.fromJson(response, ClientToken.class); CoreClient client = Add(playerName, uuid); - Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); + Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); - client.setAccountId(result.getLeft().intValue()); + client.setAccountId(result.getLeft()); if (result.getRight().getLeft() == null) { PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank); client.setPrimaryGroup(newGroup); - _repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null); + _repository.setPrimaryGroup(client.getAccountId(), newGroup, null); } else { - client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft())); + client.setPrimaryGroup(result.getRight().getLeft()); } - for (String id : result.getRight().getRight()) + for (PermissionGroup group : result.getRight().getRight()) { - client.addAdditionalGroup(_perm.getGroup(id)); + client.addAdditionalGroup(group); } // JSON sql response @@ -463,22 +462,22 @@ public class CoreClientManager extends MiniPlugin token = gson.fromJson(response, ClientToken.class); CoreClient client = Add(playerName, uuid); - Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); + Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); - client.setAccountId(result.getLeft().intValue()); + client.setAccountId(result.getLeft()); if (result.getRight().getLeft() == null) { PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank); client.setPrimaryGroup(newGroup); - _repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null); + _repository.setPrimaryGroup(client.getAccountId(), newGroup, null); } else { - client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft())); + client.setPrimaryGroup(result.getRight().getLeft()); } - for (String id : result.getRight().getRight()) + for (PermissionGroup group : result.getRight().getRight()) { - client.addAdditionalGroup(_perm.getGroup(id)); + client.addAdditionalGroup(group); } // JSON sql response @@ -518,19 +517,19 @@ public class CoreClientManager extends MiniPlugin { try { - Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); - client.setAccountId(result.getLeft().intValue()); + Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); + client.setAccountId(result.getLeft()); if (result.getRight().getLeft() == null) { client.setPrimaryGroup(null); } else { - client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft())); + client.setPrimaryGroup(result.getRight().getLeft()); } - for (String id : result.getRight().getRight()) + for (PermissionGroup group : result.getRight().getRight()) { - client.addAdditionalGroup(_perm.getGroup(id)); + client.addAdditionalGroup(group); } } catch (SQLException e) @@ -570,7 +569,7 @@ public class CoreClientManager extends MiniPlugin String mssqlRank = token.Rank; PermissionGroup newGroup = _perm.getGroupFromLegacy(mssqlRank); client.setPrimaryGroup(newGroup); - _repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null); + _repository.setPrimaryGroup(client.getAccountId(), newGroup, null); } TimingManager.start(client.getName() + " Event."); @@ -693,14 +692,14 @@ public class CoreClientManager extends MiniPlugin public void setPrimaryGroup(final int accountId, final PermissionGroup group, Runnable after) { - _repository.setPrimaryGroup(accountId, group.getIdentifier(), after); + _repository.setPrimaryGroup(accountId, group, after); } public void addAdditionalGroup(Player player, final PermissionGroup group, Consumer successCallback) { addAdditionalGroup(Get(player).getAccountId(), group, success -> { - if (success.booleanValue()) + if (success) { Get(player).addAdditionalGroup(group); UtilServer.CallEvent(new OnlineGroupAddEvent(player, group)); @@ -714,15 +713,15 @@ public class CoreClientManager extends MiniPlugin public void addAdditionalGroup(final int accountId, final PermissionGroup group, Consumer successCallback) { - _repository.addAdditionalGroup(accountId, group.getIdentifier(), success -> + _repository.addAdditionalGroup(accountId, group, success -> { if (successCallback != null) { successCallback.accept(success); } - if (!success.booleanValue()) + if (!success) { - System.out.println("Error adding additional group " + group.getIdentifier() + " to account " + accountId + "!"); + System.out.println("Error adding additional group " + group.name() + " to account " + accountId + "!"); } }); } @@ -731,7 +730,7 @@ public class CoreClientManager extends MiniPlugin { removeAdditionalGroup(Get(player).getAccountId(), group, success -> { - if (success.booleanValue()) + if (success) { Get(player).removeAdditionalGroup(group); UtilServer.CallEvent(new OnlineGroupRemoveEvent(player, group)); @@ -745,15 +744,15 @@ public class CoreClientManager extends MiniPlugin public void removeAdditionalGroup(final int accountId, final PermissionGroup group, Consumer successCallback) { - _repository.removeAdditionalGroup(accountId, group.getIdentifier(), success -> + _repository.removeAdditionalGroup(accountId, group, success -> { if (successCallback != null) { successCallback.accept(success); } - if (!success.booleanValue()) + if (!success) { - System.out.println("Error removing additional group " + group.getIdentifier() + " from account " + accountId + "!"); + System.out.println("Error removing additional group " + group + " from account " + accountId + "!"); } }); } @@ -762,13 +761,13 @@ public class CoreClientManager extends MiniPlugin { clearGroups(Get(player).getAccountId(), success -> { - if (success.booleanValue()) + if (success) { PermissionGroup old = Get(player).getPrimaryGroup(); Set cleared = Sets.newHashSet(Get(player).getAdditionalGroups()); - Get(player).setPrimaryGroup(_perm.getGroup("player")); + Get(player).setPrimaryGroup(PermissionGroup.PLAYER); Get(player).getAdditionalGroups().clear(); - UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(player, old, _perm.getGroup("player"))); + UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(player, old, PermissionGroup.PLAYER)); for (PermissionGroup clr : cleared) { UtilServer.CallEvent(new OnlineGroupRemoveEvent(player, clr)); @@ -789,25 +788,25 @@ public class CoreClientManager extends MiniPlugin { successCallback.accept(success); } - if (!success.booleanValue()) + if (!success) { System.out.println("Error clearing groups from account " + accountId + "!"); } }); } - public void fetchGroups(final int accountId, Consumer>> resultCallback, Runnable onError) + public void fetchGroups(final int accountId, BiConsumer> resultCallback, Runnable onError) { - _repository.fetchGroups(accountId, pair -> + _repository.fetchGroups(accountId, (primaryGroup, additionalGroups) -> { AtomicReference primaryReference = new AtomicReference<>(); UUID uuid; - if (pair.getLeft() == null && (uuid = _repository.getClientUUID(accountId)) != null) + if (primaryGroup == null && (uuid = _repository.getClientUUID(accountId)) != null) { runAsync(() -> { String legacy = loadOfflineClient(uuid).Rank; - PermissionGroup defaultGroup = _perm.getGroup("player"); + PermissionGroup defaultGroup = PermissionGroup.PLAYER; PermissionGroup loaded = _perm.getGroupFromLegacy(legacy); if (loaded == null) { @@ -820,24 +819,22 @@ public class CoreClientManager extends MiniPlugin }); long start = System.currentTimeMillis(); while (primaryReference.get() == null && !UtilTime.elapsed(start, 5000)) {} - primaryReference.compareAndSet(null, _perm.getGroup("player")); + primaryReference.compareAndSet(null, PermissionGroup.PLAYER); } else { - PermissionGroup defaultGroup = _perm.getGroup("player"); - PermissionGroup loaded = _perm.getGroup(pair.getLeft()); - if (loaded == null) + PermissionGroup defaultGroup = PermissionGroup.PLAYER; + if (primaryGroup == null) { primaryReference.set(defaultGroup); } else { - primaryReference.set(loaded); + primaryReference.set(primaryGroup); } } - final Set additional = pair.getRight().stream().map(_perm::getGroup).filter(Objects::nonNull).collect(Collectors.toSet()); - - UtilServer.runSync(() -> resultCallback.accept(Pair.create(primaryReference.get(), additional))); + + UtilServer.runSync(() -> resultCallback.accept(primaryReference.get(), additionalGroups)); }, () -> { if (onError != null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java index 064f5e204..9fec61a05 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java @@ -1,5 +1,6 @@ package mineplex.core.account.command; +import java.util.Optional; import java.util.UUID; import org.bukkit.Bukkit; @@ -30,12 +31,14 @@ public class AddRankCommand extends CommandBase return; } final String target = args[0]; - final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]); - if (group == null) + Optional maybeGroup = PermissionGroup.getGroup(args[1]); + if (!maybeGroup.isPresent()) { UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!")); return; } + + PermissionGroup group = maybeGroup.get(); Plugin.runAsync(() -> { UUID uuid = Plugin.loadUUIDFromDB(target); @@ -50,18 +53,18 @@ public class AddRankCommand extends CommandBase if (Bukkit.getPlayer(uuid) != null) { final CoreClient client = Plugin.Get(uuid); - Plugin.addAdditionalGroup(client.getAccountId(), group, success -> + Plugin.addAdditionalGroup(client.getAccountId(), maybeGroup.get(), success -> { - if (success.booleanValue()) + if (success) { - client.addAdditionalGroup(group); + client.addAdditionalGroup(maybeGroup.get()); UtilServer.CallEvent(new OnlineGroupAddEvent(Bukkit.getPlayer(uuid), group)); - UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "You have gained sub-rank " + F.elem(group.getIdentifier()) + "!")); - UtilPlayer.message(caller, F.main(Plugin.getName(), "You have added sub-rank " + F.elem(group.getIdentifier()) + " to " + F.elem(target) + "!")); + UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "You have gained sub-rank " + F.elem(group.name().toLowerCase()) + "!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have added sub-rank " + F.elem(group.name().toLowerCase()) + " to " + F.elem(target) + "!")); } else { - UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while adding sub-rank " + F.elem(group.getIdentifier()) + " to " + F.elem(target) + "! They may already have it.")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while adding sub-rank " + F.elem(group.name().toLowerCase()) + " to " + F.elem(target) + "! They may already have it.")); } }); } @@ -71,21 +74,21 @@ public class AddRankCommand extends CommandBase { Plugin.runSync(() -> { - if (id.intValue() == -1) + if (id == -1) { UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); } else { - Plugin.addAdditionalGroup(id.intValue(), group, success -> + Plugin.addAdditionalGroup(id, group, success -> { - if (success.booleanValue()) + if (success) { - UtilPlayer.message(caller, F.main(Plugin.getName(), "You have added sub-rank " + F.elem(group.getIdentifier()) + " to " + F.elem(target) + "!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have added sub-rank " + F.elem(group.name().toLowerCase()) + " to " + F.elem(target) + "!")); } else { - UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while adding sub-rank " + F.elem(group.getIdentifier()) + " to " + F.elem(target) + "! They may already have it.")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while adding sub-rank " + F.elem(group.name().toLowerCase()) + " to " + F.elem(target) + "! They may already have it.")); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java index 63a287046..839dea4a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java @@ -43,14 +43,14 @@ public class InfoPlayerCommand extends CommandBase if (Bukkit.getPlayer(uuid) != null) { final CoreClient client = Plugin.Get(uuid); - Plugin.fetchGroups(client.getAccountId(), pair -> + Plugin.fetchGroups(client.getAccountId(), (primaryGroup, additionalGroups) -> { UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":")); - UtilPlayer.message(caller, C.cBlue + "Primary: " + C.cGray + pair.getLeft().getIdentifier()); - UtilPlayer.message(caller, C.cBlue + "Additional (" + pair.getRight().size() + "):"); - for (PermissionGroup group : pair.getRight()) + UtilPlayer.message(caller, C.cBlue + "Primary: " + C.cGray + primaryGroup.name().toLowerCase()); + UtilPlayer.message(caller, C.cBlue + "Additional (" + additionalGroups.size() + "):"); + for (PermissionGroup group : additionalGroups) { - UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.getIdentifier()); + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.name().toLowerCase()); } }, () -> { @@ -63,20 +63,20 @@ public class InfoPlayerCommand extends CommandBase { Plugin.runSync(() -> { - if (id.intValue() == -1) + if (id == -1) { UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); } else { - Plugin.fetchGroups(id.intValue(), pair -> + Plugin.fetchGroups(id, (primaryGroup, additionalGroups) -> { UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":")); - UtilPlayer.message(caller, C.cBlue + "Primary: " + C.cGray + pair.getLeft().getIdentifier()); - UtilPlayer.message(caller, C.cBlue + "Additional (" + pair.getRight().size() + "):"); - for (PermissionGroup group : pair.getRight()) + UtilPlayer.message(caller, C.cBlue + "Primary: " + C.cGray + primaryGroup.name().toLowerCase()); + UtilPlayer.message(caller, C.cBlue + "Additional (" + additionalGroups.size() + "):"); + for (PermissionGroup group : additionalGroups) { - UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.getIdentifier()); + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.name().toLowerCase()); } }, () -> { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java index df8dbded1..5cd4132f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java @@ -1,10 +1,12 @@ package mineplex.core.account.command; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.command.CommandBase; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -20,6 +22,6 @@ public class ListRanksCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Available Ranks: " + Plugin.getPermissionManager().getGroups().stream().map(group -> C.cYellow + group.getIdentifier()).sorted().collect(Collectors.joining(C.cGray + ", ")))); + UtilPlayer.message(caller, F.main(Plugin.getName(), "Available Ranks: " + Stream.of(PermissionGroup.values()).map(group -> C.cYellow + group.name().toLowerCase()).sorted().collect(Collectors.joining(C.cGray + ", ")))); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java index d80f88901..9b9645948 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java @@ -1,5 +1,6 @@ package mineplex.core.account.command; +import java.util.Optional; import java.util.UUID; import org.bukkit.Bukkit; @@ -30,12 +31,14 @@ public class RemoveRankCommand extends CommandBase return; } final String target = args[0]; - final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]); - if (group == null) + Optional maybeGroup = PermissionGroup.getGroup(args[1]); + if (!maybeGroup.isPresent()) { UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!")); return; } + + PermissionGroup group = maybeGroup.get(); Plugin.runAsync(() -> { UUID uuid = Plugin.loadUUIDFromDB(target); @@ -52,16 +55,16 @@ public class RemoveRankCommand extends CommandBase final CoreClient client = Plugin.Get(uuid); Plugin.removeAdditionalGroup(client.getAccountId(), group, success -> { - if (success.booleanValue()) + if (success) { client.removeAdditionalGroup(group); UtilServer.CallEvent(new OnlineGroupRemoveEvent(Bukkit.getPlayer(uuid), group)); - UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "You have lost sub-rank " + F.elem(group.getIdentifier()) + "!")); - UtilPlayer.message(caller, F.main(Plugin.getName(), "You have removed sub-rank " + F.elem(group.getIdentifier()) + " from " + F.elem(target) + "!")); + UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "You have lost sub-rank " + F.elem(group.name().toLowerCase()) + "!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have removed sub-rank " + F.elem(group.name().toLowerCase()) + " from " + F.elem(target) + "!")); } else { - UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while removing sub-rank " + F.elem(group.getIdentifier()) + " from " + F.elem(target) + "! They may not have it.")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while removing sub-rank " + F.elem(group.name().toLowerCase()) + " from " + F.elem(target) + "! They may not have it.")); } }); } @@ -71,21 +74,21 @@ public class RemoveRankCommand extends CommandBase { Plugin.runSync(() -> { - if (id.intValue() == -1) + if (id == -1) { UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); } else { - Plugin.removeAdditionalGroup(id.intValue(), group, success -> + Plugin.removeAdditionalGroup(id, group, success -> { - if (success.booleanValue()) + if (success) { - UtilPlayer.message(caller, F.main(Plugin.getName(), "You have removed sub-rank " + F.elem(group.getIdentifier()) + " from " + F.elem(target) + "!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have removed sub-rank " + F.elem(group.name().toLowerCase()) + " from " + F.elem(target) + "!")); } else { - UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while removing sub-rank " + F.elem(group.getIdentifier()) + " from " + F.elem(target) + "! They may not have it.")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while removing sub-rank " + F.elem(group.name().toLowerCase()) + " from " + F.elem(target) + "! They may not have it.")); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java index 0033cb665..4a35f302b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java @@ -53,7 +53,7 @@ public class ResetPlayerCommand extends CommandBase if (success.booleanValue()) { PermissionGroup old = client.getPrimaryGroup(); - client.setPrimaryGroup(Plugin.getPermissionManager().getGroup("player")); + client.setPrimaryGroup(PermissionGroup.PLAYER); Set cleared = Sets.newHashSet(client.getAdditionalGroups()); client.getAdditionalGroups().clear(); UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(Bukkit.getPlayer(uuid), old, client.getPrimaryGroup())); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java index c2d6598c2..e14bb71b0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java @@ -1,5 +1,6 @@ package mineplex.core.account.command; +import java.util.Optional; import java.util.UUID; import org.bukkit.Bukkit; @@ -30,12 +31,14 @@ public class SetRankCommand extends CommandBase return; } final String target = args[0]; - final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]); - if (group == null) + Optional maybeGroup = PermissionGroup.getGroup(args[1]); + if (!maybeGroup.isPresent()) { UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!")); return; } + + PermissionGroup group = maybeGroup.get(); if (!group.canBePrimary()) { UtilPlayer.message(caller, F.main(Plugin.getName(), "That rank cannot be primary!")); @@ -60,8 +63,8 @@ public class SetRankCommand extends CommandBase PermissionGroup old = client.getPrimaryGroup(); client.setPrimaryGroup(group); UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(Bukkit.getPlayer(uuid), old, client.getPrimaryGroup())); - UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "Your rank has been updated to " + F.elem(group.getIdentifier()) + "!")); - UtilPlayer.message(caller, F.main(Plugin.getName(), "You have updated " + F.elem(target + "'s") + " rank to " + F.elem(group.getIdentifier()) + "!")); + UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "Your rank has been updated to " + F.elem(group.name().toLowerCase()) + "!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have updated " + F.elem(target + "'s") + " rank to " + F.elem(group.name().toLowerCase()) + "!")); }); } else @@ -70,15 +73,15 @@ public class SetRankCommand extends CommandBase { Plugin.runSync(() -> { - if (id.intValue() == -1) + if (id == -1) { UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); } else { - Plugin.setPrimaryGroup(id.intValue(), group, () -> + Plugin.setPrimaryGroup(id, group, () -> { - UtilPlayer.message(caller, F.main(Plugin.getName(), "You have updated " + F.elem(target + "'s") + " rank to " + F.elem(group.getIdentifier()) + "!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have updated " + F.elem(target + "'s") + " rank to " + F.elem(group.name().toLowerCase()) + "!")); }); } }); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupAddEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupAddEvent.java index 016df30d7..a0c3dbf72 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupAddEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupAddEvent.java @@ -3,17 +3,19 @@ package mineplex.core.account.event; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import mineplex.core.account.permissions.PermissionGroup; + public class GroupAddEvent extends Event { private static final HandlerList handlers = new HandlerList(); private int _accountId; - private String _groupIdentifier; + private PermissionGroup _group; - public GroupAddEvent(int accountId, String groupIdentifier) + public GroupAddEvent(int accountId, PermissionGroup group) { _accountId = accountId; - _groupIdentifier = groupIdentifier; + _group = group; } public int getAccountId() @@ -21,9 +23,9 @@ public class GroupAddEvent extends Event return _accountId; } - public String getGroupIdentifier() + public PermissionGroup getGroup() { - return _groupIdentifier; + return _group; } public HandlerList getHandlers() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupRemoveEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupRemoveEvent.java index c84e15819..ec609eec4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupRemoveEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupRemoveEvent.java @@ -3,17 +3,19 @@ package mineplex.core.account.event; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import mineplex.core.account.permissions.PermissionGroup; + public class GroupRemoveEvent extends Event { private static final HandlerList handlers = new HandlerList(); private int _accountId; - private String _groupIdentifier; + private PermissionGroup _group; - public GroupRemoveEvent(int accountId, String groupIdentifier) + public GroupRemoveEvent(int accountId, PermissionGroup group) { _accountId = accountId; - _groupIdentifier = groupIdentifier; + _group = group; } public int getAccountId() @@ -21,9 +23,9 @@ public class GroupRemoveEvent extends Event return _accountId; } - public String getGroupIdentifier() + public PermissionGroup getGroup() { - return _groupIdentifier; + return _group; } public HandlerList getHandlers() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/PrimaryGroupUpdateEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/PrimaryGroupUpdateEvent.java index 07c0d9bdd..27807b58d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/PrimaryGroupUpdateEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/PrimaryGroupUpdateEvent.java @@ -3,17 +3,19 @@ package mineplex.core.account.event; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import mineplex.core.account.permissions.PermissionGroup; + public class PrimaryGroupUpdateEvent extends Event { private static final HandlerList handlers = new HandlerList(); private int _accountId; - private String _groupIdentifier; + private PermissionGroup _group; - public PrimaryGroupUpdateEvent(int accountId, String groupIdentifier) + public PrimaryGroupUpdateEvent(int accountId, PermissionGroup group) { _accountId = accountId; - _groupIdentifier = groupIdentifier; + _group = group; } public int getAccountId() @@ -21,9 +23,9 @@ public class PrimaryGroupUpdateEvent extends Event return _accountId; } - public String getGroupIdentifier() + public PermissionGroup getGroup() { - return _groupIdentifier; + return _group; } public HandlerList getHandlers() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java index 337d4858e..d243bc409 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java @@ -4,21 +4,61 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Objects; +import java.util.Optional; import java.util.Set; +import java.util.stream.Stream; import org.bukkit.ChatColor; -public class PermissionGroup +import mineplex.core.common.util.F; + +public enum PermissionGroup { - protected final Object LOCK = new Object(); + BUILDER("builder", "Builder", "These creative staff members help \nbuild maps for your favorite games!", ChatColor.BLUE, 26, true, "eternal"), + MAPPER("mapper", "Mapper", "These senior staff members work closely with \nthe development and design teams to build new \nmaps for new and old content!", ChatColor.BLUE, 100, true, "builder"), + MAPLEAD("maplead", "MapLead", "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", ChatColor.BLUE, 25, true, "mapper"), + TRAINEE("trainee", "Trainee", "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", ChatColor.GOLD, 24, true, "maplead"), + MOD("mod", "Mod", "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", ChatColor.GOLD, 32, true, "trainee"), + SRMOD("srmod", "Sr.Mod", "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", ChatColor.GOLD, 44, true, "mod"), + SUPPORT("support", "Support", "Support agents handle tickets and \nprovide customer service.", ChatColor.BLUE, 47, true, "srmod"), + ADMIN("admin", "Admin", "An Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it.", ChatColor.DARK_RED, 10, true, "support", "content"), + DEV("dev", "Dev", "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", ChatColor.DARK_RED, 5, true, "admin"), + LT("lt", "Leader", "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team.", ChatColor.DARK_RED, 11, true, "dev"), + OWNER("owner", "Owner", "Owners are the core managers of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation.", ChatColor.DARK_RED, 55, true, "lt"), + + //SUB-GROUPS + QAM("qam", "", "Managers of the Quality Assurance team.", ChatColor.WHITE, 50, false, "qa"), + QA("qa", "", "Members of the Quality Assurance team.", ChatColor.WHITE, 50, false), + CMOD("cmod", "", "Members of the Clans Management team.", ChatColor.WHITE, 32, false), + TM("tm", "", "Members of the Trainee Management team.", ChatColor.WHITE, 52, false), + MC("mc", "", "Members of the Moderator Coordination team.", ChatColor.WHITE, 49, false), + EVENTMOD("eventmod", "", "Members of the Event Management team.", ChatColor.WHITE, -1, false), + CMA("cma", "", "Members of the Clans Management Assistance team.", ChatColor.WHITE, -1, false), + + //CONTENT + CONTENT("content", "", "", ChatColor.WHITE, -1, false, "eternal"), + TWITCH("twitch", "Twitch", "A Twitch streamer who often features \nMineplex in their streams.", ChatColor.DARK_PURPLE, 21, true, "content"), + YT("yt", "YT", "A YouTuber who creates content for \nor related to Mineplex. \n\nThey have fewer subscribers than full YouTubers.", ChatColor.DARK_PURPLE, 20, true, "content"), + YOUTUBE("youtube", "YouTube", "A YouTuber who creates content for \nor related to Mineplex.", ChatColor.RED, 22, true, "content"), + + //PLAYER + PLAYER("player", "", "", ChatColor.WHITE, -1, true), + ULTRA("ultra", "Ultra", "A first step into the stories of the mist. \nOnly those brave enough may enter. \n\nThe first purchasable rank at Mineplex.com/shop", ChatColor.AQUA, 12, true, "player"), + HERO("hero", "Hero", "There are many stories of a \nvaliant Hero who was brave enough to \ntame the most fearsome dragon in the land. \n\nThe second purchasable rank at Mineplex.com/shop", ChatColor.LIGHT_PURPLE, 13, true, "ultra"), + LEGEND("legend", "Legend", "Years they have told stories of this rank, \nonly for the legends to be true. \n\nThe third purchasable rank at Mineplex.com/shop", ChatColor.GREEN, 14, true, "hero"), + TITAN("titan", "Titan", "Ancient myths spoke of a gigantic being \nwith immense power... \n\nThe fourth purchasable rank at Mineplex.com/shop", ChatColor.RED, 15, true, "legend"), + ETERNAL("eternal", "Eternal", "Fantastic and magical, no one \nexcept the time lords truly understand \nthe power of this rank.\n\nThe fifth purchasable rank at Mineplex.com/shop", ChatColor.DARK_AQUA, 18, true, "titan"), + ; + + final Object LOCK = new Object(); private final String _id, _display, _description; private final ChatColor _color; private final int _forumId; private final boolean _canBePrimary; - private final Set _inherited; - - public PermissionGroup(String identifier, String display, String description, ChatColor color, int forumId, boolean canBePrimary, String... inherited) + private final Set _inheritedGroups; + + PermissionGroup(String identifier, String display, String description, ChatColor color, int forumId, boolean canBePrimary, String... inheritedGroups) { _id = Objects.requireNonNull(identifier, "Group identifier cannot be null").toLowerCase(); _display = Objects.requireNonNull(display, "Group display cannot be null"); @@ -26,14 +66,9 @@ public class PermissionGroup _color = Objects.requireNonNull(color, "Group color cannot be null"); _forumId = forumId; _canBePrimary = canBePrimary; - _inherited = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(inherited))); + _inheritedGroups = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(inheritedGroups))); } - - public String getIdentifier() - { - return _id; - } - + public String getDisplay(boolean color, boolean uppercase, boolean bold, boolean defaultIdentifier) { StringBuilder builder = new StringBuilder(); @@ -81,29 +116,11 @@ public class PermissionGroup public boolean inherits(PermissionGroup group) { - return _inherited.contains(group._id); + return _inheritedGroups.contains(group._id); } - - @Override - public String toString() + + public static Optional getGroup(String name) { - return _id; - } - - @Override - public int hashCode() - { - return _id.hashCode(); - } - - @Override - public boolean equals(Object o) - { - if (o == null || !(o instanceof PermissionGroup)) - { - return false; - } - - return ((PermissionGroup)o)._id.equals(_id); + return Stream.of(values()).filter(group -> group.name().equalsIgnoreCase(name)).findFirst(); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java index 54f73bfd6..37949c045 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java @@ -1,22 +1,17 @@ package mineplex.core.account.permissions; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import com.google.common.collect.Sets; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Pair; -import mineplex.core.common.util.F; public class PermissionManager extends MiniPlugin { @@ -30,7 +25,6 @@ public class PermissionManager extends MiniPlugin super("Permission Manager"); _clientManager = client; - generateGroups(); } private Set getPermissions(PermissionGroup group, boolean allowSpecific) @@ -52,28 +46,24 @@ public class PermissionManager extends MiniPlugin synchronized (group.LOCK) { - _inheritable.get(group).entrySet().forEach(p -> - { - if (p.getValue().booleanValue()) + _inheritable.get(group).forEach((key, value) -> { + if (value) { - perms.add(p.getKey()); - } - else + perms.add(key); + } else { - perms.remove(p.getKey()); + perms.remove(key); } }); if (allowSpecific) { - _specific.get(group).entrySet().forEach(p -> - { - if (p.getValue().booleanValue()) + _specific.get(group).forEach((key, value) -> { + if (value) { - perms.add(p.getKey()); - } - else + perms.add(key); + } else { - perms.remove(p.getKey()); + perms.remove(key); } }); } @@ -81,52 +71,7 @@ public class PermissionManager extends MiniPlugin return perms; } - - private void generateGroups() - { - //STAFF - createPermissionGroup(new PermissionGroup("builder", "Builder", "These creative staff members help \nbuild maps for your favorite games!", ChatColor.BLUE, 26, true, "eternal")); - createPermissionGroup(new PermissionGroup("mapper", "Mapper", "These senior staff members work closely with \nthe development and design teams to build new \nmaps for new and old content!", ChatColor.BLUE, 100, true, "builder")); - createPermissionGroup(new PermissionGroup("maplead", "MapLead", "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", ChatColor.BLUE, 25, true, "mapper")); - createPermissionGroup(new PermissionGroup("trainee", "Trainee", "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", ChatColor.GOLD, 24, true, "maplead")); - createPermissionGroup(new PermissionGroup("mod", "Mod", "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", ChatColor.GOLD, 32, true, "trainee")); - createPermissionGroup(new PermissionGroup("srmod", "Sr.Mod", "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", ChatColor.GOLD, 44, true, "mod")); - createPermissionGroup(new PermissionGroup("support", "Support", "Support agents handle tickets and \nprovide customer service.", ChatColor.BLUE, 47, true, "srmod")); - createPermissionGroup(new PermissionGroup("admin", "Admin", "An Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it.", ChatColor.DARK_RED, 10, true, "support", "content")); - createPermissionGroup(new PermissionGroup("dev", "Dev", "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", ChatColor.DARK_RED, 5, true, "admin")); - createPermissionGroup(new PermissionGroup("lt", "Leader", "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team.", ChatColor.DARK_RED, 11, true, "dev")); - createPermissionGroup(new PermissionGroup("owner", "Owner", "Owners are the core managers of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation.", ChatColor.DARK_RED, 55, true, "lt")); - - //SUB-GROUPS - createPermissionGroup(new PermissionGroup("qam", "", "Managers of the Quality Assurance team.", ChatColor.WHITE, 50, false, "qa")); - createPermissionGroup(new PermissionGroup("qa", "", "Members of the Quality Assurance team.", ChatColor.WHITE, 50, false)); - createPermissionGroup(new PermissionGroup("cmod", "", "Members of the Clans Management team.", ChatColor.WHITE, 32, false)); - createPermissionGroup(new PermissionGroup("tm", "", "Members of the Trainee Management team.", ChatColor.WHITE, 52, false)); - createPermissionGroup(new PermissionGroup("mc", "", "Members of the Moderator Coordination team.", ChatColor.WHITE, 49, false)); - createPermissionGroup(new PermissionGroup("eventmod", "", "Members of the Event Management team.", ChatColor.WHITE, -1, false)); - createPermissionGroup(new PermissionGroup("cma", "", "Members of the Clans Management Assistance team.", ChatColor.WHITE, -1, false)); - - //CONTENT - createPermissionGroup(new PermissionGroup("content", "", "", ChatColor.WHITE, -1, false, "eternal")); - createPermissionGroup(new PermissionGroup("twitch", "Twitch", "A Twitch streamer who often features \nMineplex in their streams.", ChatColor.DARK_PURPLE, 21, true, "content")); - createPermissionGroup(new PermissionGroup("yt", "YT", "A YouTuber who creates content for \nor related to Mineplex. \n\nThey have fewer subscribers than full YouTubers.", ChatColor.DARK_PURPLE, 20, true, "content")); - createPermissionGroup(new PermissionGroup("youtube", "YouTube", "A YouTuber who creates content for \nor related to Mineplex.", ChatColor.RED, 22, true, "content")); - - //PLAYER - createPermissionGroup(new PermissionGroup("player", "", "", ChatColor.WHITE, -1, true)); - createPermissionGroup(new PermissionGroup("ultra", "Ultra", "A first step into the stories of the mist. \nOnly those brave enough may enter. \n\nThe first purchasable rank at Mineplex.com/shop", ChatColor.AQUA, 12, true, "player")); - createPermissionGroup(new PermissionGroup("hero", "Hero", "There are many stories of a \nvaliant Hero who was brave enough to \ntame the most fearsome dragon in the land. \n\nThe second purchasable rank at Mineplex.com/shop", ChatColor.LIGHT_PURPLE, 13, true, "ultra")); - createPermissionGroup(new PermissionGroup("legend", "Legend", "Years they have told stories of this rank, \nonly for the legends to be true. \n\nThe third purchasable rank at Mineplex.com/shop", ChatColor.GREEN, 14, true, "hero")); - createPermissionGroup(new PermissionGroup("titan", "Titan", "Ancient myths spoke of a gigantic being \nwith immense power... \n\nThe fourth purchasable rank at Mineplex.com/shop", ChatColor.RED, 15, true, "legend")); - createPermissionGroup(new PermissionGroup("eternal", "Eternal", "Fantastic and magical, no one \nexcept the time lords truly understand \nthe power of this rank.\n\nThe fifth purchasable rank at Mineplex.com/shop", ChatColor.DARK_AQUA, 18, true, "titan")); - } - - public Collection getGroups() - { - Set groups = Sets.newHashSet(_groups.values()); - return groups; - } - + public PermissionGroup getGroup(String identifier) { if (identifier == null) @@ -143,55 +88,55 @@ public class PermissionManager extends MiniPlugin return null; } - String legacy = legacyValue == null ? "all" : legacyValue.toLowerCase(); - String current = null; + String legacy = legacyValue.toLowerCase(); + final PermissionGroup current; if (legacy.equals("developer")) { - current = "dev"; + current = PermissionGroup.DEV; } else if (legacy.equals("jnr_dev")) { - current = "player"; + current = PermissionGroup.PLAYER; } else if (legacy.equals("event_moderator")) { - current = "eventmod"; + current = PermissionGroup.EVENTMOD; } else if (legacy.equals("snr_moderator")) { - current = "srmod"; + current = PermissionGroup.SRMOD; } else if (legacy.equals("moderator")) { - current = "mod"; + current = PermissionGroup.MOD; } else if (legacy.equals("helper")) { - current = "trainee"; + current = PermissionGroup.TRAINEE; } else if (legacy.equals("mapdev")) { - current = "builder"; + current = PermissionGroup.BUILDER; } else if (legacy.equals("media")) { - current = "player"; + current = PermissionGroup.PLAYER; } else if (legacy.equals("youtube_small")) { - current = "yt"; + current = PermissionGroup.YT; } else if (legacy.equals("all")) { - current = "player"; + current = PermissionGroup.PLAYER; } else { - current = legacy; + current = PermissionGroup.getGroup(legacy).get(); } - return getGroup(current); + return current; } /** @@ -270,21 +215,6 @@ public class PermissionManager extends MiniPlugin return hasPermission(client, permission); } - private void createPermissionGroup(PermissionGroup group) - { - if (group == null) - { - throw new NullPointerException("Cannot register a null group"); - } - if (_groups.containsKey(group.getIdentifier())) - { - throw new IllegalArgumentException("That group is already registered"); - } - _groups.put(group.getIdentifier().toLowerCase(), group); - _inheritable.put(group, new HashMap<>()); - _specific.put(group, new HashMap<>()); - } - public void setPermission(PermissionGroup group, GroupPermission permission, boolean inheritable, boolean value) { if (group == null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroupHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroupHandler.java index 3f7befb4c..0f735a6d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroupHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroupHandler.java @@ -29,12 +29,9 @@ public class AddPermissionGroupHandler implements CommandCallback if (opt.isPresent()) { - PermissionGroup group = _clientManager.getPermissionManager().getGroup("player"); + PermissionGroup group = PermissionGroup.PLAYER; _clientManager.Get(opt.get()).setPrimaryGroup(group); _clientManager.Get(opt.get()).getAdditionalGroups().clear(); UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "Your ranks have been cleared!")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdateHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdateHandler.java index 9ceec3415..c7f59ed1b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdateHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdateHandler.java @@ -29,13 +29,9 @@ public class PrimaryGroupUpdateHandler implements CommandCallback>> login(final List loginProcessors, final UUID uuid, final String name) throws SQLException + public Pair>> login(final List loginProcessors, final UUID uuid, final String name) throws SQLException { // First we try to grab the account id from cache - this saves an extra trip to database int accountId = PlayerCache.getInstance().getAccountId(uuid); - String primaryId = null; - Set extraIds = new HashSet<>(); + PermissionGroup primaryRank = null; + Set extraRanks = new HashSet<>(); System.out.println("LOGIN... IDLE: " + ((BasicDataSource) DBPool.getAccount()).getNumIdle() + " ACTIVE: " + ((BasicDataSource) DBPool.getAccount()).getNumActive()); try (Connection connection = getConnection(); Statement statement = connection.createStatement()) @@ -103,16 +105,16 @@ public class AccountRepository extends MinecraftRepository while (rankSet.next()) { anyRows = true; - String id = rankSet.getString("rankIdentifier"); + PermissionGroup group = PermissionGroup.valueOf(rankSet.getString("rankIdentifier")); boolean primary = rankSet.getBoolean("primaryGroup"); if (primary) { - primaryId = id; + primaryRank = group; } else { - extraIds.add(id); + extraRanks.add(group); } } @@ -156,7 +158,7 @@ public class AccountRepository extends MinecraftRepository } - return Pair.create(Integer.valueOf(accountId), Pair.create(primaryId, extraIds)); + return Pair.create(accountId, Pair.create(primaryRank, extraRanks)); } public void getAccountId(UUID uuid, Callback callback) @@ -227,7 +229,7 @@ public class AccountRepository extends MinecraftRepository } } - public void setPrimaryGroup(final int accountId, final String rankIdentifier, Runnable after) + public void setPrimaryGroup(final int accountId, final PermissionGroup group, Runnable after) { UtilServer.runAsync(() -> { @@ -243,7 +245,7 @@ public class AccountRepository extends MinecraftRepository } } - executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier), new ColumnInt("accountId", accountId)); + executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnVarChar("rankIdentifier", 255, group.name()), new ColumnInt("accountId", accountId)); UtilServer.runSync(() -> { @@ -251,7 +253,7 @@ public class AccountRepository extends MinecraftRepository { after.run(); } - UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, rankIdentifier)); + UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, group)); }); } catch (SQLException e) @@ -261,7 +263,7 @@ public class AccountRepository extends MinecraftRepository }); } - public void addAdditionalGroup(final int accountId, final String rankIdentifier, Consumer successCallback) + public void addAdditionalGroup(final int accountId, final PermissionGroup group, Consumer successCallback) { UtilServer.runAsync(() -> { @@ -275,7 +277,7 @@ public class AccountRepository extends MinecraftRepository { successCallback.accept(Boolean.TRUE); } - UtilServer.CallEvent(new GroupAddEvent(accountId, rankIdentifier)); + UtilServer.CallEvent(new GroupAddEvent(accountId, group)); }); } else @@ -291,11 +293,11 @@ public class AccountRepository extends MinecraftRepository { UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE)); } - }, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier)); + }, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", 255, group.name())); }); } - public void removeAdditionalGroup(final int accountId, final String rankIdentifier, Consumer successCallback) + public void removeAdditionalGroup(final int accountId, final PermissionGroup group, Consumer successCallback) { UtilServer.runAsync(() -> { @@ -307,7 +309,7 @@ public class AccountRepository extends MinecraftRepository { UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE)); } - }, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier)); + }, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", 255, group.name())); if (!callbackRun.get()) { @@ -319,7 +321,7 @@ public class AccountRepository extends MinecraftRepository { successCallback.accept(Boolean.TRUE); } - UtilServer.CallEvent(new GroupRemoveEvent(accountId, rankIdentifier)); + UtilServer.CallEvent(new GroupRemoveEvent(accountId, group)); }); } else @@ -335,7 +337,7 @@ public class AccountRepository extends MinecraftRepository UtilServer.runAsync(() -> { AtomicBoolean success = new AtomicBoolean(true); - Set removed = new HashSet<>(); + Set removed = new HashSet<>(); try (Connection c = getConnection()) { @@ -354,12 +356,12 @@ public class AccountRepository extends MinecraftRepository { if (!rs.getBoolean("primaryGroup")) { - removed.add(rs.getString("rankIdentifier")); + removed.add(PermissionGroup.valueOf(rs.getString("rankIdentifier"))); } } } } - + executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnVarChar("rankIdentifier", "player".length(), "player"), new ColumnInt("accountId", accountId)); executeUpdate(c, REMOVE_ADDITIONAL_RANKS, () -> success.set(false), new ColumnInt("accountId", accountId)); } @@ -375,30 +377,30 @@ public class AccountRepository extends MinecraftRepository { if (successCallback != null) { - successCallback.accept(Boolean.valueOf(success.get())); + successCallback.accept(success.get()); } - UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, "player")); - for (String ident : removed) + UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, PermissionGroup.PLAYER)); + for (PermissionGroup group : removed) { - UtilServer.CallEvent(new GroupRemoveEvent(accountId, ident)); + UtilServer.CallEvent(new GroupRemoveEvent(accountId, group)); } }); } }); } - public void fetchGroups(final int accountId, Consumer>> resultCallback, Runnable onError) + public void fetchGroups(final int accountId, BiConsumer> resultCallback, Runnable onError) { fetchGroups(accountId, resultCallback, onError, true); } - public void fetchGroups(final int accountId, Consumer>> resultCallback, Runnable onError, boolean runAsync) + public void fetchGroups(final int accountId, BiConsumer> resultCallback, Runnable onError, boolean runAsync) { Runnable r = () -> { AtomicBoolean errored = new AtomicBoolean(); AtomicReference primary = new AtomicReference<>(); - Set additional = new HashSet<>(); + Set additional = new HashSet<>(); executeQuery("SELECT * FROM accountRanks WHERE accountId=?;", rs -> { @@ -410,7 +412,7 @@ public class AccountRepository extends MinecraftRepository } else { - additional.add(rs.getString("rankIdentifier")); + additional.add(PermissionGroup.valueOf(rs.getString("rankIdentifier"))); } } }, () -> @@ -426,7 +428,7 @@ public class AccountRepository extends MinecraftRepository { if (resultCallback != null) { - resultCallback.accept(Pair.create(primary.get(), additional)); + resultCallback.accept(PermissionGroup.valueOf(primary.get()), additional); } } }; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index cb945f6c3..8a11ae11a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.command.StatsCommand; import mineplex.core.achievement.ui.AchievementShop; @@ -57,12 +58,12 @@ public class AchievementManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(SEE_FULL_STATS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 1), true, true); - pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 2), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 3), true, true); - pm.setPermission(pm.getGroup("lt"), GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 4), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(STATS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(SEE_FULL_STATS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 1), true, true); + pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 2), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 3), true, true); + pm.setPermission(PermissionGroup.LT, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 4), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(STATS_COMMAND_PERMISSION), true, true); } public AchievementData get(Player player, Achievement type) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 156cfdd50..0698939f2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -1,5 +1,6 @@ package mineplex.core.antihack; +import javax.xml.bind.DatatypeConverter; import java.util.Collections; import java.util.HashSet; import java.util.Map; @@ -9,7 +10,11 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import javax.xml.bind.DatatypeConverter; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -52,6 +57,7 @@ import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.actions.AntiHackAction; import mineplex.core.antihack.actions.BanwaveAction; @@ -82,11 +88,8 @@ import mineplex.core.punish.PunishClient; import mineplex.core.punish.Punishment; import mineplex.core.punish.PunishmentResponse; import mineplex.serverdata.commands.ServerCommandManager; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; + +import static mineplex.core.account.permissions.GroupPermission.of; @ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin @@ -198,24 +201,24 @@ public class AntiHack extends MiniPlugin private void generatePermissions() { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, false); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, false); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(SILENTLY_BANNED_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SILENTLY_BANNED_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(SILENTLY_BANNED_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, of(SILENTLY_BANNED_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SEE_ALERTS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SEE_ALERTS_PERMISSION), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(ANTICHEAT_TOGGLE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(TEST_BAN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(ANTICHEAT_TOGGLE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(TEST_BAN_COMMAND_PERMISSION), true, true); } - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(DETAILED_MESSAGES_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(GET_VLS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(DETAILED_MESSAGES_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(GET_VLS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(DETAILED_MESSAGES_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(GET_VLS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(DETAILED_MESSAGES_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(GET_VLS_COMMAND_PERMISSION), true, true); } @Override @@ -265,9 +268,7 @@ public class AntiHack extends MiniPlugin Consumer> doPunish = after -> { runAsync(() -> - { - new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.getPrimaryGroup().getIdentifier(), CheckManager.getCheckSimpleName(cause), id, gep).publish(); - }); + new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.getPrimaryGroup().name().toLowerCase(), CheckManager.getCheckSimpleName(cause), id, gep).publish()); _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after); if (UtilServer.getGroup().equals("Clans")) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java index 936b65956..faa6dbe02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -65,9 +65,7 @@ public class BanWaveManager extends MiniPlugin if (_repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server)) { runAsync(() -> - { - new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), client.getPrimaryGroup().getIdentifier(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan).publish(); - }); + new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), client.getPrimaryGroup().name().toLowerCase(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan).publish()); JsonObject custom = new JsonObject(); custom.addProperty("is-banwave", true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java index b1f8c1d79..64daf61ae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java @@ -12,11 +12,10 @@ import org.bukkit.entity.Player; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.PlayerSelector; import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.UtilLambda; @ReflectivelyCreateMiniPlugin @@ -83,18 +82,18 @@ public class GuardianManager extends MiniPlugin UtilLambda.and( PlayerSelector.NOT_VANISHED, PlayerSelector.hasAnyRank(false, - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("player"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("ultra"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("hero"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("legend"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("titan"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("twitch"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("yt"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("youtube"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("admin"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("dev"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("lt"), - Managers.get(CoreClientManager.class).getPermissionManager().getGroup("owner") + PermissionGroup.PLAYER, + PermissionGroup.ULTRA, + PermissionGroup.HERO, + PermissionGroup.LEGEND, + PermissionGroup.TITAN, + PermissionGroup.TWITCH, + PermissionGroup.YT, + PermissionGroup.YOUTUBE, + PermissionGroup.ADMIN, + PermissionGroup.DEV, + PermissionGroup.LT, + PermissionGroup.OWNER ), player -> !_stalking.contains(player.getUniqueId()), player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java index 03c20d6cc..91e45f771 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java @@ -23,6 +23,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.logging.builtin.PartyInfoMetadata; @@ -67,7 +68,7 @@ public class AntihackLogger extends MiniPlugin private void generatePermissions() { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(SAVE_METADATA_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(SAVE_METADATA_COMMAND_PERMISSION), true, true); } public void addCommands() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java index 17e7b9679..a6e23e930 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java @@ -12,6 +12,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.aprilfools.command.PirateSongCommand; import mineplex.core.common.util.UtilServer; @@ -106,7 +107,7 @@ public class AprilFoolsManager extends MiniPlugin private void generatePermissions() { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PIRATE_SONG_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PIRATE_SONG_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java index 65b755d28..3c50b529d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java @@ -13,6 +13,7 @@ import com.google.common.collect.ImmutableSet; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.powerplayclub.PowerPlayClubRepository; @@ -60,7 +61,7 @@ public class BetaWhitelist extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(BYPASS_WHITELIST_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(BYPASS_WHITELIST_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 378448e0f..b4dd34457 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -8,13 +8,16 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.TimeZone; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.EntityCreeper; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Sound; @@ -37,6 +40,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.bonuses.animations.AnimationCarl; import mineplex.core.bonuses.commands.AnimationCommand; @@ -84,9 +88,6 @@ import mineplex.database.Tables; import mineplex.database.tables.records.BonusRecord; import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.database.DBPool; -import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.EntityCreeper; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; public class BonusManager extends MiniClientPlugin implements ILoginProcessor { @@ -310,18 +311,18 @@ public class BonusManager extends MiniClientPlugin implements I private void generatePermissions() { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(MONTHLY_BONUS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(ULTRA_BONUS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("hero"), GroupPermission.of(HERO_BONUS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("legend"), GroupPermission.of(LEGEND_BONUS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_BONUS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(ETERNAL_BONUS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(MONTHLY_BONUS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(ULTRA_BONUS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.HERO, GroupPermission.of(HERO_BONUS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(LEGEND_BONUS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_BONUS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(ETERNAL_BONUS_PERMISSION), true, true); //pm.setPermission(pm.getGroup("mod"), GroupPermission.of(ALLOW_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(ANIMATION_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(GUI_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(POWER_PLAY_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TICKET_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(ANIMATION_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(GUI_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(POWER_PLAY_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TICKET_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java index cab12c860..730598c35 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java @@ -23,6 +23,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.boosters.command.BoosterCommand; import mineplex.core.boosters.event.BoosterActivateEvent; @@ -124,11 +125,11 @@ public class BoosterManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(BOOSTER_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(THANK_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(ADD_BOOSTER_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(RELOAD_BOOSTERS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(BOOSTER_GUI_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(BOOSTER_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(THANK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(ADD_BOOSTER_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(RELOAD_BOOSTERS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(BOOSTER_GUI_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java index f5fb62df6..8261150d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java @@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.botspam.command.BotSpamCommand; import mineplex.core.botspam.repository.BotSpamRepository; @@ -55,12 +56,12 @@ public class BotSpamManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_BOTSPAM_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BOTSPAM_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ADD_BOTSPAM_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TOGGLE_BOTSPAM_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UPDATE_BOTSPAM_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(LIST_BOTSPAM_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_BOTSPAM_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BOTSPAM_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ADD_BOTSPAM_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TOGGLE_BOTSPAM_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UPDATE_BOTSPAM_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(LIST_BOTSPAM_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 1368e3f8f..a426b0302 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -1,5 +1,11 @@ package mineplex.core.chat; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; @@ -14,13 +20,6 @@ import java.util.Map; import java.util.UUID; import java.util.function.Function; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - import org.apache.commons.lang3.Validate; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -38,6 +37,7 @@ import org.json.simple.JSONValue; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.chat.command.BroadcastCommand; @@ -113,16 +113,16 @@ public class Chat extends MiniPlugin private void generatePermissions() { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ALLOW_CAPS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_COOLDOWN_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_SLOW_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_SILENCE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BYPASS_SIGNS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(ALLOW_HACKUSATE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(ALLOW_SIMILAR_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SILENCE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SLOW_CHAT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BROADCAST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ALLOW_CAPS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_COOLDOWN_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_SLOW_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_SILENCE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BYPASS_SIGNS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(ALLOW_HACKUSATE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(ALLOW_SIMILAR_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SILENCE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(SLOW_CHAT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BROADCAST_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java index fb36270d4..d6a5d8580 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java @@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chatsnap.command.ChatSnapCommand; import mineplex.core.message.PrivateMessageEvent; @@ -39,7 +40,7 @@ public class SnapshotPlugin extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(CHAT_SNAP_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(CHAT_SNAP_COMMAND_PERMISSION), true, true); } public SnapshotManager getSnapshotManager() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index fc1b9e6d9..95544aa92 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -6,6 +6,10 @@ import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import net.minecraft.server.v1_8_R3.PacketPlayInTabComplete; +import net.minecraft.server.v1_8_R3.PacketPlayOutTabComplete; +import net.minecraft.server.v1_8_R3.PlayerConnection; + import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -17,6 +21,7 @@ import com.google.common.collect.Lists; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -27,9 +32,6 @@ import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; import mineplex.core.recharge.Recharge; -import net.minecraft.server.v1_8_R3.PacketPlayInTabComplete; -import net.minecraft.server.v1_8_R3.PacketPlayOutTabComplete; -import net.minecraft.server.v1_8_R3.PlayerConnection; public class CommandCenter implements Listener, IPacketHandler { @@ -85,10 +87,10 @@ public class CommandCenter implements Listener, IPacketHandler { ClientManager = clientManager; - clientManager.getPermissionManager().setPermission(clientManager.getPermissionManager().getGroup("dev"), GroupPermission.of(BLOCKED_COMMAND_PERMISSION), true, true); + clientManager.getPermissionManager().setPermission(PermissionGroup.DEV, GroupPermission.of(BLOCKED_COMMAND_PERMISSION), true, true); if (UtilServer.isTestServer()) { - clientManager.getPermissionManager().setPermission(clientManager.getPermissionManager().getGroup("qam"), GroupPermission.of(BLOCKED_COMMAND_PERMISSION), false, true); + clientManager.getPermissionManager().setPermission(PermissionGroup.QAM, GroupPermission.of(BLOCKED_COMMAND_PERMISSION), false, true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java index c8db5ac87..50fc93401 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java @@ -26,6 +26,7 @@ import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; @@ -211,23 +212,23 @@ public class CommunityManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(OWN_COMMUNITY_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_CHAT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_DESCRIPTION_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_DESCRIPTION_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(COMMUNITY_DISBAND_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_DISBAND_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_INVITE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_INVITE_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_JOIN_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_MCS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_MCS_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_MENU_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(COMMUNITY_RENAME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_RENAME_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_UNINVITE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_UNINVITE_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(OWN_COMMUNITY_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_CHAT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_DESCRIPTION_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_DESCRIPTION_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(COMMUNITY_DISBAND_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_DISBAND_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_INVITE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_INVITE_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_JOIN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_MCS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_MCS_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_MENU_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(COMMUNITY_RENAME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_RENAME_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_UNINVITE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_UNINVITE_STAFF_COMMAND_PERMISSION), true, true); } public boolean ownsCommunity(UUID uuid) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMemberButton.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMemberButton.java index ecf17c91d..83eace4dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMemberButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMemberButton.java @@ -67,9 +67,9 @@ public class CommunityMemberButton extends CommunitiesGUIButton } CoreClientManager clientManager = Managers.get(CoreClientManager.class); _fetching = true; - clientManager.fetchGroups(_info.AccountId, pair -> + clientManager.fetchGroups(_info.AccountId, (primaryGroup, additionalGroups) -> { - if (clientManager.getPermissionManager().hasPermission(pair, GroupPermission.of(CommunityManager.OWN_COMMUNITY_PERMISSION))) + if (clientManager.getPermissionManager().hasPermission(primaryGroup, GroupPermission.of(CommunityManager.OWN_COMMUNITY_PERMISSION))) { getCommunityManager().handleRoleUpdate(_viewer, _community, _info, CommunityRole.LEADER); getCommunityManager().handleRoleUpdate(_viewer, _community, _community.getMembers().get(_viewer.getUniqueId()), CommunityRole.COLEADER); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java index 972dbaa14..d83aedcc3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java @@ -27,6 +27,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -58,8 +59,8 @@ public class Creature extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MOB_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(KILL_MOB_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MOB_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(KILL_MOB_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java index 22f2c2662..7740939b5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -12,6 +12,11 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PlayerList; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; @@ -59,10 +64,6 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.PlayerStatus; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ServerManager; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.PlayerList; @ReflectivelyCreateMiniPlugin public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler @@ -155,12 +156,12 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler { PermissionManager pm = _clients.getPermissionManager(); - pm.setPermission(pm.getGroup("tm"), GroupPermission.of(USE_DISGUISE_PERMISSION), false, true); - pm.setPermission(pm.getGroup("mc"), GroupPermission.of(USE_DISGUISE_PERMISSION), false, true); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(USE_DISGUISE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(BLOCKED_DISGUISE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(BLOCKED_DISGUISE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SHORT_DISGUISE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TM, GroupPermission.of(USE_DISGUISE_PERMISSION), false, true); + pm.setPermission(PermissionGroup.MC, GroupPermission.of(USE_DISGUISE_PERMISSION), false, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(USE_DISGUISE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(BLOCKED_DISGUISE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(BLOCKED_DISGUISE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SHORT_DISGUISE_PERMISSION), true, true); } @Override @@ -617,7 +618,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler return false; } - PermissionGroup otherRank = otherClient != null ? otherClient.getPrimaryGroup() : getClientManager().getPermissionManager().getGroup("player"); + PermissionGroup otherRank = otherClient != null ? otherClient.getPrimaryGroup() : PermissionGroup.PLAYER; callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 34c44e2ee..4529ed773 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -22,6 +22,7 @@ import mineplex.core.account.ILoginProcessor; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.donation.command.CrownCommand; @@ -108,9 +109,9 @@ public class DonationManager extends MiniClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(CROWN_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GEM_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SHARD_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(CROWN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GEM_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SHARD_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java index 618e01ae3..3dd42b6bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java @@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -48,7 +49,7 @@ public class EloManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TOP_ELO_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TOP_ELO_COMMAND_PERMISSION), true, true); } public EloRepository getRepo() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java index 5ee920c36..7ab10f38e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java @@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -47,7 +48,7 @@ public class FacebookManager extends MiniDbClientPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(FACEBOOK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(FACEBOOK_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 14c6defa7..457af40fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -17,6 +17,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.JsonMessage; @@ -64,8 +65,8 @@ public class FriendManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(FRIEND_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_STAFF_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(FRIEND_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_STAFF_PERMISSION), true, true); } public PreferencesManager getPreferenceManager() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index d25ce5042..49cb1f978 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -28,6 +28,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; @@ -364,28 +365,28 @@ public class GadgetManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_ARROW_TRAIL_PERMISSION), true, true); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_DEATH_EFFECT_PERMISSION), true, true); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_DOUBLE_JUMP_PERMISSION), true, true); - pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(ETERNAL_TAUNT_PERMISSION), true, true); - pm.setPermission(pm.getGroup("legend"), GroupPermission.of(LEGEND_PARTICLE_EFFECT_PERMISSION), true, true); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_PARTICLE_EFFECT_PERMISSION), true, true); - pm.setPermission(pm.getGroup("hero"), GroupPermission.of(HERO_MORPH_BLAZE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("hero"), GroupPermission.of(HERO_MORPH_CREEPER_PERMISSION), true, true); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(ULTRA_MORPH_PERMISSION), true, true); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_MORPH_PERMISSION), true, true); - pm.setPermission(pm.getGroup("legend"), GroupPermission.of(LEGEND_MORPH_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AMMO_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(LOCK_INFUSED_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_ARROW_TRAIL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_DEATH_EFFECT_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_DOUBLE_JUMP_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(ETERNAL_TAUNT_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(LEGEND_PARTICLE_EFFECT_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_PARTICLE_EFFECT_PERMISSION), true, true); + pm.setPermission(PermissionGroup.HERO, GroupPermission.of(HERO_MORPH_BLAZE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.HERO, GroupPermission.of(HERO_MORPH_CREEPER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(ULTRA_MORPH_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_MORPH_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(LEGEND_MORPH_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AMMO_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(LOCK_INFUSED_COMMAND_PERMISSION), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(LOCK_COSMETICS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(UNLOCK_COSMETICS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(LOCK_COSMETICS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(UNLOCK_COSMETICS_COMMAND_PERMISSION), true, true); } else { - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(LOCK_COSMETICS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UNLOCK_COSMETICS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(LOCK_COSMETICS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UNLOCK_COSMETICS_COMMAND_PERMISSION), true, true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java index 16d7823d3..535ae846d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java @@ -28,7 +28,7 @@ public abstract class WinEffectRankBased extends WinEffectGadget super(manager, name, lore, -1, material, data, true, alternativeSalepackageNames); _rank = rank; _winEffectType = winEffectType; - _schematicName = winEffectType.getSchematic().replace("%r%", rank.getIdentifier().substring(0, 1).toUpperCase() + rank.getIdentifier().substring(1)); + _schematicName = winEffectType.getSchematic().replace("%r%", rank.name().substring(0, 1).toUpperCase() + rank.name().substring(1)); manager.getClientManager().getPermissionManager().setPermission(rank, getUnlockPermission(), true, true); } @@ -40,7 +40,7 @@ public abstract class WinEffectRankBased extends WinEffectGadget public GroupPermission getUnlockPermission() { - return GroupPermission.of(PERMISSION_BASE + _rank.getIdentifier()); + return GroupPermission.of(PERMISSION_BASE + _rank.name()); } public WinEffectType getWinEffectType() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index 8c9415ec2..b3dd2a174 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -12,6 +12,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.MaterialData; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; @@ -39,7 +40,7 @@ public class WinEffectRankEternal extends WinEffectRankBased { super(manager, "Eternal Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "GWEN is ALWAYS watching."}, LineFormat.LORE), - Material.PRISMARINE_SHARD, (byte) 0, manager.getClientManager().getPermissionManager().getGroup("eternal"), WinEffectType.RANK_WIN_EFFECT); + Material.PRISMARINE_SHARD, (byte) 0, PermissionGroup.ETERNAL, WinEffectType.RANK_WIN_EFFECT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index d06caba29..f01673e57 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -12,6 +12,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.MaterialData; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; @@ -39,7 +40,7 @@ public class WinEffectRankHero extends WinEffectRankBased { super(manager, "Hero Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "To become a True Hero you must first defeat the Dragon."}, LineFormat.LORE), - Material.DRAGON_EGG, (byte) 0, manager.getClientManager().getPermissionManager().getGroup("hero"), WinEffectType.RANK_WIN_EFFECT); + Material.DRAGON_EGG, (byte) 0, PermissionGroup.HERO, WinEffectType.RANK_WIN_EFFECT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index de38f79dd..8d75dc1c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -12,6 +12,7 @@ import org.bukkit.entity.WitherSkull; import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.MaterialData; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; @@ -39,7 +40,7 @@ public class WinEffectRankLegend extends WinEffectRankBased { super(manager, "Legend Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Can you weather this Withering Assault?"}, LineFormat.LORE), - Material.SKULL_ITEM, (byte) 1, manager.getClientManager().getPermissionManager().getGroup("legend"), WinEffectType.RANK_WIN_EFFECT); + Material.SKULL_ITEM, (byte) 1, PermissionGroup.LEGEND, WinEffectType.RANK_WIN_EFFECT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java index e15eec81b..10587adab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java @@ -11,6 +11,7 @@ import org.bukkit.entity.Giant; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.MaterialData; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; @@ -36,7 +37,7 @@ public class WinEffectRankTitan extends WinEffectRankBased { super(manager, "Titan Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Legend has it that the Titans were so powerful they towered over even the gods."}, LineFormat.LORE), - Material.ROTTEN_FLESH, (byte) 0, manager.getClientManager().getPermissionManager().getGroup("titan"), WinEffectType.RANK_WIN_EFFECT); + Material.ROTTEN_FLESH, (byte) 0, PermissionGroup.TITAN, WinEffectType.RANK_WIN_EFFECT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index c6e1edfd2..ec6f485cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -12,6 +12,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityExplodeEvent; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.MaterialData; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; @@ -36,7 +37,7 @@ public class WinEffectRankUltra extends WinEffectRankBased public WinEffectRankUltra(GadgetManager manager) { super(manager, "Ultra Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Always check behind you."}, LineFormat.LORE), - Material.SKULL_ITEM, (byte) 4, manager.getClientManager().getPermissionManager().getGroup("ultra"), WinEffectType.RANK_WIN_EFFECT); + Material.SKULL_ITEM, (byte) 4, PermissionGroup.ULTRA, WinEffectType.RANK_WIN_EFFECT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java index 7146232b6..01412b1c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java @@ -13,6 +13,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.structs.ItemContainer; import mineplex.core.common.util.F; @@ -40,10 +41,10 @@ public class Give extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_COMMAND_PERMISSION), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(GIVE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(GIVE_COMMAND_PERMISSION), true, true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java index 8316d5fe8..ebdec39f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java @@ -62,7 +62,7 @@ public class GlobalPacketManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GLOBAL_PACKET_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GLOBAL_PACKET_COMMAND_PERMISSION), true, true); } public void callGlobalCommand(Player caller, String[] args) @@ -75,8 +75,8 @@ public class GlobalPacketManager extends MiniPlugin { callerName = caller.getName(); callerUUID = caller.getUniqueId(); - callerRanks = _clientManager.Get(caller).getAdditionalGroups().stream().map(PermissionGroup::getIdentifier).collect(Collectors.toList()); - callerRanks.add(_clientManager.Get(caller).getPrimaryGroup().getIdentifier()); + callerRanks = _clientManager.Get(caller).getAdditionalGroups().stream().map(PermissionGroup::name).collect(Collectors.toList()); + callerRanks.add(_clientManager.Get(caller).getPrimaryGroup().name()); UtilPlayer.message(caller, F.main("Global", "Sending Global Command with Arguments;")); UtilPlayer.message(caller, F.main("Global", F.elem(Arrays.toString(args)))); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java index f32e1ed5b..f45949955 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java @@ -36,14 +36,10 @@ public class GlobalGiveCoins implements Listener PermissionManager pm = _clientManager.getPermissionManager(); for (String id : e.getCallerGroups()) { - PermissionGroup group = pm.getGroup(id); - if (group != null) + if (pm.hasPermission(PermissionGroup.valueOf(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) { - if (pm.hasPermission(pm.getGroup(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) - { - allowed = true; - break; - } + allowed = true; + break; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java index d1fa9a06e..5ef585a2f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java @@ -35,17 +35,13 @@ public class GlobalGiveGems implements Listener PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); for (String id : e.getCallerGroups()) { - PermissionGroup group = pm.getGroup(id); - if (group != null) + if (pm.hasPermission(PermissionGroup.valueOf(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) { - if (pm.hasPermission(pm.getGroup(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) - { - allowed = true; - break; - } + allowed = true; + break; } } - + if (!allowed) { return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java index 876e5005d..c7875f217 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java @@ -60,14 +60,10 @@ public class GlobalGiveItem implements Listener PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); for (String id : e.getCallerGroups()) { - PermissionGroup group = pm.getGroup(id); - if (group != null) + if (pm.hasPermission(PermissionGroup.valueOf(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) { - if (pm.hasPermission(pm.getGroup(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) - { - allowed = true; - break; - } + allowed = true; + break; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java index a92966d58..133dedb27 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java @@ -18,6 +18,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.JsonMessage; @@ -54,8 +55,8 @@ public class IgnoreManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(IGNORE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_IGNORE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(IGNORE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_IGNORE_PERMISSION), true, true); } public PreferencesManager getPreferenceManager() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index 1ca5ad6ca..136fd3a7b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -52,24 +52,16 @@ public class IncognitoManager extends MiniDbClientPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(USE_INCOGNITO_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(USE_INCOGNITO_PERMISSION), true, true); } private boolean canSeeThroughIncognito(Player viewer, Player target) { - PermissionGroup v = _clientManager.Get(viewer).getPrimaryGroup(); - PermissionGroup t = _clientManager.Get(target).getPrimaryGroup(); - - if (v.getIdentifier().equals(t.getIdentifier())) - { - return true; - } - if (_clientManager.getPermissionManager().inheritsFully(v, t)) - { - return true; - } - - return false; + PermissionGroup viewerGroup = _clientManager.Get(viewer).getPrimaryGroup(); + PermissionGroup targetGroup = _clientManager.Get(target).getPrimaryGroup(); + + return viewerGroup == targetGroup || _clientManager.getPermissionManager().inheritsFully(viewerGroup, targetGroup); + } public void addCommands() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index f0a51f0c9..b53e87292 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -25,6 +25,7 @@ import mineplex.cache.player.PlayerCache; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; @@ -65,7 +66,7 @@ public class InventoryManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_ITEM_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_ITEM_COMMAND_PERMISSION), true, true); } private void updateItems() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index 3ddc463e9..6a12074af 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -14,6 +14,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; @@ -79,7 +80,7 @@ public class LeaderboardManager extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(CYCLE_LEADERBOARD_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(CYCLE_LEADERBOARD_COMMAND_PERMISSION), true, true); } private void refreshBoards() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index fa1b0be16..7e552d810 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -88,17 +88,12 @@ public class MessageManager extends MiniClientPlugin ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, command -> { - PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getRank()); - if (group == null) - { - return; - } - + PermissionGroup group = PermissionGroup.valueOf(command.getRank()); String message = command.getMessage(); for (Player player : Bukkit.getOnlinePlayers()) { - if (_clientManager.Get(player).getPrimaryGroup().getIdentifier().equals(group.getIdentifier()) || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), group)) + if (_clientManager.Get(player).getPrimaryGroup() == group || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), group)) { if (command.getDisplayTitle()) { @@ -120,15 +115,15 @@ public class MessageManager extends MiniClientPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_INCOGNITO_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_SPAM_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SEE_ADMIN_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(ADMIN_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ANNOUNCE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(MESSAGE_ADMIN_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(MESSAGE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(RESEND_ADMIN_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(RESEND_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_INCOGNITO_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_SPAM_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SEE_ADMIN_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(ADMIN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ANNOUNCE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(MESSAGE_ADMIN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(MESSAGE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(RESEND_ADMIN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(RESEND_COMMAND_PERMISSION), true, true); } public void addCommands() @@ -273,8 +268,7 @@ public class MessageManager extends MiniClientPlugin Get(from).LastTo = to.getName(); Get(from).LastToTime = System.currentTimeMillis(); - // Chiss or defek7 - if (GetClientManager().Get(to).getRealOrDisguisedPrimaryGroup().getIdentifier().equals("dev")) + if (GetClientManager().Get(to).getRealOrDisguisedPrimaryGroup() == PermissionGroup.DEV) { UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); UtilPlayer.message(from, C.cPurple + "Please be patient if they do not reply instantly."); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java index 64dd203f7..d6ab828af 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java @@ -1,5 +1,7 @@ package mineplex.core.message.commands; +import java.util.Optional; + import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -26,14 +28,14 @@ public class AnnounceCommand extends CommandBase } else { - PermissionGroup group = Plugin.GetClientManager().getPermissionManager().getGroup(args[0]); - if (group == null) + Optional group = PermissionGroup.getGroup(args[0]); + if (!group.isPresent()) { UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!")); return; } - new AnnouncementCommand(true, group.getIdentifier(), F.combine(args, 1, null, false)).publish(); + new AnnouncementCommand(true, group.get().name(), F.combine(args, 1, null, false)).publish(); } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index 210290961..3624af989 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -2,6 +2,8 @@ package mineplex.core.monitor; import java.util.HashSet; +import net.minecraft.server.v1_8_R3.MinecraftServer; + import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -12,12 +14,12 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import net.minecraft.server.v1_8_R3.MinecraftServer; public class LagMeter extends MiniPlugin { @@ -49,10 +51,10 @@ public class LagMeter extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(VERSIONS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(VERSIONS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(LAG_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(MONITOR_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(VERSIONS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(VERSIONS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(LAG_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(MONITOR_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 2c9a85c40..7f92c9832 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -17,6 +17,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; @@ -73,8 +74,8 @@ public class MountManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("hero"), GroupPermission.of(HERO_MOUNT_PERMISSION), true, true); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_MOUNT_PERMISSION), true, true); + pm.setPermission(PermissionGroup.HERO, GroupPermission.of(HERO_MOUNT_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_MOUNT_PERMISSION), true, true); } private void CreateGadgets() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index 97ee32e12..30662f532 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -54,7 +54,7 @@ public class NotificationManager extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - if (_clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("player")) + if (_clientManager.Get(player).getPrimaryGroup() == PermissionGroup.PLAYER) { player.sendMessage(C.cWhite + " "); player.sendMessage(C.cRedB + " MASSIVE WINTER SALE"); @@ -71,20 +71,20 @@ public class NotificationManager extends MiniPlugin { PermissionGroup group = _clientManager.Get(player).getPrimaryGroup(); - if (group.getIdentifier().equals("legend") || _clientManager.getPermissionManager().inheritsFully(group, _clientManager.getPermissionManager().getGroup("legend"))) + if (group == PermissionGroup.LEGEND || _clientManager.getPermissionManager().inheritsFully(group, PermissionGroup.LEGEND)) { continue; } - if (group.getIdentifier().equals("player")) + if (group == PermissionGroup.PLAYER) { UtilPlayer.message(player, C.cWhite + " 50% Off Sale! " + " Purchase " + C.cAqua + C.Bold + "Ultra Rank" + C.cWhite + " for $15"); } - else if (group.getIdentifier().equals("ultra")) + else if (group == PermissionGroup.ULTRA) { UtilPlayer.message(player, C.cWhite + " 50% Off Sale! " + " Upgrade to " + C.cPurple + C.Bold + "Hero Rank" + C.cWhite + " for $15!"); } - else if (group.getIdentifier().equals("hero")) + else if (group == PermissionGroup.HERO) { UtilPlayer.message(player, C.cWhite + " 50% Off Sale! " + "Upgrade to " + C.cGreen + C.Bold + "Legend Rank" + C.cWhite + " for $15!"); } @@ -99,7 +99,7 @@ public class NotificationManager extends MiniPlugin { PermissionGroup group = _clientManager.Get(player).getPrimaryGroup(); - if (group.getIdentifier().equals("legend") || _clientManager.getPermissionManager().inheritsFully(group, _clientManager.getPermissionManager().getGroup("legend"))) + if (group == PermissionGroup.LEGEND || _clientManager.getPermissionManager().inheritsFully(group, PermissionGroup.LEGEND)) { continue; } @@ -112,17 +112,17 @@ public class NotificationManager extends MiniPlugin C.cGreen + C.Bold + "75% OFF"); UtilPlayer.message(player, " "); - if (group.getIdentifier().equals("player")) + if (group == PermissionGroup.PLAYER) { UtilPlayer.message(player, C.cWhite + " " + player.getName() + ", you can get 75% Off " + C.cAqua + C.Bold + "All Lifetime Ranks" + C.cWhite + "!"); UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } - else if (group.getIdentifier().equals("ultra")) + else if (group == PermissionGroup.ULTRA) { UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cPurple + C.Bold + "HERO RANK" + C.cWhite + " for only $7.50!"); UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } - else if (group.getIdentifier().equals("hero")) + else if (group == PermissionGroup.HERO) { UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cGreen + C.Bold + "LEGEND RANK" + C.cWhite + " for only $7.50!"); UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 4cdd16faa..fd11476fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -13,6 +13,8 @@ import java.util.Queue; import java.util.Set; import java.util.UUID; +import net.minecraft.server.v1_8_R3.EntityInsentient; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -53,6 +55,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; @@ -69,7 +72,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.database.Tables; import mineplex.database.tables.records.NpcsRecord; import mineplex.serverdata.database.DBPool; -import net.minecraft.server.v1_8_R3.EntityInsentient; public class NpcManager extends MiniPlugin { @@ -155,12 +157,12 @@ public class NpcManager extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ADD_NPC_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(CLEAR_NPCS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(DELETE_NPC_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NPC_HOME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NPC_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(REFRESH_NPCS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ADD_NPC_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(CLEAR_NPCS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(DELETE_NPC_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NPC_HOME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NPC_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(REFRESH_NPCS_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java index 7f1fd67bd..4becd0422 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java @@ -15,6 +15,7 @@ import org.bukkit.scheduler.BukkitTask; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.ClickEvent; @@ -108,7 +109,7 @@ public class PartyManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(PARTY_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(PARTY_COMMAND_PERMISSION), true, true); } @Deprecated diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index b50518c8e..32c959b95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -11,6 +11,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.Color; @@ -65,14 +66,14 @@ public class PersonalServerManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("legend"), GroupPermission.of(MPS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(ADVANCED_MPS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("yt"), GroupPermission.of(ADVANCED_MPS_PERMISSION), true, false); - pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(ADVANCED_MPS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("eventmod"), GroupPermission.of(EVENT_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("eventmod"), GroupPermission.of(PERSONAL_EVENT_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PERSONAL_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(MPS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(ADVANCED_MPS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.YT, GroupPermission.of(ADVANCED_MPS_PERMISSION), true, false); + pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(ADVANCED_MPS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.EVENTMOD, GroupPermission.of(EVENT_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.EVENTMOD, GroupPermission.of(PERSONAL_EVENT_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PERSONAL_EVENT_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index b6580846c..c3aff01d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -1,6 +1,6 @@ package mineplex.core.pet; -import java.awt.Color; +import java.awt.*; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -8,6 +8,9 @@ import java.util.Map; import java.util.Map.Entry; import java.util.UUID; +import net.minecraft.server.v1_8_R3.EntityCreature; +import net.minecraft.server.v1_8_R3.NavigationAbstract; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -48,6 +51,7 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.shape.ShapeWings; @@ -75,8 +79,6 @@ import mineplex.core.pet.repository.PetRepository; import mineplex.core.pet.repository.token.ClientPetTokenWrapper; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; public class PetManager extends MiniClientPlugin { @@ -134,8 +136,8 @@ public class PetManager extends MiniClientPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("legend"), GroupPermission.of(WIDDER_PET_PERMISSION), true, true); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(GUARDIAN_PET_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(WIDDER_PET_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(GUARDIAN_PET_PERMISSION), true, true); } public void addPetOwnerToQueue(String playerName, PetType petType) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java index 68726f4cc..43f0d2db2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java @@ -13,9 +13,9 @@ public enum DisplayType switch (this) { case RANKED: - return !group.getIdentifier().equals("player"); + return group != PermissionGroup.PLAYER; case NOT_RANKED: - return group.getIdentifier().equals("player"); + return group == PermissionGroup.PLAYER; default: return true; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java index bf46f14bc..9983703ab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java @@ -56,8 +56,8 @@ public class PollManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(POLL_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(POLL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(POLL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(POLL_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 5d0d53f95..e503ad59f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -19,6 +19,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -95,11 +96,11 @@ public class Portal extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(SERVER_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SEND_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_STAFF_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SERVER_COMMAND_CLANS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(SERVER_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SEND_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_STAFF_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SERVER_COMMAND_CLANS_PERMISSION), true, true); } public void sendAllPlayersToGenericServer(GenericServer hub, Intent kick) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index 13ac102fd..afdcdfded 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -28,6 +28,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilGear; @@ -79,41 +80,41 @@ public class PreferencesManager extends MiniPlugin implements ILoginProcessor { if (p == Preference.INVISIBILITY) { - pm.setPermission(pm.getGroup("admin"), p.getPermission(), true, true); - pm.setPermission(pm.getGroup("content"), p.getPermission(), true, true); - pm.setPermission(pm.getGroup("yt"), p.getPermission(), false, false); + pm.setPermission(PermissionGroup.ADMIN, p.getPermission(), true, true); + pm.setPermission(PermissionGroup.CONTENT, p.getPermission(), true, true); + pm.setPermission(PermissionGroup.YT, p.getPermission(), false, false); } else if (p == Preference.FORCE_FIELD) { - pm.setPermission(pm.getGroup("content"), p.getPermission(), true, true); - pm.setPermission(pm.getGroup("eventmod"), p.getPermission(), false, true); + pm.setPermission(PermissionGroup.CONTENT, p.getPermission(), true, true); + pm.setPermission(PermissionGroup.EVENTMOD, p.getPermission(), false, true); } else if (p == Preference.GLOBAL_GWEN_REPORTS) { - pm.setPermission(pm.getGroup("trainee"), p.getPermission(), true, true); + pm.setPermission(PermissionGroup.TRAINEE, p.getPermission(), true, true); } else if (p == Preference.SHOW_USER_REPORTS) { - pm.setPermission(pm.getGroup("trainee"), p.getPermission(), true, true); + pm.setPermission(PermissionGroup.TRAINEE, p.getPermission(), true, true); } else if (p == Preference.IGNORE_VELOCITY) { - pm.setPermission(pm.getGroup("builder"), p.getPermission(), true, true); + pm.setPermission(PermissionGroup.BUILDER, p.getPermission(), true, true); } else { - pm.setPermission(pm.getGroup("admin"), p.getPermission(), true, true); + pm.setPermission(PermissionGroup.ADMIN, p.getPermission(), true, true); } } else { - pm.setPermission(pm.getGroup("player"), p.getPermission(), true, true); + pm.setPermission(PermissionGroup.PLAYER, p.getPermission(), true, true); } } - pm.setPermission(pm.getGroup("content"), GroupPermission.of(VIEW_EXCLUSIVE_MENU_PERMISSION), true, true); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(VIEW_EXCLUSIVE_MENU_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(PREFERENCES_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(VIEW_EXCLUSIVE_MENU_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(VIEW_EXCLUSIVE_MENU_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(PREFERENCES_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 698b0641b..06615747d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -26,6 +26,7 @@ import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.Constants; import mineplex.core.common.util.C; @@ -81,10 +82,10 @@ public class Punish extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(FULL_PUNISHMENT_ACCESS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(RULES_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(FULL_PUNISHMENT_ACCESS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(RULES_COMMAND_PERMISSION), true, true); } public ClansBanManager getClansPunish() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java index a2e5fb8d4..e7cea3a39 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java @@ -14,6 +14,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -64,13 +65,13 @@ public class ClansBanManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), true, true); - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), false, true); - pm.setPermission(pm.getGroup("cma"), GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), false, true); + pm.setPermission(PermissionGroup.CMA, GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("cma"), GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.CMA, GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), false, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index e31644f82..8ae77d09b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -12,6 +12,8 @@ import java.util.Set; import java.util.UUID; import java.util.function.Consumer; +import net.md_5.bungee.api.ChatColor; + import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -23,6 +25,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -51,7 +54,6 @@ import mineplex.quest.common.QuestSupplier; import mineplex.serverdata.redis.messaging.PubSubJedisClient; import mineplex.serverdata.redis.messaging.PubSubRouter; import mineplex.serverdata.servers.ServerManager; -import net.md_5.bungee.api.ChatColor; /** * QuestManager @@ -118,10 +120,10 @@ public class QuestManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GET_QUEST_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(GET_QUEST_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(INCREMENT_QUEST_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(QUEST_GUI_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GET_QUEST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(GET_QUEST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(INCREMENT_QUEST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(QUEST_GUI_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java index 52b5e7a31..884ff4f44 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java @@ -37,8 +37,8 @@ public class EternalGiveawayManager extends MiniPlugin _clientManager = clientManager; _statusManager = statusManager; _random = new Random(); - - _group = _clientManager.getPermissionManager().getGroup("eternal"); + + _group = PermissionGroup.ETERNAL; ServerCommandManager.getInstance().registerCommandType("EternalGiveawayMessage", EternalGiveawayMessage.class, new GiveawayMessageHandler(plugin)); @@ -49,7 +49,7 @@ public class EternalGiveawayManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("lt"), GroupPermission.of(ETERNAL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LT, GroupPermission.of(ETERNAL_COMMAND_PERMISSION), true, true); } @Override @@ -100,7 +100,7 @@ public class EternalGiveawayManager extends MiniPlugin */ private boolean hasEternal(Player player) { - return _clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("eternal") || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group); + return _clientManager.Get(player).getPrimaryGroup() == PermissionGroup.ETERNAL || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group); } public Region getRegion() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java index 1ec63db20..991714e40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java @@ -35,8 +35,8 @@ public class TitanGiveawayManager extends MiniPlugin _clientManager = clientManager; _statusManager = statusManager; _random = new Random(); - - _group = _clientManager.getPermissionManager().getGroup("titan"); + + _group = PermissionGroup.TITAN; ServerCommandManager.getInstance().registerCommandType("TitanGiveawayMessage", TitanGiveawayMessage.class, new GiveawayMessageHandler(plugin)); ServerCommandManager.getInstance().registerCommandType("TitanChestGiveawayMessage", TitanChestGiveawayMessage.class, new TitanChestGiveawayHandler(_statusManager)); @@ -81,7 +81,7 @@ public class TitanGiveawayManager extends MiniPlugin */ private boolean hasTitan(Player player) { - return _clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("titan") || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group); + return _clientManager.Get(player).getPrimaryGroup() == PermissionGroup.TITAN || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group); } public Region getRegion() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 750436645..d4b31daa3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -19,6 +19,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotMetadata; @@ -36,16 +37,17 @@ import mineplex.core.portal.Portal; import mineplex.core.punish.Category; import mineplex.core.punish.Punish; import mineplex.core.punish.PunishClient; -import mineplex.core.report.data.metrics.ReportMetricsRepository; -import mineplex.core.report.redis.HandlerNotification; import mineplex.core.report.data.Report; import mineplex.core.report.data.ReportMessage; +import mineplex.core.report.data.ReportRepository; import mineplex.core.report.data.ReportUser; import mineplex.core.report.data.ReportUserRepository; -import mineplex.core.report.data.ReportRepository; +import mineplex.core.report.data.metrics.ReportMetricsRepository; +import mineplex.core.report.redis.HandlerNotification; import mineplex.core.report.redis.ReportersNotification; import mineplex.serverdata.Region; import mineplex.serverdata.commands.ServerCommandManager; + import static com.google.common.base.Preconditions.checkNotNull; /** @@ -108,12 +110,12 @@ public class ReportManager { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_CLOSE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(REPORT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_HANDLE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_HISTORY_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_INFO_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_METRICS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_CLOSE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(REPORT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_HANDLE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_HISTORY_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_INFO_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_METRICS_COMMAND_PERMISSION), true, true); } public SnapshotManager getSnapshotManager() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index a946ea828..57867be59 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; @@ -1307,7 +1308,7 @@ public class RewardManager if (rarity == RewardRarity.MYTHICAL) { PowerPlayReward rew = new PowerPlayReward(_clientManager, SubscriptionDuration.MONTH, rarity, 0, 0); - if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST || type == RewardType.THANKFUL_CHEST) && !(_clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("titan") || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("titan")))) + if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST || type == RewardType.THANKFUL_CHEST) && !(_clientManager.Get(player).getPrimaryGroup() == PermissionGroup.TITAN || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), PermissionGroup.TITAN))) { return new RankReward(_clientManager, 0, 0, rarity); } @@ -1315,7 +1316,7 @@ public class RewardManager { return rew; } - else if (!canGiveMythical || (_clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("legend") || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("legend")))) + else if (!canGiveMythical || (_clientManager.Get(player).getPrimaryGroup() == PermissionGroup.LEGEND || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), PermissionGroup.LEGEND))) { rarity = RewardRarity.LEGENDARY; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java index d6983bd3f..cb530df67 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java @@ -31,31 +31,31 @@ public class RankReward extends Reward { PermissionGroup newGroup = null; - switch (current.getIdentifier()) + switch (current) { - case "player": - newGroup = _clientManager.getPermissionManager().getGroup("ultra"); - break; - case "ultra": - newGroup = _clientManager.getPermissionManager().getGroup("hero"); - break; - case "hero": - newGroup = _clientManager.getPermissionManager().getGroup("legend"); - break; - case "legend": - if (canPassLegend) - { - newGroup = _clientManager.getPermissionManager().getGroup("titan"); - } - break; - case "titan": - if (canPassLegend) - { - newGroup = _clientManager.getPermissionManager().getGroup("eternal"); - } - break; - default: - break; + case PLAYER: + newGroup = PermissionGroup.ULTRA; + break; + case ULTRA: + newGroup = PermissionGroup.HERO; + break; + case HERO: + newGroup = PermissionGroup.LEGEND; + break; + case LEGEND: + if (canPassLegend) + { + newGroup = PermissionGroup.TITAN; + } + break; + case TITAN: + if (canPassLegend) + { + newGroup = PermissionGroup.ETERNAL; + } + break; + default: + break; } return newGroup; @@ -68,7 +68,7 @@ public class RankReward extends Reward if (rewardType == RewardType.MYTHICAL_CHEST && _random.nextDouble() < 0.01) // 1 Percent { - group = _clientManager.getPermissionManager().getGroup("eternal"); + group = PermissionGroup.ETERNAL; } if (group == null) @@ -97,7 +97,7 @@ public class RankReward extends Reward @Override public boolean canGiveReward(Player player) { - return !_clientManager.Get(player).getPrimaryGroup().equals("eternal") && !_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("eternal")); + return !_clientManager.Get(player).getPrimaryGroup().equals("eternal") && !_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), PermissionGroup.ETERNAL); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java index 168c15de7..a986f6fd4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java @@ -2,6 +2,8 @@ package mineplex.core.serverConfig; import java.lang.reflect.Field; +import net.minecraft.server.v1_8_R3.PlayerList; + import org.bukkit.craftbukkit.v1_8_R3.CraftServer; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerLoginEvent; @@ -11,11 +13,11 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.serverdata.Region; import mineplex.serverdata.data.ServerGroup; import mineplex.serverdata.servers.ServerManager; -import net.minecraft.server.v1_8_R3.PlayerList; public class ServerConfiguration extends MiniPlugin { @@ -61,7 +63,7 @@ public class ServerConfiguration extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_STAFF_SERVER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_STAFF_SERVER_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index e1af4a22e..cfedaa4b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -20,6 +20,7 @@ import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTasks; @@ -88,10 +89,10 @@ public class StatsManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_STAT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(TIME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SET_LEVEL_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MASTER_BUILDERS_UNBAN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_STAT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(TIME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_LEVEL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MASTER_BUILDERS_UNBAN_COMMAND_PERMISSION), true, true); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java index 13fdc26b2..2e5402ef9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java @@ -1,8 +1,8 @@ package mineplex.core.status; import java.io.File; -import java.util.Arrays; import java.util.Collection; +import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -10,8 +10,11 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; +import com.google.common.collect.ImmutableSet; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.Constants; import mineplex.core.common.util.Callback; import mineplex.core.monitor.LagMeter; @@ -28,6 +31,7 @@ import mineplex.serverdata.servers.ServerRepository; public class ServerStatusManager extends MiniPlugin { + private static final Set DONOR_GROUPS = ImmutableSet.of(PermissionGroup.ULTRA, PermissionGroup.HERO, PermissionGroup.LEGEND, PermissionGroup.TITAN, PermissionGroup.ETERNAL); // The default timeout (in seconds) before the ServerStatus expires. public final int DEFAULT_SERVER_TIMEOUT = 30; @@ -170,7 +174,7 @@ public class ServerStatusManager extends MiniPlugin for (Player player : Bukkit.getOnlinePlayers()) { - if (Arrays.asList("ultra", "hero", "legend", "titan", "eternal").contains(_clientManager.Get(player).getPrimaryGroup().getIdentifier())) + if (DONOR_GROUPS.contains(_clientManager.Get(player).getPrimaryGroup())) { donorsOnline++; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java index 771714a9a..54491bbaf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java @@ -10,6 +10,12 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; + import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -20,6 +26,7 @@ import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -31,11 +38,6 @@ import mineplex.core.teamspeak.redis.TeamspeakLinkResponse; import mineplex.core.teamspeak.redis.TeamspeakUnlinkRequest; import mineplex.core.teamspeak.redis.TeamspeakUnlinkResponse; import mineplex.serverdata.commands.ServerCommandManager; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; @ReflectivelyCreateMiniPlugin public class TeamspeakManager extends MiniClientPlugin implements ILoginProcessor @@ -127,10 +129,10 @@ public class TeamspeakManager extends MiniClientPlugin impl { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(LINK_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(LIST_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(TEAMSPEAK_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(UNLINK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(LINK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(LIST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(TEAMSPEAK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(UNLINK_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java index 7311c504e..f656f2b27 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java @@ -72,7 +72,7 @@ public class Teleport extends MiniPlugin { runSync(() -> { - PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getRankIdentifier()); + PermissionGroup group = PermissionGroup.valueOf(command.getRankIdentifier()); Set on = new HashSet<>(); for (Player online : Bukkit.getOnlinePlayers()) { @@ -162,15 +162,15 @@ public class Teleport extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(FIND_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mc"), GroupPermission.of(FIND_MOD_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FIND_MOD_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("tm"), GroupPermission.of(FIND_TRAINEE_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FIND_TRAINEE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(TELEPORT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TELEPORT_LOCATION_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TELEPORT_OTHER_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TELEPORT_ALL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(FIND_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MC, GroupPermission.of(FIND_MOD_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIND_MOD_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TM, GroupPermission.of(FIND_TRAINEE_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIND_TRAINEE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(TELEPORT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TELEPORT_LOCATION_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TELEPORT_OTHER_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TELEPORT_ALL_COMMAND_PERMISSION), true, true); } @Override @@ -212,7 +212,7 @@ public class Teleport extends MiniPlugin return; } - RankLocate locate = new RankLocate(_serverName, sender.getName(), sender.getUniqueId(), group.getIdentifier()); + RankLocate locate = new RankLocate(_serverName, sender.getName(), sender.getUniqueId(), group.name()); locate.publish(); int id = getScheduler().runTaskLater(_plugin, () -> { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/ModLocateCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/ModLocateCommand.java index c2642c5f3..355328c56 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/ModLocateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/ModLocateCommand.java @@ -2,6 +2,7 @@ package mineplex.core.teleport.command; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.command.CommandBase; import mineplex.core.teleport.Teleport; @@ -15,6 +16,6 @@ public class ModLocateCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - Plugin.locateRank(caller, Plugin.getClientManager().getPermissionManager().getGroup("mod")); + Plugin.locateRank(caller, PermissionGroup.MOD); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TraineeLocateCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TraineeLocateCommand.java index 083e26889..cdaa8a4df 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TraineeLocateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TraineeLocateCommand.java @@ -2,6 +2,7 @@ package mineplex.core.teleport.command; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.command.CommandBase; import mineplex.core.teleport.Teleport; @@ -15,6 +16,6 @@ public class TraineeLocateCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - Plugin.locateRank(caller, Plugin.getClientManager().getPermissionManager().getGroup("trainee")); + Plugin.locateRank(caller, PermissionGroup.TRAINEE); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java index 5135c2a8f..317460416 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java @@ -10,6 +10,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; @@ -48,7 +49,7 @@ public class ThankManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(THANK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(THANK_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java index 5914f891a..212e7a37e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java @@ -36,7 +36,7 @@ public class PlayerScoreboard { _scoreboard.registerNewTeam("Vanished").setSuffix(C.cBlue + "*"); - for (PermissionGroup group : _manager.getClients().getPermissionManager().getGroups()) + for (PermissionGroup group : PermissionGroup.values()) { if (!group.canBePrimary()) { @@ -44,11 +44,11 @@ public class PlayerScoreboard } if (!group.getDisplay(false, false, false, false).isEmpty()) { - _scoreboard.registerNewTeam(group.getIdentifier()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); + _scoreboard.registerNewTeam(group.name()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); } else { - _scoreboard.registerNewTeam(group.getIdentifier()).setPrefix(""); + _scoreboard.registerNewTeam(group.name()).setPrefix(""); } } @@ -66,8 +66,8 @@ public class PlayerScoreboard continue; } - String rankName = _manager.getClients().Get(player).getRealOrDisguisedPrimaryGroup().getIdentifier(); - String otherRankName = _manager.getClients().Get(otherPlayer).getRealOrDisguisedPrimaryGroup().getIdentifier(); + String rankName = _manager.getClients().Get(player).getRealOrDisguisedPrimaryGroup().name(); + String otherRankName = _manager.getClients().Get(otherPlayer).getRealOrDisguisedPrimaryGroup().name(); //Add Other to Self _scoreboard.getTeam(otherRankName).addPlayer(otherPlayer); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java index 4289f775e..ebead132e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java @@ -7,6 +7,8 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; +import net.md_5.bungee.api.ChatColor; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -14,6 +16,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.Callback; import mineplex.core.inventory.InventoryManager; @@ -48,7 +51,6 @@ import mineplex.core.titles.tracks.standard.SweetToothTrack; import mineplex.core.titles.tracks.standard.TreasureHunterTrack; import mineplex.core.titles.tracks.standard.UnluckyTrack; import mineplex.core.titles.tracks.standard.WarriorTrack; -import net.md_5.bungee.api.ChatColor; @ReflectivelyCreateMiniPlugin public class TrackManager extends MiniPlugin @@ -168,22 +170,22 @@ public class TrackManager extends MiniPlugin { PermissionManager pm = _coreClientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(HAPPY_GARY_PERMISSION), true, true); - pm.setPermission(pm.getGroup("lt"), GroupPermission.of(LEADER_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TABLE_FLIP_PERMISSION), true, true); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(BUILDER_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BUILDER_PERMISSION), true, false); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BUILDER_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(MOD_PERMISSION), true, true); - pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(MOD_PERMISSION), true, false); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MOD_PERMISSION), true, true); - pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SR_MOD_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(TRAINEE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(TRAINEE_PERMISSION), true, false); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TRAINEE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(HAPPY_GARY_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LT, GroupPermission.of(LEADER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TABLE_FLIP_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(BUILDER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BUILDER_PERMISSION), true, false); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BUILDER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(MOD_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(MOD_PERMISSION), true, false); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MOD_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(SR_MOD_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(TRAINEE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(TRAINEE_PERMISSION), true, false); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TRAINEE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_TRACK_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(TRACK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_TRACK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(TRACK_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java index 1e2d785ee..0726a6dce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java @@ -11,6 +11,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.donation.DonationManager; @@ -46,7 +47,7 @@ public class TournamentManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(DEBUG_SHOP_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(DEBUG_SHOP_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java index 66a0fcdde..4ab193a74 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -1,6 +1,6 @@ package mineplex.core.treasure; -import java.awt.Color; +import java.awt.*; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; @@ -9,6 +9,9 @@ import java.util.Random; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction; + import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -16,6 +19,7 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -44,8 +48,6 @@ import mineplex.core.treasure.animation.LootMythicalAnimation; import mineplex.core.treasure.animation.LootRareAnimation; import mineplex.core.treasure.animation.LootUncommonAnimation; import mineplex.core.treasure.animation.TreasureRemoveAnimation; -import net.minecraft.server.v1_8_R3.BlockPosition; -import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction; public class Treasure { @@ -324,7 +326,7 @@ public class Treasure { if (rewardData instanceof RankRewardData) { - if (((RankRewardData)rewardData).getWonRank().getIdentifier().equals("titan")) + if (((RankRewardData)rewardData).getWonRank() == PermissionGroup.TITAN) { TitanChestGiveawayMessage message = new TitanChestGiveawayMessage(_player.getName(), _statusManager.getCurrentServerName()); message.publish(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java index dc28e0502..056d205ee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java @@ -34,6 +34,7 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; import mineplex.core.common.util.BukkitFuture; @@ -77,8 +78,8 @@ public class TwoFactorAuth extends MiniClientPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(USE_2FA_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RESET_2FA_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(USE_2FA_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESET_2FA_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java index 814279a15..502a978e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java @@ -20,6 +20,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -78,9 +79,9 @@ public class FileUpdater extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BVERSION_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RESTART_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qam"), GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BVERSION_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESTART_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QAM, GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java index 4893abe15..930a2c46d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java @@ -13,6 +13,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -43,7 +44,6 @@ import mineplex.core.account.event.PrimaryGroupUpdateEvent; import mineplex.core.account.permissions.GroupPermission; import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; -import mineplex.core.common.Pair; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -79,8 +79,8 @@ public class WebsiteLinkManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(LINK_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UNLINK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(LINK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UNLINK_COMMAND_PERMISSION), true, true); } public void unlink(Player sender, String target) @@ -110,11 +110,11 @@ public class WebsiteLinkManager extends MiniDbClientPlugin List remove = new ArrayList<>(); remove.add(POWER_PLAY_TAG_ID); remove.add(LINKED_TAG_ID); - for (PermissionGroup group : getClientManager().getPermissionManager().getGroups()) + for (PermissionGroup group : PermissionGroup.values()) { if (group.getForumId() != -1) { - remove.add(Integer.valueOf(group.getForumId())); + remove.add(group.getForumId()); } } String call = "action=editUser&user=" + user.username + "&custom_fields=mcAcctIdPC="; @@ -655,24 +655,24 @@ public class WebsiteLinkManager extends MiniDbClientPlugin @EventHandler public void handleRankSave(PrimaryGroupUpdateEvent event) { - Consumer>> dataCallback = (p) -> + BiConsumer> dataCallback = (userId, groups) -> { List remove = new ArrayList<>(); List add = new ArrayList<>(); - for (PermissionGroup group : getClientManager().getPermissionManager().getGroups()) + for (PermissionGroup group : PermissionGroup.values()) { - if (group.getForumId() != -1 && !event.getGroupIdentifier().equals(group.getIdentifier()) && !p.getRight().contains(group.getIdentifier())) + if (group.getForumId() != -1 && event.getGroup() != group && !groups.contains(group)) { - remove.add(Integer.valueOf(group.getForumId())); + remove.add(group.getForumId()); } } - PermissionGroup group = getClientManager().getPermissionManager().getGroup(event.getGroupIdentifier()); + PermissionGroup group = event.getGroup(); if (group.getForumId() != -1) { - add.add(Integer.valueOf(group.getForumId())); + add.add(group.getForumId()); } - refreshSiteTags(p.getLeft().intValue(), remove, add, false, () -> {}, false, () -> {}, false); + refreshSiteTags(userId, remove, add, false, () -> {}, false, () -> {}, false); }; runAsync(() -> { @@ -696,9 +696,9 @@ public class WebsiteLinkManager extends MiniDbClientPlugin return; } final int userId = id; - getClientManager().getRepository().fetchGroups(event.getAccountId(), pair -> + getClientManager().getRepository().fetchGroups(event.getAccountId(), (primaryName, additionalNames) -> { - dataCallback.accept(Pair.create(Integer.valueOf(userId), pair.getRight())); + dataCallback.accept(userId, additionalNames); }, () -> {}, false); }); } @@ -706,24 +706,24 @@ public class WebsiteLinkManager extends MiniDbClientPlugin @EventHandler public void handleRankSave(GroupAddEvent event) { - Consumer>> dataCallback = (p) -> + BiConsumer> dataCallback = (userId, groups) -> { List remove = new ArrayList<>(); List add = new ArrayList<>(); - for (PermissionGroup group : getClientManager().getPermissionManager().getGroups()) + for (PermissionGroup group : PermissionGroup.values()) { - if (group.getForumId() != -1 && !event.getGroupIdentifier().equals(group.getIdentifier()) && !p.getRight().contains(group.getIdentifier())) + if (group.getForumId() != -1 && event.getGroup() != group && !groups.contains(group)) { - remove.add(Integer.valueOf(group.getForumId())); + remove.add(group.getForumId()); } } - PermissionGroup group = getClientManager().getPermissionManager().getGroup(event.getGroupIdentifier()); + PermissionGroup group = event.getGroup(); if (group.getForumId() != -1) { - add.add(Integer.valueOf(group.getForumId())); + add.add(group.getForumId()); } - refreshSiteTags(p.getLeft().intValue(), remove, add, false, () -> {}, false, () -> {}, false); + refreshSiteTags(userId, remove, add, false, () -> {}, false, () -> {}, false); }; runAsync(() -> { @@ -747,12 +747,12 @@ public class WebsiteLinkManager extends MiniDbClientPlugin return; } final int userId = id; - getClientManager().getRepository().fetchGroups(event.getAccountId(), pair -> + getClientManager().getRepository().fetchGroups(event.getAccountId(), (primaryGroup, additionalGroups) -> { - Set groups = Sets.newHashSet(pair.getRight()); - groups.add(pair.getLeft()); - groups.remove(event.getGroupIdentifier()); - dataCallback.accept(Pair.create(Integer.valueOf(userId), groups)); + Set groups = new HashSet<>(additionalGroups); + groups.add(primaryGroup); + groups.remove(event.getGroup()); + dataCallback.accept(userId, groups); }, () -> {}, false); }); } @@ -760,19 +760,19 @@ public class WebsiteLinkManager extends MiniDbClientPlugin @EventHandler public void handleRankSave(GroupRemoveEvent event) { - Consumer>> dataCallback = (p) -> + BiConsumer> dataCallback = (userId, groups) -> { List remove = new ArrayList<>(); List add = new ArrayList<>(); - for (PermissionGroup group : getClientManager().getPermissionManager().getGroups()) + for (PermissionGroup group : PermissionGroup.values()) { - if (group.getForumId() != -1 && !p.getRight().contains(group.getIdentifier())) + if (group.getForumId() != -1 && !groups.contains(group)) { - remove.add(Integer.valueOf(group.getForumId())); + remove.add(group.getForumId()); } } - refreshSiteTags(p.getLeft().intValue(), remove, add, false, () -> {}, false, () -> {}, false); + refreshSiteTags(userId, remove, add, false, () -> {}, false, () -> {}, false); }; runAsync(() -> { @@ -796,11 +796,11 @@ public class WebsiteLinkManager extends MiniDbClientPlugin return; } final int userId = id; - getClientManager().getRepository().fetchGroups(event.getAccountId(), pair -> + getClientManager().getRepository().fetchGroups(event.getAccountId(), (primaryGroup, additionalGroups) -> { - Set groups = Sets.newHashSet(pair.getRight()); - groups.add(pair.getLeft()); - dataCallback.accept(Pair.create(Integer.valueOf(userId), groups)); + Set groups = Sets.newHashSet(additionalGroups); + groups.add(primaryGroup); + dataCallback.accept(userId, groups); }, () -> {}, false); }); } diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index 9e49ddbd9..ead50bbe4 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -149,30 +149,26 @@ public class Enjin extends MiniPlugin implements CommandExecutor { return false; } - - PermissionGroup c = _clientManager.getPermissionManager().getGroup(args[2]); - if (c == null) - { - c = _clientManager.getPermissionManager().getGroupFromLegacy(args[2]); - } + + PermissionGroup c = PermissionGroup.getGroup(args[2]).orElse(_clientManager.getPermissionManager().getGroupFromLegacy(args[2])); if (c == null) { return false; } - final PermissionGroup rank = _clientManager.getPermissionManager().getGroup(args[2]); + final PermissionGroup rank = PermissionGroup.valueOf(args[2]); _clientManager.loadClientByName(name, loadedClient -> { - if (rank.getIdentifier().equals("player") || loadedClient.getPrimaryGroup().getIdentifier().equals("player") || !_clientManager.getPermissionManager().inheritsFully(loadedClient.getPrimaryGroup(), rank) || loadedClient.getPrimaryGroup().equals(rank)) + if (rank == PermissionGroup.PLAYER || loadedClient.getPrimaryGroup() == PermissionGroup.PLAYER || !_clientManager.getPermissionManager().inheritsFully(loadedClient.getPrimaryGroup(), rank) || loadedClient.getPrimaryGroup().equals(rank)) { - _clientManager.setPrimaryGroup(client.getAccountId(), rank, () -> _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.getIdentifier() + "Permanent", 1, true)); + _clientManager.setPrimaryGroup(client.getAccountId(), rank, () -> _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.name() + "Permanent", 1, true)); - System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank.getIdentifier() + " " + "permanently."); + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank.name() + " " + "permanently."); } else { - System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank.getIdentifier() + " " + "permanently."); - _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.getIdentifier() + " Permanent", 1, false); + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank.name() + " " + "permanently."); + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.name() + " Permanent", 1, false); } }); diff --git a/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/ClansCompensation.java b/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/ClansCompensation.java index 6cce7e431..3fe3f2b1f 100644 --- a/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/ClansCompensation.java +++ b/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/ClansCompensation.java @@ -30,6 +30,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -83,7 +84,7 @@ public class ClansCompensation extends JavaPlugin implements Listener Bukkit.getPluginManager().registerEvents(this, this); { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMPENSATION_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMPENSATION_COMMAND_PERMISSION), true, true); } ClansManager.getInstance().addCommand(new CompensationCommand(ClansManager.getInstance(), this)); loadUUIDs(uuids -> diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index 2fade383f..9aea90546 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -7,6 +7,7 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -38,7 +39,7 @@ public class ClansAdmin { PermissionManager pm = Clans.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(USE_ADMIN_COMMANDS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(USE_ADMIN_COMMANDS_PERMISSION), true, true); } public void command(Player caller, String[] args) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 8bdfba5b5..658a31cf5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -45,6 +45,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestoreData; import mineplex.core.common.util.C; @@ -89,7 +90,7 @@ public class ClansGame extends MiniPlugin { PermissionManager pm = _clans.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(DUPE_ALERT_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(DUPE_ALERT_PERMISSION), true, true); } private void setupSafes() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index bebd7ead1..bff71b1c7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -43,6 +43,7 @@ import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; @@ -142,8 +143,8 @@ import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.item.ItemFactory; import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; @@ -495,27 +496,27 @@ public class ClansManager extends MiniClientPlugin implements IRelat { PermissionManager pm = _clientManager.getPermissionManager(); - pm.revokePermission(pm.getGroup("mod"), GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION), true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION), true, true); + pm.revokePermission(PermissionGroup.MOD, GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION), true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(CLANS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(ALLY_CHAT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(CLAN_CHAT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(MAP_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(SUICIDE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(REGION_CLEAR_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(SPEED_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SPEED_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FORCE_JOIN_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(CLANS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(ALLY_CHAT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(CLAN_CHAT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(MAP_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(SUICIDE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(REGION_CLEAR_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(SPEED_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SPEED_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FORCE_JOIN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("qam"), GroupPermission.of(AUTO_OP_PERMISSION), false, true); + pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); } - pm.setPermission(pm.getGroup("content"), GroupPermission.of(PREFIX_SHOWN_PERMISSION), true, true); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(PREFIX_SHOWN_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(PREFIX_SHOWN_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(PREFIX_SHOWN_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); } @Override @@ -1034,7 +1035,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat event.setCancelled(true); - System.out.println((clan == null ? "" : clan.getName()) + " " + _clientManager.Get(event.getPlayer()).getPrimaryGroup().getIdentifier() + " " + event.getPlayer().getName() + " " + event.getMessage()); + System.out.println((clan == null ? "" : clan.getName()) + " " + _clientManager.Get(event.getPlayer()).getPrimaryGroup().name() + " " + event.getPlayer().getName() + " " + event.getMessage()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java index 4696e517e..7774e6277 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java @@ -8,6 +8,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -43,7 +44,7 @@ public class AmplifierManager extends MiniPlugin { PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(AMPLIFIER_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(AMPLIFIER_COMMAND_PERMISSION), true, true); } /** diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index a8ccc4b49..794a5e2da 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -3,6 +3,8 @@ package mineplex.game.clans.clans.banners; import java.util.HashMap; import java.util.Map; +import net.minecraft.server.v1_8_R3.MinecraftServer; + import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Banner; @@ -25,6 +27,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -34,7 +37,6 @@ import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.banners.command.BannerCommand; import mineplex.game.clans.core.repository.ClanTerritory; -import net.minecraft.server.v1_8_R3.MinecraftServer; /** * Manager class for cosmetic clans banners @@ -63,8 +65,8 @@ public class BannerManager extends MiniPlugin { PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(BANNER_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BANNER_ACCESS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(BANNER_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BANNER_ACCESS_PERMISSION), true, true); } /** diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java index b720390e5..09e09b6fa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java @@ -18,6 +18,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; import mineplex.core.common.util.C; @@ -56,7 +57,7 @@ public class BoxManager extends MiniPlugin { PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(BOX_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(BOX_COMMAND_PERMISSION), true, true); } @EventHandler(priority=EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java index 2a6d807a3..88277b07c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import net.minecraft.server.v1_8_R3.EnumDirection; + import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -17,6 +19,7 @@ import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -36,7 +39,6 @@ import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanLeaveEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; import mineplex.game.clans.core.ClaimLocation; -import net.minecraft.server.v1_8_R3.EnumDirection; public class ClaimVisualizer extends MiniPlugin { @@ -68,7 +70,7 @@ public class ClaimVisualizer extends MiniPlugin { PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(VISUALIZE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(VISUALIZE_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java index f600cd3dc..ebf95ab6e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java @@ -21,6 +21,7 @@ import org.bukkit.potion.PotionEffectType; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -59,15 +60,15 @@ public class ClansFreezeManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(FREEZE_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("cma"), GroupPermission.of(FREEZE_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FREEZE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("cma"), GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(NOTIFY_PERMISSION), false, true); - pm.setPermission(pm.getGroup("cma"), GroupPermission.of(NOTIFY_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NOTIFY_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(FREEZE_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.CMA, GroupPermission.of(FREEZE_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FREEZE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.CMA, GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(NOTIFY_PERMISSION), false, true); + pm.setPermission(PermissionGroup.CMA, GroupPermission.of(NOTIFY_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NOTIFY_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeManager.java index 3a9ea7b47..f8ead4820 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeManager.java @@ -1,18 +1,20 @@ package mineplex.game.clans.clans.invsee; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilServer; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.invsee.commands.InvseeCommand; import mineplex.game.clans.clans.invsee.ui.InvseeInventory; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; public class InvseeManager extends MiniPlugin { @@ -31,8 +33,8 @@ public class InvseeManager extends MiniPlugin { PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(INVSEE_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(INVSEE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(INVSEE_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(INVSEE_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index 8e74774ad..7ccfa6b68 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -27,6 +27,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; import mineplex.core.common.Pair; @@ -156,9 +157,9 @@ public class MountManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(MOUNT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_MOUNT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MOUNT_SKIN_UNLOCK_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(MOUNT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_MOUNT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MOUNT_SKIN_UNLOCK_PERMISSION), true, true); } public DonationManager getDonationManager() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/ClansBlacklist.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/ClansBlacklist.java index e609a1985..92c984ab0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/ClansBlacklist.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/ClansBlacklist.java @@ -7,6 +7,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -36,8 +37,8 @@ public class ClansBlacklist extends MiniPlugin { PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(BLACKLIST_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BLACKLIST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(BLACKLIST_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BLACKLIST_COMMAND_PERMISSION), true, true); } // Fetch new blacklisted clans every 16 seconds (in case someone blacklists a clan name on a different server) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 5472ba7a0..78850294e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -35,6 +35,7 @@ import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.generator.VoidGenerator; import mineplex.core.common.util.C; @@ -105,13 +106,13 @@ public class NetherManager extends MiniPlugin { PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_CLOSE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_CREATE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_DELETE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_FORCE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_LIST_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_OPEN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_CLOSE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_CREATE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_DELETE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_FORCE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_LIST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_OPEN_COMMAND_PERMISSION), true, true); } private void begin() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java index 88674c53a..159bb7d3c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java @@ -20,6 +20,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -51,7 +52,7 @@ public class ObserverManager extends MiniPlugin { PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("helper"), GroupPermission.of(OBSERVE_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(OBSERVE_COMMAND_PERMISSION), false, true); } public void setObserver(Player player) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java index df959ce48..86cea47d7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java @@ -11,6 +11,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniClientPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.stats.StatsManager; import mineplex.core.task.TaskManager; @@ -39,7 +40,7 @@ public class Playtime extends MiniClientPlugin { PermissionManager pm = _statsManager.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(CLANS_TIME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(CLANS_TIME_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index a209bdeeb..a938f496d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -77,7 +77,7 @@ public class ClansPlayerScoreboard extends PlayerScoreboard { if (otherPlayer.getGameMode().equals(GameMode.CREATIVE)) { - String teamName = UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).getPrimaryGroup().getIdentifier() + "CREATIVE"); + String teamName = UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).getPrimaryGroup().name() + "CREATIVE"); Team team = scoreboard.getTeam(teamName); if (team == null) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index 1b6aae164..de999075a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -2,8 +2,21 @@ package mineplex.game.clans.clans.siege; import java.util.Stack; +import net.minecraft.server.v1_8_R3.Material; + +import org.bukkit.Location; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockPlaceEvent; + +import com.google.gson.Gson; + import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -25,17 +38,6 @@ import mineplex.game.clans.clans.siege.weapon.Cannon; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; -import net.minecraft.server.v1_8_R3.Material; - -import org.bukkit.Location; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Slime; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockPlaceEvent; - -import com.google.gson.Gson; public class SiegeManager extends MiniPlugin { @@ -100,7 +102,7 @@ public class SiegeManager extends MiniPlugin { PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_CANNON_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_CANNON_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index b0bc05f01..4896b68f5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -17,6 +17,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -71,7 +72,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement { PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(WAR_POINT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(WAR_POINT_COMMAND_PERMISSION), true, true); } public ClansManager getClansManager() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index a7ed0cde0..e5a0de948 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -14,6 +14,7 @@ import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; @@ -87,9 +88,9 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(WORLD_EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(STOP_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(WORLD_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(STOP_EVENT_COMMAND_PERMISSION), true, true); } public void addCommands() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java index 371f23b2f..38c7a1988 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java @@ -19,6 +19,7 @@ import org.bukkit.scheduler.BukkitTask; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; @@ -66,7 +67,7 @@ public class RaidManager extends MiniPlugin { PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_RAID_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_RAID_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index d13d69a66..38147e024 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -28,6 +28,7 @@ import org.bukkit.util.Vector; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -86,8 +87,8 @@ public class GoldManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_GOLD_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SET_GOLD_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_GOLD_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_GOLD_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java index 3b6d1333d..d042a1bfc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java @@ -20,6 +20,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent; @@ -80,7 +81,7 @@ public class FieldBlock extends MiniPlugin { PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FIELD_BLOCK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIELD_BLOCK_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldMonster.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldMonster.java index bfd4e64eb..210906ccf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldMonster.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldMonster.java @@ -14,6 +14,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; @@ -55,7 +56,7 @@ public class FieldMonster extends MiniPlugin { PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FIELD_MONSTER_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIELD_MONSTER_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java index d113291e7..4a71f0793 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java @@ -21,6 +21,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent; @@ -69,7 +70,7 @@ public class FieldOre extends MiniPlugin { PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FIELD_ORE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIELD_ORE_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 035c2dc75..e65f48acf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -10,6 +10,14 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import net.minecraft.server.v1_8_R3.NBTBase; +import net.minecraft.server.v1_8_R3.NBTTagByte; +import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.NBTTagString; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; +import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; + import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; @@ -30,6 +38,7 @@ import com.google.gson.JsonSyntaxException; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; @@ -79,13 +88,6 @@ import mineplex.game.clans.items.runes.RuneManager; import mineplex.game.clans.items.smelting.SmeltingListener; import mineplex.game.clans.items.ui.GearShop; import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; -import net.minecraft.server.v1_8_R3.NBTBase; -import net.minecraft.server.v1_8_R3.NBTTagByte; -import net.minecraft.server.v1_8_R3.NBTTagCompound; -import net.minecraft.server.v1_8_R3.NBTTagString; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; -import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; /** * Handles converting legendary itemstacks to their respective CustomItem objects @@ -256,8 +258,8 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RUNE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GEAR_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RUNE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GEAR_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java index f4f73ea66..264af47d9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -3,6 +3,8 @@ package mineplex.game.clans.restart; import java.util.Calendar; import java.util.LinkedList; +import net.minecraft.server.v1_8_R3.MinecraftServer; + import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -15,6 +17,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -32,7 +35,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; -import net.minecraft.server.v1_8_R3.MinecraftServer; public class RestartManager extends MiniPlugin { @@ -82,9 +84,9 @@ public class RestartManager extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("qam"), GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RESTART_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.QAM, GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESTART_COMMAND_PERMISSION), true, true); } private boolean inRestartZone(int hour) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java index e2474a504..a28d13a39 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chat.Chat; import mineplex.core.chat.FilterPriority; @@ -91,21 +92,21 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("player"), GroupPermission.of(TUTORIAL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(TUTORIAL_COMMAND_PERMISSION), true, true); } else { - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TUTORIAL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TUTORIAL_COMMAND_PERMISSION), true, true); } if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("player"), GroupPermission.of(FINISH_TUTORIAL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(FINISH_TUTORIAL_COMMAND_PERMISSION), true, true); } else { - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FINISH_TUTORIAL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FINISH_TUTORIAL_COMMAND_PERMISSION), true, true); } - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(START_TUTORIAL_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(START_TUTORIAL_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java index e49e3ea71..70061c229 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java @@ -18,6 +18,7 @@ import com.google.common.collect.Lists; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -38,6 +39,8 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.servers.ServerManager; +import static mineplex.core.account.permissions.GroupPermission.of; + /** * Server selection controller for clans */ @@ -74,9 +77,9 @@ public class ClansTransferManager extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(STAFF_PAGE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(ALLOW_HARDCORE_PERMISSION), true, true); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, of(STAFF_PAGE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(ALLOW_HARDCORE_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); } /** diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java index 913d5f6e4..cfa0be0c5 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java @@ -11,6 +11,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -48,9 +49,9 @@ public class ForcefieldManager extends MiniPlugin { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), true, true); - pm.setPermission(pm.getGroup("eventmod"), GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FORCEFIELD_RADIUS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), true, true); + pm.setPermission(PermissionGroup.EVENTMOD, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FORCEFIELD_RADIUS_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index cba2f1698..fdf2e173f 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -6,6 +6,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.HoverEvent.Action; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityPlayer; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -124,12 +131,6 @@ import mineplex.core.youtube.YoutubeManager; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.condition.ConditionManager; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.HoverEvent.Action; -import net.md_5.bungee.api.chat.TextComponent; -import net.minecraft.server.v1_8_R3.EntityInsentient; -import net.minecraft.server.v1_8_R3.EntityPlayer; /** * Main manager for clans hub @@ -281,7 +282,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter @Override public void setup(MineplexScoreboard scoreboard) { - for (PermissionGroup group : _clientManager.getPermissionManager().getGroups()) + for (PermissionGroup group : PermissionGroup.values()) { if (!group.canBePrimary()) { @@ -289,11 +290,11 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter } if (!group.getDisplay(false, false, false, false).isEmpty()) { - scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); + scoreboard.getHandle().registerNewTeam(group.name()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); } else { - scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(""); + scoreboard.getHandle().registerNewTeam(group.name()).setPrefix(""); } } @@ -346,7 +347,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(group.getIdentifier()).addEntry(playerName); + scoreboard.getHandle().getTeam(group.name()).addEntry(playerName); } if (get(player) != null) @@ -354,7 +355,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter for (Player player1 : Bukkit.getOnlinePlayers()) { group = _clientManager.Get(player1).getRealOrDisguisedPrimaryGroup(); - get(player).getHandle().getTeam(group.getIdentifier()).addEntry(player1.getName()); + get(player).getHandle().getTeam(group.name()).addEntry(player1.getName()); } } } @@ -368,7 +369,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(group.getIdentifier()).removeEntry(playerName); + scoreboard.getHandle().getTeam(group.name()).removeEntry(playerName); } } @@ -404,17 +405,17 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GADGET_TOGGLE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GAMEMODE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GADGET_TOGGLE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GAMEMODE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("qam"), GroupPermission.of(AUTO_OP_PERMISSION), false, true); + pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); } - pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(VANISH_PERMISSION), false, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(VANISH_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SPAWN_PM_PERMISSION), true, true); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(VANISH_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(VANISH_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SPAWN_PM_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); } @Override @@ -727,7 +728,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter if (event.getType() != UpdateType.TICK) return; - Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("player")).forEach(player -> + Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.Get(player).getPrimaryGroup() == PermissionGroup.PLAYER).forEach(player -> { UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive perks!", player); }); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java index de3bd0897..cc862285f 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java @@ -8,6 +8,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; @@ -40,7 +41,7 @@ public class HubVisibilityManager extends MiniPlugin { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_INVISIBILITY_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_INVISIBILITY_PERMISSION), true, true); } /** diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCreationPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCreationPage.java index 2988cb333..4a369dfa3 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCreationPage.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCreationPage.java @@ -14,9 +14,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import mineplex.core.Managers; -import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; @@ -42,15 +40,12 @@ public class SalesAnnouncementCreationPage implements Listener private void setup() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - PermissionGroup[] ranks = pm.getGroups().toArray(new PermissionGroup[pm.getGroups().size()]); int slot = 0; - for (int i = 0; i < ranks.length; i++) + for (PermissionGroup group : PermissionGroup.values()) { - PermissionGroup rank = ranks[i]; - if (rank.canBePrimary()) + if (group.canBePrimary()) { - _buttons.put(slot++, new RankSelectionButton(rank, this)); + _buttons.put(slot++, new RankSelectionButton(group, this)); } } _buttons.put(31, new RankSelectionFinalizeButton(this)); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java index ea20a9265..2d4a974a5 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java @@ -47,7 +47,7 @@ public class SalesAnnouncementManager extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); } public Map getLoadedAnnouncements() diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java index 41b50f1e6..9504c75ec 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java @@ -66,21 +66,13 @@ public class SalesAnnouncementRepository extends RepositoryBase { for (String rankStr : rankString.split(",")) { - PermissionGroup group = _pm.getGroup(rankStr); - if (group == null) - { - group = _pm.getGroupFromLegacy(rankStr); - } + PermissionGroup group = PermissionGroup.valueOf(rankStr); ranks.add(group); } } else { - PermissionGroup group = _pm.getGroup(rankString); - if (group == null) - { - group = _pm.getGroupFromLegacy(rankString); - } + PermissionGroup group = PermissionGroup.valueOf(rankString); ranks.add(group); } PermissionGroup[] displayTo = ranks.toArray(new PermissionGroup[ranks.size()]); @@ -114,11 +106,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { for (String rankStr : rankString.split(",")) { - PermissionGroup group = _pm.getGroup(rankStr); - if (group == null) - { - group = _pm.getGroupFromLegacy(rankStr); - } + PermissionGroup group = PermissionGroup.valueOf(rankStr); ranks.add(group); } } @@ -135,7 +123,7 @@ public class SalesAnnouncementRepository extends RepositoryBase String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); - final SalesAnnouncementData data = new SalesAnnouncementData(Integer.valueOf(aId), displayTo, message, enabled); + final SalesAnnouncementData data = new SalesAnnouncementData(aId, displayTo, message, enabled); runSync(() -> { callback.run(data); @@ -149,10 +137,10 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - String rankStr = displayTo[0].getIdentifier(); + StringBuilder rankStr = new StringBuilder(displayTo[0].name()); for (int i = 1; i < displayTo.length; i++) { - rankStr += ("," + displayTo[i].getIdentifier()); + rankStr.append(",").append(displayTo[i].name()); } executeInsert(INSERT_ANNOUNCEMENT, resultSet -> { @@ -165,7 +153,7 @@ public class SalesAnnouncementRepository extends RepositoryBase runSync(() -> callback.run(data)); } } - }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans)); + }, new ColumnVarChar("ranks", 250, rankStr.toString()), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans)); }); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index e360404d7..73a9eb0f2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -7,6 +7,13 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.HoverEvent.Action; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityPlayer; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -138,12 +145,6 @@ import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.condition.ConditionManager; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.HoverEvent.Action; -import net.md_5.bungee.api.chat.TextComponent; -import net.minecraft.server.v1_8_R3.EntityInsentient; -import net.minecraft.server.v1_8_R3.EntityPlayer; public class HubManager extends MiniClientPlugin implements IChatMessageFormatter { @@ -313,7 +314,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess @Override public void setup(MineplexScoreboard scoreboard) { - for (PermissionGroup group : _clientManager.getPermissionManager().getGroups()) + for (PermissionGroup group : PermissionGroup.values()) { if (!group.canBePrimary()) { @@ -321,11 +322,11 @@ public class HubManager extends MiniClientPlugin implements IChatMess } if (!group.getDisplay(false, false, false, false).isEmpty()) { - scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); + scoreboard.getHandle().registerNewTeam(group.name()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); } else { - scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(""); + scoreboard.getHandle().registerNewTeam(group.name()).setPrefix(""); } } @@ -387,7 +388,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(group.getIdentifier()).addEntry(playerName); + scoreboard.getHandle().getTeam(group.name()).addEntry(playerName); } if (get(player) != null) @@ -395,7 +396,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess for (Player player1 : Bukkit.getOnlinePlayers()) { group = _clientManager.Get(player1).getRealOrDisguisedPrimaryGroup(); - get(player).getHandle().getTeam(group.getIdentifier()).addEntry(player1.getName()); + get(player).getHandle().getTeam(group.name()).addEntry(player1.getName()); } } } @@ -409,7 +410,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(group.getIdentifier()).removeEntry(playerName); + scoreboard.getHandle().getTeam(group.name()).removeEntry(playerName); } } @@ -445,21 +446,21 @@ public class HubManager extends MiniClientPlugin implements IChatMess { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GADGET_TOGGLE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GAMEMODE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NEWS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GADGET_TOGGLE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GAMEMODE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NEWS_COMMAND_PERMISSION), true, true); if (UtilServer.isDevServer() || UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qam"), GroupPermission.of(AUTO_OP_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); } else { - pm.setPermission(pm.getGroup("lt"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LT, GroupPermission.of(AUTO_OP_PERMISSION), true, true); } - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(VANISH_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SPAWN_PM_PERMISSION), true, true); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(VANISH_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SPAWN_PM_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java index 5bb966c14..5bd47f2a0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java @@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -44,7 +45,7 @@ public class AdminMountManager extends MiniPlugin private void generatePermissions() { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("lt"), GroupPermission.of(HORSE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LT, GroupPermission.of(HORSE_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java index df2f47e12..009151aaf 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java @@ -30,6 +30,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.Achievement; import mineplex.core.blockrestore.BlockRestore; @@ -169,7 +170,7 @@ public class AlienInvasion extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TOGGLE_ANIMATION_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TOGGLE_ANIMATION_COMMAND_PERMISSION), true, true); } public void startAnimation() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java index a28e73247..417148aa6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java @@ -28,6 +28,7 @@ import mineplex.core.Managers; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -103,7 +104,7 @@ public class EasterEggHunt extends MiniDbClientPlugin { PermissionManager pm = getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ADD_EGG_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ADD_EGG_COMMAND_PERMISSION), true, true); } private String vecToStr(Vector vec) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index 52292ffaa..05e8f124d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -45,9 +46,9 @@ public class ForcefieldManager extends MiniPlugin { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), true, true); - pm.setPermission(pm.getGroup("eventmod"), GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), false, true); - pm.setPermission(pm.getGroup("lt"), GroupPermission.of(FORCEFIELD_RADIUS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), true, true); + pm.setPermission(PermissionGroup.EVENTMOD, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), false, true); + pm.setPermission(PermissionGroup.LT, GroupPermission.of(FORCEFIELD_RADIUS_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index c7e5f67af..9fb687c65 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -1,8 +1,6 @@ package mineplex.hub.modules; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; +import java.awt.*; import java.awt.font.FontRenderContext; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -27,6 +25,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.C; @@ -76,7 +75,7 @@ public class NewYearCountdown extends MiniPlugin private void generatePermissions() { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NEW_YEARS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NEW_YEARS_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCreationPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCreationPage.java index 55e458625..f33823cbb 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCreationPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCreationPage.java @@ -14,9 +14,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import mineplex.core.Managers; -import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; @@ -42,12 +40,9 @@ public class SalesAnnouncementCreationPage implements Listener private void setup() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - PermissionGroup[] ranks = pm.getGroups().toArray(new PermissionGroup[pm.getGroups().size()]); int slot = 0; - for (int i = 0; i < ranks.length; i++) + for (PermissionGroup rank : PermissionGroup.values()) { - PermissionGroup rank = ranks[i]; if (rank.canBePrimary()) { _buttons.put(slot++, new RankSelectionButton(rank, this)); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java index 331be8c18..fd741a6ef 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java @@ -47,7 +47,7 @@ public class SalesAnnouncementManager extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); } public Map getLoadedAnnouncements() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java index fdeb59602..3213c47ea 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java @@ -66,21 +66,13 @@ public class SalesAnnouncementRepository extends RepositoryBase { for (String rankStr : rankString.split(",")) { - PermissionGroup group = _pm.getGroup(rankStr); - if (group == null) - { - group = _pm.getGroupFromLegacy(rankStr); - } + PermissionGroup group = PermissionGroup.valueOf(rankStr); ranks.add(group); } } else { - PermissionGroup group = _pm.getGroup(rankString); - if (group == null) - { - group = _pm.getGroupFromLegacy(rankString); - } + PermissionGroup group = PermissionGroup.valueOf(rankString); ranks.add(group); } PermissionGroup[] displayTo = ranks.toArray(new PermissionGroup[ranks.size()]); @@ -114,21 +106,13 @@ public class SalesAnnouncementRepository extends RepositoryBase { for (String rankStr : rankString.split(",")) { - PermissionGroup group = _pm.getGroup(rankStr); - if (group == null) - { - group = _pm.getGroupFromLegacy(rankStr); - } + PermissionGroup group = PermissionGroup.valueOf(rankStr); ranks.add(group); } } else { - PermissionGroup group = _pm.getGroup(rankString); - if (group == null) - { - group = _pm.getGroupFromLegacy(rankString); - } + PermissionGroup group = PermissionGroup.valueOf(rankString); ranks.add(group); } PermissionGroup[] displayTo = ranks.toArray(new PermissionGroup[ranks.size()]); @@ -149,10 +133,10 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - String rankStr = displayTo[0].getIdentifier(); + StringBuilder rankStr = new StringBuilder(displayTo[0].name()); for (int i = 1; i < displayTo.length; i++) { - rankStr += ("," + displayTo[i].getIdentifier()); + rankStr.append(",").append(displayTo[i].name()); } executeInsert(INSERT_ANNOUNCEMENT, resultSet -> { @@ -165,7 +149,7 @@ public class SalesAnnouncementRepository extends RepositoryBase runSync(() -> callback.run(data)); } } - }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans)); + }, new ColumnVarChar("ranks", 250, rankStr.toString()), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans)); }); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java index 8a0852c7d..48c6583da 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java @@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.Color; @@ -48,7 +49,7 @@ public class NotificationManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(NOTIFICATION_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(NOTIFICATION_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 79b1c2e4f..31be69ab3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -28,6 +28,7 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.boosters.BoosterManager; import mineplex.core.common.util.C; @@ -127,9 +128,9 @@ public class ServerManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(FEATURE_SERVER_PERMISSION), true, true); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(FEATURE_SERVER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(FEATURE_SERVER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(FEATURE_SERVER_PERMISSION), true, true); } @EventHandler(priority = EventPriority.LOW) @@ -358,7 +359,7 @@ public class ServerManager extends MiniPlugin try { - serverInfo.HostRank = _clientManager.getPermissionManager().getGroup(identifier); + serverInfo.HostRank = PermissionGroup.valueOf(identifier); } catch (Exception e) { diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java index eb5afa930..22e92fad3 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClassManager.java @@ -18,6 +18,7 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilPlayer; @@ -97,7 +98,7 @@ public class ClassManager extends MiniClientPlugin implements IClas { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(VIEW_OTHER_SKILLS), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(VIEW_OTHER_SKILLS), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java index a8f43184a..b882bfd25 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java @@ -6,6 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.Achievement; import mineplex.core.achievement.AchievementManager; @@ -41,8 +42,8 @@ public class ClassShopManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SKILL_UNLOCK_PERMISSION), true, true); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(SKILL_UNLOCK_LEGACY_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SKILL_UNLOCK_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(SKILL_UNLOCK_LEGACY_PERMISSION), true, true); } public ClassManager GetClassManager() diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 6d6c95db8..6fa7bb982 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -30,6 +30,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -90,11 +91,11 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("support"), GroupPermission.of(CHECK_BONUS_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("support"), GroupPermission.of(CHECK_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("support"), GroupPermission.of(CHECK_OWNS_PACKAGE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("support"), GroupPermission.of(LIST_PPC_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("support"), GroupPermission.of(JOIN_SERVER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(CHECK_BONUS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(CHECK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(CHECK_OWNS_PACKAGE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(LIST_PPC_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(JOIN_SERVER_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index bac2330f6..376524a48 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -6,6 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.NautHashMap; @@ -21,6 +22,7 @@ import mineplex.staffServer.salespackage.salespackages.AncientChest; import mineplex.staffServer.salespackage.salespackages.ApplyKits; import mineplex.staffServer.salespackage.salespackages.ClanBannerEditor; import mineplex.staffServer.salespackage.salespackages.ClanBannerUsage; +import mineplex.staffServer.salespackage.salespackages.ClansBox; import mineplex.staffServer.salespackage.salespackages.Coins; import mineplex.staffServer.salespackage.salespackages.DefaultRank; import mineplex.staffServer.salespackage.salespackages.FreedomChest; @@ -40,7 +42,6 @@ import mineplex.staffServer.salespackage.salespackages.OmegaChest; import mineplex.staffServer.salespackage.salespackages.Pet; import mineplex.staffServer.salespackage.salespackages.PowerPlayClub; import mineplex.staffServer.salespackage.salespackages.RuneAmplifier; -import mineplex.staffServer.salespackage.salespackages.ClansBox; import mineplex.staffServer.salespackage.salespackages.SalesPackageBase; import mineplex.staffServer.salespackage.salespackages.SpringChest; import mineplex.staffServer.salespackage.salespackages.StPatricksChest; @@ -127,8 +128,8 @@ public class SalesPackageManager extends MiniPlugin { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("support"), GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("support"), GroupPermission.of(DISPLAY_PACKAGE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(DISPLAY_PACKAGE_COMMAND_PERMISSION), true, true); } private void addSalesPackage(SalesPackageBase salesPackage) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java index f7f290025..9c41d9752 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java @@ -35,7 +35,7 @@ public class RankCommand extends CommandBase if (ACCEPTED_RANKS.contains(rank)) { - PermissionGroup group = Plugin.getClientManager().getPermissionManager().getGroup(rank); + PermissionGroup group = PermissionGroup.valueOf(rank); Plugin.runAsync(() -> { UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); @@ -44,13 +44,13 @@ public class RankCommand extends CommandBase { Plugin.runSync(() -> { - if (id.intValue() == -1) + if (id == -1) { UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not find " + F.elem(playerName) + "!")); } else { - Plugin.getClientManager().setPrimaryGroup(id.intValue(), group, () -> UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(playerName) + "'s rank has been updated to " + rank + "!"))); + Plugin.getClientManager().setPrimaryGroup(id, group, () -> UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(playerName) + "'s rank has been updated to " + rank + "!"))); } }); }); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 7bed577bc..520fa7152 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -5,6 +5,8 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Set; +import net.minecraft.server.v1_8_R3.EntityLiving; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -125,6 +127,7 @@ import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; import mineplex.serverdata.Region; + import nautilus.game.arcade.addons.SoupAddon; import nautilus.game.arcade.booster.GameBoosterManager; import nautilus.game.arcade.command.CancelNextGameCommand; @@ -165,7 +168,6 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; -import net.minecraft.server.v1_8_R3.EntityLiving; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -428,7 +430,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(client.getRealOrDisguisedPrimaryGroup().getIdentifier()).addEntry(playerName); + scoreboard.getHandle().getTeam(client.getRealOrDisguisedPrimaryGroup().name()).addEntry(playerName); } Player player = Bukkit.getPlayerExact(playerName); @@ -439,7 +441,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { client = GetClients().Get(player1); - get(player).getHandle().getTeam(client.getRealOrDisguisedPrimaryGroup().getIdentifier()).addEntry(player1.getName()); + get(player).getHandle().getTeam(client.getRealOrDisguisedPrimaryGroup().name()).addEntry(player1.getName()); } } @@ -474,14 +476,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(client.getRealOrDisguisedPrimaryGroup().getIdentifier()).removeEntry(playerName); + scoreboard.getHandle().getTeam(client.getRealOrDisguisedPrimaryGroup().name()).removeEntry(playerName); } } @Override public void setup(MineplexScoreboard scoreboard) { - for (PermissionGroup group : _clientManager.getPermissionManager().getGroups()) + for (PermissionGroup group : PermissionGroup.values()) { if (!group.canBePrimary()) { @@ -489,11 +491,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation } if (!group.getDisplay(false, false, false, false).isEmpty()) { - scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); + scoreboard.getHandle().registerNewTeam(group.name()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); } else { - scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(""); + scoreboard.getHandle().registerNewTeam(group.name()).setPrefix(""); } } @@ -614,44 +616,44 @@ public class ArcadeManager extends MiniPlugin implements IRelation { PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(USE_MENU_DURING_GAME_PERMISSION), true, true); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(USE_MENU_DURING_GAME_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(NEXT_BEST_GAME_PERMISSION), true, true); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(KIT_UNLOCK_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(TAUNT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SET_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(USE_MENU_DURING_GAME_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(USE_MENU_DURING_GAME_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(NEXT_BEST_GAME_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(KIT_UNLOCK_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(TAUNT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(SET_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(START_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("maplead"), GroupPermission.of(GAME_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("maplead"), GroupPermission.of(SET_GAME_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("maplead"), GroupPermission.of(START_GAME_COMMAND_PERMISSION), false, true); - pm.setPermission(pm.getGroup("maplead"), GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(SET_GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(START_GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MAPLEAD, GroupPermission.of(GAME_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.MAPLEAD, GroupPermission.of(SET_GAME_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.MAPLEAD, GroupPermission.of(START_GAME_COMMAND_PERMISSION), false, true); + pm.setPermission(PermissionGroup.MAPLEAD, GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), false, true); } if (UtilServer.isTestServer() || UtilServer.isDevServer()) { - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); - pm.setPermission(pm.getGroup("qam"), GroupPermission.of(AUTO_OP_PERMISSION), false, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); } else { - pm.setPermission(pm.getGroup("lt"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LT, GroupPermission.of(AUTO_OP_PERMISSION), true, true); } - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(KIT_ACCESS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(FEATURED_SERVER_PERMISSION), true, true); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(FEATURED_SERVER_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(INFORM_RANKED_MODERATION_POTENTIAL_PERMISSION), true, true); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_FULL_STAFF_PERMISSION), true, true); - pm.setPermission(pm.getGroup("builder"), GroupPermission.of(BYPASS_WHITELIST_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_WHITELIST_PERMISSION), false, false); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_MPS_WHITELIST_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(KIT_ACCESS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(FEATURED_SERVER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(FEATURED_SERVER_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(INFORM_RANKED_MODERATION_POTENTIAL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_FULL_STAFF_PERMISSION), true, true); + pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(BYPASS_WHITELIST_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_WHITELIST_PERMISSION), false, false); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_MPS_WHITELIST_PERMISSION), true, true); } @Override @@ -1000,7 +1002,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation if (_gameHostManager.isPrivateServer() && _gameHostManager.hasPermission(GroupPermission.of(FEATURED_SERVER_PERMISSION))) { - extrainformation += "|HostRank." + _gameHostManager.getHostRank().getIdentifier(); + extrainformation += "|HostRank." + _gameHostManager.getHostRank().name(); } //Always Joinable /*if (_game != null && _game.JoinInProgress) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java index f0fcc170f..76cba4ca7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java @@ -3,21 +3,22 @@ package nautilus.game.arcade.game; import org.bukkit.entity.Player; import mineplex.core.Managers; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.command.CommandBase; import nautilus.game.arcade.ArcadeManager; public abstract class DebugCommand extends CommandBase { - private final String _defaultGroup; + private final PermissionGroup _defaultGroup; - public DebugCommand(String commandName, String permission, String defaultGroup) + public DebugCommand(String commandName, String permission, PermissionGroup defaultGroup) { super(Managers.get(ArcadeManager.class), permission, commandName); _defaultGroup = defaultGroup; } - public String getDefaultGroup() + public PermissionGroup getDefaultGroup() { return _defaultGroup; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 94e6dc7ca..000f9d739 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -13,6 +13,9 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; +import net.minecraft.server.v1_8_R3.EntityItem; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; + import org.apache.commons.lang3.tuple.Triple; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -46,6 +49,7 @@ import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; import mineplex.core.Managers; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; import mineplex.core.arcadeevents.CoreGameStartEvent; @@ -79,6 +83,7 @@ import mineplex.core.utils.UtilGameProfile; import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; + import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -121,8 +126,6 @@ import nautilus.game.arcade.stats.StatTracker; import nautilus.game.arcade.stats.WinStatTracker; import nautilus.game.arcade.wineffect.WinEffectManager; import nautilus.game.arcade.world.WorldData; -import net.minecraft.server.v1_8_R3.EntityItem; -import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; public abstract class Game extends ListenerComponent implements Lifetimed { @@ -534,10 +537,10 @@ public abstract class Game extends ListenerComponent implements Lifetimed public void registerDebugCommand(DebugCommand debugCommand) { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup(debugCommand.getDefaultGroup()), debugCommand.getPermission(), true, true); + pm.setPermission(debugCommand.getDefaultGroup(), debugCommand.getPermission(), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("qa"), debugCommand.getPermission(), true, true); + pm.setPermission(PermissionGroup.QA, debugCommand.getPermission(), true, true); } _debugCommands.add(debugCommand); for (String string : debugCommand.Aliases()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index 7dec96c42..ece542833 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -1,37 +1,29 @@ package nautilus.game.arcade.game.games.bridge; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.explosion.ExplosionEvent; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.DebugCommand; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation; -import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimationType; -import nautilus.game.arcade.game.games.bridge.animation.custom.CustomBridgeAnimation; -import nautilus.game.arcade.game.games.bridge.animation.custom.RadiusCustomBridgeAnimation; -import nautilus.game.arcade.game.games.bridge.animation.custom.RandomCustomBridgeAnimation; -import nautilus.game.arcade.game.games.bridge.kits.*; -import nautilus.game.arcade.game.modules.compass.CompassModule; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.perks.PerkBomber; -import nautilus.game.arcade.ore.OreHider; -import nautilus.game.arcade.ore.OreObsfucation; -import nautilus.game.arcade.stats.*; -import org.bukkit.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Chest; -import org.bukkit.entity.*; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Pig; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; @@ -53,8 +45,59 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; -import java.util.*; -import java.util.concurrent.TimeUnit; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.explosion.ExplosionEvent; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation; +import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimationType; +import nautilus.game.arcade.game.games.bridge.animation.custom.CustomBridgeAnimation; +import nautilus.game.arcade.game.games.bridge.animation.custom.RadiusCustomBridgeAnimation; +import nautilus.game.arcade.game.games.bridge.animation.custom.RandomCustomBridgeAnimation; +import nautilus.game.arcade.game.games.bridge.kits.KitApple; +import nautilus.game.arcade.game.games.bridge.kits.KitArcher; +import nautilus.game.arcade.game.games.bridge.kits.KitBerserker; +import nautilus.game.arcade.game.games.bridge.kits.KitBomber; +import nautilus.game.arcade.game.games.bridge.kits.KitBrawler; +import nautilus.game.arcade.game.games.bridge.kits.KitDestructor; +import nautilus.game.arcade.game.games.bridge.kits.KitMiner; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.perks.PerkBomber; +import nautilus.game.arcade.ore.OreHider; +import nautilus.game.arcade.ore.OreObsfucation; +import nautilus.game.arcade.stats.BridgesSniperStatTracker; +import nautilus.game.arcade.stats.DeathBomberStatTracker; +import nautilus.game.arcade.stats.FoodForTheMassesStatTracker; +import nautilus.game.arcade.stats.KillFastStatTracker; +import nautilus.game.arcade.stats.TntMinerStatTracker; public class Bridge extends TeamGame implements OreObsfucation { @@ -226,7 +269,7 @@ public class Bridge extends TeamGame implements OreObsfucation } } - registerDebugCommand(new DebugCommand("bridge", "mineplex.arcade.bridge.bridge", "admin") + registerDebugCommand(new DebugCommand("bridge", "mineplex.arcade.bridge.bridge", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) @@ -236,7 +279,7 @@ public class Bridge extends TeamGame implements OreObsfucation } }); - registerDebugCommand(new DebugCommand("bridgeinfo", "mineplex.arcade.bridge.bridgeinfo", "admin") + registerDebugCommand(new DebugCommand("bridgeinfo", "mineplex.arcade.bridge.bridgeinfo", PermissionGroup.ADMIN) { @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java index 8cd63ec27..b2db7e432 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java @@ -26,6 +26,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -42,6 +43,7 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -119,10 +121,10 @@ public class CaptureTheFlag extends TeamGame { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION), true, true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index e846927cc..bdc549651 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -40,6 +40,7 @@ import org.bukkit.potion.PotionEffectType; import mineplex.core.MiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -62,6 +63,7 @@ import mineplex.core.mount.Mount; import mineplex.core.punish.PunishClient; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.bridge.Bridge; @@ -103,10 +105,10 @@ public class EventModule extends MiniPlugin { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SET_HOST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_HOST_COMMAND_PERMISSION), true, true); if (_plugin.getConfig().getString("serverstatus.name").equals("SMTestServer-1")) { - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(SET_HOST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(SET_HOST_COMMAND_PERMISSION), true, true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index a53c3f9f3..27aa0cfaf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -21,6 +21,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.Managers; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.Pair; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -35,6 +36,7 @@ import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; import mineplex.minecraft.game.core.combat.DeathMessageType; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -160,7 +162,7 @@ public class Moba extends TeamGame .setGiveCompassToAlive(false) .register(this); - registerDebugCommand(new DebugCommand("kit", "mineplex.arcade.moba.kit", "admin") + registerDebugCommand(new DebugCommand("kit", "mineplex.arcade.moba.kit", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index cfcbacf36..5c9e6370b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -8,6 +8,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; @@ -39,7 +40,7 @@ public class GoldManager implements Listener _playerGold = new HashMap<>(); - host.registerDebugCommand(new DebugCommand("gold", "mineplex.arcade.moba.gold.give", "admin") + host.registerDebugCommand(new DebugCommand("gold", "mineplex.arcade.moba.gold.give", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 5d91d0f41..fc4fb3e4c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -15,6 +15,7 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -46,7 +47,7 @@ public class MinionManager implements Listener _waves = new HashSet<>(); _enabled = true; - host.registerDebugCommand(new DebugCommand("removeminions", "mineplex.arcade.moba.minion.remove", "dev") + host.registerDebugCommand(new DebugCommand("removeminions", "mineplex.arcade.moba.minion.remove", PermissionGroup.DEV) { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index f539d02fe..cf09056cc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -17,6 +17,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -24,6 +25,7 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.DebugCommand; @@ -66,7 +68,7 @@ public class MobaProgression implements Listener _roleViewers = new HashMap<>(); _roleShop = new MobaRoleShop(host.getArcadeManager()); - host.registerDebugCommand(new DebugCommand("fakeexp", "mineplex.arcade.moba.progression.fakeexp", "dev") + host.registerDebugCommand(new DebugCommand("fakeexp", "mineplex.arcade.moba.progression.fakeexp", PermissionGroup.DEV) { @Override public void Execute(Player caller, String[] args) @@ -76,7 +78,7 @@ public class MobaProgression implements Listener caller.sendMessage(F.main("Debug", "Gave you " + F.elem(exp) + " fake exp.")); } }); - host.registerDebugCommand(new DebugCommand("setmobalevel", "mineplex.arcade.moba.progression.setlevel", "dev") + host.registerDebugCommand(new DebugCommand("setmobalevel", "mineplex.arcade.moba.progression.setlevel", PermissionGroup.DEV) { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index ffb3d0b46..0e28cbefd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -24,6 +24,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -191,7 +192,7 @@ public class MobaTraining extends Moba (int) (Math.ceil(subject.getHealth() / 2D))) .register(this); - registerDebugCommand(new DebugCommand("skip", "mineplex.arcade.moba.training.skip", "player") + registerDebugCommand(new DebugCommand("skip", "mineplex.arcade.moba.training.skip", PermissionGroup.PLAYER) { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java index da75b92f2..f2fd7a722 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java @@ -32,6 +32,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.google.common.collect.Sets; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -51,6 +52,7 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -137,7 +139,7 @@ public abstract class SuperSmash extends Game new PerkSpreadsheetModule(this, "SMASH_KITS"); - registerDebugCommand(new DebugCommand("cooldown", "mineplex.arcade.smash.cooldown", "admin") + registerDebugCommand(new DebugCommand("cooldown", "mineplex.arcade.smash.cooldown", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) @@ -150,7 +152,7 @@ public abstract class SuperSmash extends Game Announce(C.cWhiteB + caller.getName() + C.cAquaB + " reset cooldowns!"); } }); - registerDebugCommand(new DebugCommand("nextsmash", "mineplex.arcade.smash.nextsmash", "admin") + registerDebugCommand(new DebugCommand("nextsmash", "mineplex.arcade.smash.nextsmash", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) @@ -159,7 +161,7 @@ public abstract class SuperSmash extends Game Announce(C.cWhiteB + caller.getName() + C.cAquaB + " spawned a smash crystal!"); } }); - registerDebugCommand(new DebugCommand("smash", "mineplex.arcade.smash.smash", "admin") + registerDebugCommand(new DebugCommand("smash", "mineplex.arcade.smash.smash", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) @@ -167,7 +169,7 @@ public abstract class SuperSmash extends Game giveSmashItem(caller); } }); - registerDebugCommand(new DebugCommand("kit", "mineplex.arcade.smash.kit", "admin") + registerDebugCommand(new DebugCommand("kit", "mineplex.arcade.smash.kit", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) @@ -193,7 +195,7 @@ public abstract class SuperSmash extends Game caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); } }); - registerDebugCommand(new DebugCommand("lives", "mineplex.arcade.smash.lives", "admin") + registerDebugCommand(new DebugCommand("lives", "mineplex.arcade.smash.lives", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index b2843e4e1..35ba49e31 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -7,6 +7,8 @@ import java.util.List; import java.util.Map.Entry; import java.util.stream.Collectors; +import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -53,6 +55,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -73,6 +76,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseGuardian; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -95,7 +99,6 @@ import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.BlockPlaceStatTracker; -import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange; public class SpeedBuilders extends SoloGame { @@ -206,7 +209,7 @@ public class SpeedBuilders extends SoloGame .setGiveCompassToAlive(false) .register(this); - registerDebugCommand(new DebugCommand("setnext", "mineplex.arcade.speedbuilders.setnext", "builder") + registerDebugCommand(new DebugCommand("setnext", "mineplex.arcade.speedbuilders.setnext", PermissionGroup.BUILDER) { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java index 92a3c90a9..dc4fe8789 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java @@ -7,11 +7,13 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilPlayer; + import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; @@ -38,7 +40,7 @@ public class StaffKillMonitorManager implements Listener { PermissionManager pm = _host.Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(MONITOR_KILLS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(MONITOR_KILLS_COMMAND_PERMISSION), true, true); } public TypeWars getHost() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java index 062acf389..4a6b0f9a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -28,6 +28,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.util.Vector; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -187,7 +188,7 @@ public class TypeWars extends TeamGame .giveHotbarItem() .register(this); - registerDebugCommand(new DebugCommand("money", "mineplex.arcade.type.money", "dev") + registerDebugCommand(new DebugCommand("money", "mineplex.arcade.type.money", PermissionGroup.DEV) { @Override public void Execute(Player caller, String[] args) @@ -196,7 +197,7 @@ public class TypeWars extends TeamGame UtilPlayer.message(caller, F.main("Money", "You got some Money")); } }); - registerDebugCommand(new DebugCommand("boss", "mineplex.arcade.type.boss", "dev") + registerDebugCommand(new DebugCommand("boss", "mineplex.arcade.type.boss", PermissionGroup.DEV) { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index dbafb1179..81e617260 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -14,6 +14,12 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.stream.Collectors; +import net.md_5.bungee.api.ChatColor; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.NextTickListEntry; +import net.minecraft.server.v1_8_R3.WorldServer; + import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.GameMode; @@ -64,6 +70,7 @@ import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.spigotmc.ActivationRange; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.boosters.event.BoosterItemGiveEvent; import mineplex.core.common.Pair; import mineplex.core.common.util.C; @@ -89,6 +96,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatLog; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GamePrepareCountdownCommence; @@ -117,11 +125,6 @@ import nautilus.game.arcade.game.modules.combatlog.CombatLogNPCKilledEvent; import nautilus.game.arcade.game.modules.combatlog.CombatLogNPCPreSpawnEvent; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import net.md_5.bungee.api.ChatColor; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import net.minecraft.server.v1_8_R3.NextTickListEntry; -import net.minecraft.server.v1_8_R3.WorldServer; public abstract class UHC extends Game { @@ -296,7 +299,7 @@ public abstract class UHC extends Game registerQuestTrackers(new TameQuestTracker(this)); - registerDebugCommand(new DebugCommand("startpvp", "mineplex.arcade.uhc.startpvp", "admin") + registerDebugCommand(new DebugCommand("startpvp", "mineplex.arcade.uhc.startpvp", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) @@ -320,7 +323,7 @@ public abstract class UHC extends Game } }); - registerDebugCommand(new DebugCommand("worldinfo", "mineplex.arcade.uhc.worldinfo", "admin") + registerDebugCommand(new DebugCommand("worldinfo", "mineplex.arcade.uhc.worldinfo", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) @@ -442,7 +445,7 @@ public abstract class UHC extends Game return; } }); - registerDebugCommand(new DebugCommand("uhcgames", "mineplex.arcade.uhc.uhcgames", "admin") + registerDebugCommand(new DebugCommand("uhcgames", "mineplex.arcade.uhc.uhcgames", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) @@ -450,7 +453,7 @@ public abstract class UHC extends Game UtilPlayer.message(caller, F.main("Debug", "As of now, there have been " + _gamesRun + " games played")); } }); - registerDebugCommand(new DebugCommand("uhcgc", "mineplex.arcade.uhc.gc","dev") + registerDebugCommand(new DebugCommand("uhcgc", "mineplex.arcade.uhc.gc", PermissionGroup.DEV) { @Override public void Execute(Player caller, String[] args) @@ -459,7 +462,7 @@ public abstract class UHC extends Game UtilPlayer.message(caller, F.main("Debug", "Cleaned up!")); } }); - registerDebugCommand(new DebugCommand("setcombatlogtimeout", "mineplex.arcade.uhc.combatlogtimeout", "dev") + registerDebugCommand(new DebugCommand("setcombatlogtimeout", "mineplex.arcade.uhc.combatlogtimeout", PermissionGroup.DEV) { @Override public void Execute(Player caller, String[] args) @@ -490,7 +493,7 @@ public abstract class UHC extends Game } } }); - registerDebugCommand(new DebugCommand("dm", "mineplex.arcade.uhc.deathmatch", "admin") + registerDebugCommand(new DebugCommand("dm", "mineplex.arcade.uhc.deathmatch", PermissionGroup.ADMIN) { @Override @@ -502,7 +505,7 @@ public abstract class UHC extends Game UtilPlayer.message(caller, F.main("Debug", "Starting deathmatch")); } }); - registerDebugCommand(new DebugCommand("uhcentities", "mineplex.arcade.uhc.entities", "dev") + registerDebugCommand(new DebugCommand("uhcentities", "mineplex.arcade.uhc.entities", PermissionGroup.DEV) { @Override @@ -523,7 +526,7 @@ public abstract class UHC extends Game } } }); - registerDebugCommand(new DebugCommand("uhcchunk", "mineplex.arcade.uhc.chunk", "dev") + registerDebugCommand(new DebugCommand("uhcchunk", "mineplex.arcade.uhc.chunk", PermissionGroup.DEV) { @Override @@ -574,7 +577,7 @@ public abstract class UHC extends Game } } }); - registerDebugCommand(new DebugCommand("uhcallchunks", "mineplex.arcade.uhc.callchunks", "dev") + registerDebugCommand(new DebugCommand("uhcallchunks", "mineplex.arcade.uhc.callchunks", PermissionGroup.DEV) { @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java index 1d95ee594..d14585e14 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java @@ -13,6 +13,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -20,6 +21,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.kit.Kit; @@ -33,7 +35,7 @@ public class RejoinModule extends Module @Override protected void setup() { - getGame().registerDebugCommand(new DebugCommand("rejoin", "mineplex.arcade.rejoin.command", "admin") + getGame().registerDebugCommand(new DebugCommand("rejoin", "mineplex.arcade.rejoin.command", PermissionGroup.ADMIN) { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index cc5e37ca0..2b4016893 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -49,6 +49,7 @@ import org.bukkit.util.Vector; import mineplex.core.Managers; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; import mineplex.core.common.util.C; @@ -72,6 +73,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -104,11 +106,11 @@ public class GameFlagManager implements Listener { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("qa"), GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); + pm.setPermission(PermissionGroup.QA, GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 47c385336..3ae9d535b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -163,11 +163,11 @@ public class GameHostManager implements Listener { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AUTO_ADMIN_ACCESS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), true, true); - pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 1), true, true); - pm.setPermission(pm.getGroup("content"), GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), true, true); - pm.setPermission(pm.getGroup("yt"), GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), false, false); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_ADMIN_ACCESS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), true, true); + pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 1), true, true); + pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), true, true); + pm.setPermission(PermissionGroup.YT, GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), false, false); } public ArrayList hasWarning() @@ -639,7 +639,7 @@ public class GameHostManager implements Listener PermissionManager pm = Manager.GetClients().getPermissionManager(); if (isCommunityServer()) { - return pm.getGroup("eternal").inherits(group); + return PermissionGroup.ETERNAL.inherits(group); } if (_hostRank == null) { @@ -654,7 +654,7 @@ public class GameHostManager implements Listener PermissionManager pm = Manager.GetClients().getPermissionManager(); if (isCommunityServer()) { - return pm.hasPermission(pm.getGroup("eternal"), permission); + return pm.hasPermission(PermissionGroup.ETERNAL, permission); } if (_hostRank == null) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java index bb2173e26..59f4d11f6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java @@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -30,6 +31,7 @@ import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardType; import mineplex.core.reward.rewards.InventoryReward; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; @@ -71,9 +73,9 @@ public class GameLootManager implements Listener { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 1), true, true); - pm.setPermission(pm.getGroup("hero"), GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 2), true, true); - pm.setPermission(pm.getGroup("legend"), GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 3), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 1), true, true); + pm.setPermission(PermissionGroup.HERO, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 2), true, true); + pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 3), true, true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java index 585fce757..28959fe0f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java @@ -65,11 +65,11 @@ public class GameRewardManager implements Listener { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 1), true, true); - pm.setPermission(pm.getGroup("hero"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 2), true, true); - pm.setPermission(pm.getGroup("legend"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 3), true, true); - pm.setPermission(pm.getGroup("titan"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 4), true, true); - pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 5), true, true); + pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 1), true, true); + pm.setPermission(PermissionGroup.HERO, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 2), true, true); + pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 3), true, true); + pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 4), true, true); + pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 5), true, true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java index 4348ae7eb..46776694d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java @@ -13,10 +13,12 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -44,7 +46,7 @@ public class GameStatManager implements Listener { PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("lt"), GroupPermission.of(STAT_BOOST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.LT, GroupPermission.of(STAT_BOOST_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java index 6fafbbeae..a2a7ef8e8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java @@ -15,6 +15,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; @@ -24,6 +25,7 @@ import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; @@ -49,7 +51,7 @@ public class IdleManager implements Listener { PermissionManager pm = _arcadeManager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_KICK_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_KICK_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 0f09e11e4..6aca653bb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -57,9 +57,9 @@ public class GameChatManager implements Listener { PermissionManager pm = _manager.GetClients().getPermissionManager(); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(TEAM_SPY_PERMISSION), true, true); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SPEC_ALWAYS_SPEAK_PERMISSION), true, true); - pm.setPermission(pm.getGroup("mod"), GroupPermission.of(SPEC_ALWAYS_HEAR_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(TEAM_SPY_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SPEC_ALWAYS_SPEAK_PERMISSION), true, true); + pm.setPermission(PermissionGroup.MOD, GroupPermission.of(SPEC_ALWAYS_HEAR_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java index 684b89ab6..73e66caad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java @@ -584,7 +584,7 @@ public abstract class LobbyManager implements Listener if (player == null) { - group = _manager.GetClients().getPermissionManager().getGroup("player"); + group = PermissionGroup.PLAYER; } else { @@ -638,7 +638,7 @@ public abstract class LobbyManager implements Listener { team.removeEntry(player.getName()); } - scoreboard.getHandle().getTeam(group.getIdentifier()).addEntry(player.getName()); + scoreboard.getHandle().getTeam(group.name()).addEntry(player.getName()); } } @@ -648,22 +648,22 @@ public abstract class LobbyManager implements Listener if (player == null) { - group = _manager.GetClients().getPermissionManager().getGroup("player"); + group = PermissionGroup.PLAYER; } else { group = _manager.GetClients().Get(player).getRealOrDisguisedPrimaryGroup(); } - String rankName = group.getIdentifier(); + String rankName = group.name(); if (player != null) { - boolean rankIsUltra = group.getIdentifier().equals("player") && + boolean rankIsUltra = group == PermissionGroup.PLAYER && _manager.GetDonation().Get(player).ownsUnknownSalesPackage(_manager.GetServerConfig().ServerType + " ULTRA"); if (rankIsUltra) { - rankName = "ultra"; + rankName = PermissionGroup.ULTRA.name(); } } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java index 3702b2fd3..315927c9d 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java @@ -1,10 +1,31 @@ package mineplex.gemhunters.economy; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Material; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; + import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -27,25 +48,6 @@ import mineplex.gemhunters.economy.command.CashOutItemCommand; import mineplex.gemhunters.economy.command.ResetCooldownCommand; import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent; import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; -import org.bukkit.Material; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; - -import java.text.DecimalFormat; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; @ReflectivelyCreateMiniPlugin public class CashOutModule extends MiniPlugin @@ -83,8 +85,8 @@ public class CashOutModule extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(CASH_OUT_ITEM_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("dev"), GroupPermission.of(RESET_COOLDOWN_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(CASH_OUT_ITEM_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.DEV, GroupPermission.of(RESET_COOLDOWN_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java index bab9b4046..a5485a37e 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java @@ -10,6 +10,7 @@ import org.bukkit.event.entity.PlayerDeathEvent; import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; @@ -47,7 +48,7 @@ public class EconomyModule extends MiniClientPlugin { PermissionManager pm = _donation.getClientManager().getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_GEMS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_GEMS_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index 31ef09684..71286e525 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -1,10 +1,40 @@ package mineplex.gemhunters.loot; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.block.Chest; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; @@ -33,34 +63,6 @@ import mineplex.gemhunters.loot.rewards.LootShardReward; import mineplex.gemhunters.safezone.SafezoneModule; import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; import mineplex.gemhunters.world.WorldDataModule; -import org.bukkit.Bukkit; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.block.Chest; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.TimeUnit; @ReflectivelyCreateMiniPlugin public class LootModule extends MiniPlugin @@ -133,8 +135,8 @@ public class LootModule extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SPAWN_CHEST_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UPDATE_LOOT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SPAWN_CHEST_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UPDATE_LOOT_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java index 0a50f4377..d1c2dacdc 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java @@ -43,25 +43,25 @@ public class LootRankReward extends LootItemReward // however knowing some people that might get changed so I'm just going // to hard code what you get. - switch (group.getIdentifier()) + switch (group) { - case "player": - newGroup = _clientManager.getPermissionManager().getGroup("ultra"); - break; - case "ultra": - newGroup = _clientManager.getPermissionManager().getGroup("hero"); - break; - case "hero": - newGroup = _clientManager.getPermissionManager().getGroup("legend"); - break; - case "legend": - newGroup = _clientManager.getPermissionManager().getGroup("titan"); - break; - case "titan": - newGroup = _clientManager.getPermissionManager().getGroup("eternal"); - break; - default: - break; + case PLAYER: + newGroup = PermissionGroup.ULTRA; + break; + case ULTRA: + newGroup = PermissionGroup.HERO; + break; + case HERO: + newGroup = PermissionGroup.LEGEND; + break; + case LEGEND: + newGroup = PermissionGroup.TITAN; + break; + case TITAN: + newGroup = PermissionGroup.ETERNAL; + break; + default: + break; } // A suitable rank could not be found. @@ -72,7 +72,7 @@ public class LootRankReward extends LootItemReward return; } - final String status = newGroup.getIdentifier(); + final String status = newGroup.name(); _clientManager.setPrimaryGroup(_player, newGroup, () -> SlackRewardBot.logReward(_player, this, status)); } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java index 9664c8827..edca846fa 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java @@ -12,6 +12,17 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map.Entry; +import net.minecraft.server.v1_8_R3.Block; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.Blocks; +import net.minecraft.server.v1_8_R3.Chunk; +import net.minecraft.server.v1_8_R3.ChunkProviderServer; +import net.minecraft.server.v1_8_R3.ChunkRegionLoader; +import net.minecraft.server.v1_8_R3.IBlockData; +import net.minecraft.server.v1_8_R3.MaterialMapColor; +import net.minecraft.server.v1_8_R3.PersistentCollection; +import net.minecraft.server.v1_8_R3.WorldServer; + import org.apache.commons.io.FileUtils; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -45,6 +56,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -63,16 +75,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent; import mineplex.gemhunters.map.command.MapCommand; -import net.minecraft.server.v1_8_R3.Block; -import net.minecraft.server.v1_8_R3.BlockPosition; -import net.minecraft.server.v1_8_R3.Blocks; -import net.minecraft.server.v1_8_R3.Chunk; -import net.minecraft.server.v1_8_R3.ChunkProviderServer; -import net.minecraft.server.v1_8_R3.ChunkRegionLoader; -import net.minecraft.server.v1_8_R3.IBlockData; -import net.minecraft.server.v1_8_R3.MaterialMapColor; -import net.minecraft.server.v1_8_R3.PersistentCollection; -import net.minecraft.server.v1_8_R3.WorldServer; /** * All item map code was adapted from Clans.
@@ -307,7 +309,7 @@ public class ItemMapModule extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(MAP_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(MAP_COMMAND_PERMISSION), true, true); } private void initialScan() diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java index 95781c65c..c4e9a3a03 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java @@ -15,6 +15,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; @@ -55,12 +56,12 @@ public class ModerationModule extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(MODERATOR_MODE_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MODERATOR_MODE_BYPASS_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(MODERATOR_MODE_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MODERATOR_MODE_BYPASS_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); if (UtilServer.isTestServer()) { - pm.setPermission(pm.getGroup("qam"), GroupPermission.of(AUTO_OP_PERMISSION), false, true); + pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); } } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java index a37b8a945..0eb513d8e 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java @@ -4,8 +4,6 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.TimeUnit; -import mineplex.core.common.util.*; -import mineplex.core.stats.StatsManager; import net.md_5.bungee.api.ChatColor; import org.bukkit.Bukkit; @@ -29,12 +27,21 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilItem.ItemAttribute; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.menu.Menu; import mineplex.core.recharge.Recharge; +import mineplex.core.stats.StatsManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.gemhunters.economy.EconomyModule; @@ -122,7 +129,7 @@ public class QuestModule extends MiniClientPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RESET_QUESTS_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESET_QUESTS_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java index 5188b76bc..a63eab737 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java @@ -20,6 +20,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -73,7 +74,7 @@ public class SpawnModule extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("player"), GroupPermission.of(HUB_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(HUB_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java index ad124fa42..76a7e62d8 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java @@ -21,6 +21,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.Pair; @@ -81,9 +82,9 @@ public class SupplyDropModule extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SUPPLY_DROP_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_SUPPLY_DROP_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(STOP_SUPPLY_DROP_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SUPPLY_DROP_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_SUPPLY_DROP_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(STOP_SUPPLY_DROP_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java index a73176f87..ce53df05c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; -import mineplex.gemhunters.worldevent.ufo.UFOWorldEvent; import org.bukkit.event.EventHandler; import mineplex.core.Managers; @@ -16,6 +15,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; @@ -28,6 +28,7 @@ import mineplex.gemhunters.worldevent.blizzard.BlizzardWorldEvent; import mineplex.gemhunters.worldevent.command.WorldEventCommand; import mineplex.gemhunters.worldevent.giant.GiantWorldEvent; import mineplex.gemhunters.worldevent.gwenmart.GwenMartWorldEvent; +import mineplex.gemhunters.worldevent.ufo.UFOWorldEvent; import mineplex.gemhunters.worldevent.wither.WitherWorldEvent; @ReflectivelyCreateMiniPlugin @@ -63,9 +64,9 @@ public class WorldEventModule extends MiniPlugin { PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(WORLD_EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_WORLD_EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(pm.getGroup("admin"), GroupPermission.of(STOP_WORLD_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(WORLD_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_WORLD_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(STOP_WORLD_EVENT_COMMAND_PERMISSION), true, true); } @Override