De-stringify permission groups

This commit is contained in:
cnr 2017-08-09 22:26:55 -04:00
parent 482a02fee1
commit ba8f4e0d5a
178 changed files with 1318 additions and 1222 deletions

View File

@ -95,7 +95,7 @@ public class PlayerSelector
for (PermissionGroup requiredGroup : groups)
{
if (group.getIdentifier().equals(requiredGroup.getIdentifier()))
if (group == requiredGroup)
{
return true;
}

View File

@ -82,7 +82,7 @@ public class CoreClient
{
if (_primary == null)
{
_primary = Managers.get(CoreClientManager.class).getPermissionManager().getGroup("player");
_primary = PermissionGroup.PLAYER;
}
return _primary;

View File

@ -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<Integer, Pair<String, Set<String>>> result = _repository.login(_loginProcessors, uuid, client.getName());
Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> 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<Integer, Pair<String, Set<String>>> result = _repository.login(_loginProcessors, uuid, client.getName());
Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> 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<Integer, Pair<String, Set<String>>> result = _repository.login(_loginProcessors, uuid, client.getName());
Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> 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<Integer, Pair<String, Set<String>>> result = _repository.login(_loginProcessors, uuid, client.getName());
client.setAccountId(result.getLeft().intValue());
Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> 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<Boolean> 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<Boolean> 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<Boolean> 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<PermissionGroup> 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<Pair<PermissionGroup, Set<PermissionGroup>>> resultCallback, Runnable onError)
public void fetchGroups(final int accountId, BiConsumer<PermissionGroup, Set<PermissionGroup>> resultCallback, Runnable onError)
{
_repository.fetchGroups(accountId, pair ->
_repository.fetchGroups(accountId, (primaryGroup, additionalGroups) ->
{
AtomicReference<PermissionGroup> 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<PermissionGroup> 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)

View File

@ -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<CoreClientManager>
return;
}
final String target = args[0];
final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]);
if (group == null)
Optional<PermissionGroup> 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<CoreClientManager>
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<CoreClientManager>
{
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."));
}
});
}

View File

@ -43,14 +43,14 @@ public class InfoPlayerCommand extends CommandBase<CoreClientManager>
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<CoreClientManager>
{
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());
}
}, () ->
{

View File

@ -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<CoreClientManager>
@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 + ", "))));
}
}

View File

@ -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<CoreClientManager>
return;
}
final String target = args[0];
final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]);
if (group == null)
Optional<PermissionGroup> 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<CoreClientManager>
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<CoreClientManager>
{
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."));
}
});
}

View File

@ -53,7 +53,7 @@ public class ResetPlayerCommand extends CommandBase<CoreClientManager>
if (success.booleanValue())
{
PermissionGroup old = client.getPrimaryGroup();
client.setPrimaryGroup(Plugin.getPermissionManager().getGroup("player"));
client.setPrimaryGroup(PermissionGroup.PLAYER);
Set<PermissionGroup> cleared = Sets.newHashSet(client.getAdditionalGroups());
client.getAdditionalGroups().clear();
UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(Bukkit.getPlayer(uuid), old, client.getPrimaryGroup()));

View File

@ -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<CoreClientManager>
return;
}
final String target = args[0];
final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]);
if (group == null)
Optional<PermissionGroup> 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<CoreClientManager>
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<CoreClientManager>
{
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()) + "!"));
});
}
});

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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 <message>") + ".", 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 <message>") + ".", 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 <message>") + ".", 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 Administrators 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<String> _inherited;
public PermissionGroup(String identifier, String display, String description, ChatColor color, int forumId, boolean canBePrimary, String... inherited)
private final Set<String> _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<PermissionGroup> 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();
}
}

View File

@ -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<GroupPermission> 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 <message>") + ".", 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 <message>") + ".", 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 <message>") + ".", 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 Administrators 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<PermissionGroup> getGroups()
{
Set<PermissionGroup> 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)

View File

@ -29,12 +29,9 @@ public class AddPermissionGroupHandler implements CommandCallback<AddPermissionG
if (opt.isPresent())
{
PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getGroupIdentifier());
if (group != null)
{
_clientManager.Get(opt.get()).addAdditionalGroup(group);
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "You have gained sub-rank " + F.elem(group.getIdentifier()) + "!"));
}
PermissionGroup group = PermissionGroup.valueOf(command.getGroupIdentifier());
_clientManager.Get(opt.get()).addAdditionalGroup(group);
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "You have gained sub-rank " + F.elem(group.name().toLowerCase()) + "!"));
}
});
}

View File

@ -29,7 +29,7 @@ public class ClearGroupsHandler implements CommandCallback<ClearGroups>
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!"));

View File

@ -29,13 +29,9 @@ public class PrimaryGroupUpdateHandler implements CommandCallback<PrimaryGroupUp
if (opt.isPresent())
{
PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getGroupIdentifier());
if (group == null)
{
group = _clientManager.getPermissionManager().getGroup("player");
}
PermissionGroup group = PermissionGroup.valueOf(command.getGroupIdentifier());
_clientManager.Get(opt.get()).setPrimaryGroup(group);
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "Your rank has been updated to " + F.elem(group.getIdentifier()) + "!"));
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "Your rank has been updated to " + F.elem(group.name().toLowerCase()) + "!"));
}
});
}

View File

@ -29,12 +29,9 @@ public class RemovePermissionGroupHandler implements CommandCallback<RemovePermi
if (opt.isPresent())
{
PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getGroupIdentifier());
if (group != null)
{
_clientManager.Get(opt.get()).removeAdditionalGroup(group);
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "You have lost sub-rank " + F.elem(group.getIdentifier()) + "!"));
}
PermissionGroup group = PermissionGroup.valueOf(command.getGroupIdentifier());
_clientManager.Get(opt.get()).removeAdditionalGroup(group);
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "You have lost sub-rank " + F.elem(group.name().toLowerCase()) + "!"));
}
});
}

View File

@ -12,6 +12,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@ -24,6 +25,7 @@ import mineplex.core.account.ILoginProcessor;
import mineplex.core.account.event.GroupAddEvent;
import mineplex.core.account.event.GroupRemoveEvent;
import mineplex.core.account.event.PrimaryGroupUpdateEvent;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.account.repository.token.LoginToken;
import mineplex.core.common.Pair;
import mineplex.core.common.util.Callback;
@ -54,12 +56,12 @@ public class AccountRepository extends MinecraftRepository
super(DBPool.getAccount());
}
public Pair<Integer, Pair<String, Set<String>>> login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name) throws SQLException
public Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> login(final List<ILoginProcessor> 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<String> extraIds = new HashSet<>();
PermissionGroup primaryRank = null;
Set<PermissionGroup> 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<Integer> 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<Boolean> successCallback)
public void addAdditionalGroup(final int accountId, final PermissionGroup group, Consumer<Boolean> 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<Boolean> successCallback)
public void removeAdditionalGroup(final int accountId, final PermissionGroup group, Consumer<Boolean> 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<String> removed = new HashSet<>();
Set<PermissionGroup> 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<Pair<String, Set<String>>> resultCallback, Runnable onError)
public void fetchGroups(final int accountId, BiConsumer<PermissionGroup, Set<PermissionGroup>> resultCallback, Runnable onError)
{
fetchGroups(accountId, resultCallback, onError, true);
}
public void fetchGroups(final int accountId, Consumer<Pair<String, Set<String>>> resultCallback, Runnable onError, boolean runAsync)
public void fetchGroups(final int accountId, BiConsumer<PermissionGroup, Set<PermissionGroup>> resultCallback, Runnable onError, boolean runAsync)
{
Runnable r = () ->
{
AtomicBoolean errored = new AtomicBoolean();
AtomicReference<String> primary = new AtomicReference<>();
Set<String> additional = new HashSet<>();
Set<PermissionGroup> 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);
}
}
};

View File

@ -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)

View File

@ -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<Consumer<PunishmentResponse>> 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"))

View File

@ -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);

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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<BonusClientData> implements ILoginProcessor
{
@ -310,18 +311,18 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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);
}
}

View File

@ -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<CommunityMemberData>
{
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)

View File

@ -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);

View File

@ -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

View File

@ -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());

View File

@ -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<Donor>
{
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

View File

@ -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<EloClientData>
{
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()

View File

@ -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<FacebookClient>
{
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

View File

@ -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<FriendData>
{
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()

View File

@ -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);
}
}

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}
}

View File

@ -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))));

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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<IgnoreData>
{
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()

View File

@ -52,24 +52,16 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{
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()

View File

@ -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<ClientInventory>
{
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()

View File

@ -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()

View File

@ -88,17 +88,12 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
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<ClientMessage>
{
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<ClientMessage>
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.");

View File

@ -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<MessageManager>
}
else
{
PermissionGroup group = Plugin.GetClientManager().getPermissionManager().getGroup(args[0]);
if (group == null)
Optional<PermissionGroup> 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();
}
}
}

View File

@ -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

View File

@ -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()

View File

@ -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 + "!");

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<PetClient>
{
@ -134,8 +136,8 @@ public class PetManager extends MiniClientPlugin<PetClient>
{
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)

View File

@ -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;
}

View File

@ -56,8 +56,8 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
{
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

View File

@ -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)

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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<QuestClientData>
{
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

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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<PlayerStats>
{
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);
}
/**

View File

@ -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<PermissionGroup> 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++;
}

View File

@ -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<TeamspeakClientInfo> implements ILoginProcessor
@ -127,10 +129,10 @@ public class TeamspeakManager extends MiniClientPlugin<TeamspeakClientInfo> 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

View File

@ -72,7 +72,7 @@ public class Teleport extends MiniPlugin
{
runSync(() ->
{
PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getRankIdentifier());
PermissionGroup group = PermissionGroup.valueOf(command.getRankIdentifier());
Set<String> 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, () ->
{

View File

@ -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<Teleport>
@Override
public void Execute(Player caller, String[] args)
{
Plugin.locateRank(caller, Plugin.getClientManager().getPermissionManager().getGroup("mod"));
Plugin.locateRank(caller, PermissionGroup.MOD);
}
}

View File

@ -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<Teleport>
@Override
public void Execute(Player caller, String[] args)
{
Plugin.locateRank(caller, Plugin.getClientManager().getPermissionManager().getGroup("trainee"));
Plugin.locateRank(caller, PermissionGroup.TRAINEE);
}
}

View File

@ -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<ThankData>
{
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

View File

@ -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);

View File

@ -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

View File

@ -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<ClientTournamentData>
{
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

View File

@ -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();

View File

@ -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<TwoFactorData>
{
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

View File

@ -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

View File

@ -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<ForumUserData>
{
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<ForumUserData>
List<Integer> 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<ForumUserData>
@EventHandler
public void handleRankSave(PrimaryGroupUpdateEvent event)
{
Consumer<Pair<Integer, Set<String>>> dataCallback = (p) ->
BiConsumer<Integer, Set<PermissionGroup>> dataCallback = (userId, groups) ->
{
List<Integer> remove = new ArrayList<>();
List<Integer> 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<ForumUserData>
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<ForumUserData>
@EventHandler
public void handleRankSave(GroupAddEvent event)
{
Consumer<Pair<Integer, Set<String>>> dataCallback = (p) ->
BiConsumer<Integer, Set<PermissionGroup>> dataCallback = (userId, groups) ->
{
List<Integer> remove = new ArrayList<>();
List<Integer> 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<ForumUserData>
return;
}
final int userId = id;
getClientManager().getRepository().fetchGroups(event.getAccountId(), pair ->
getClientManager().getRepository().fetchGroups(event.getAccountId(), (primaryGroup, additionalGroups) ->
{
Set<String> groups = Sets.newHashSet(pair.getRight());
groups.add(pair.getLeft());
groups.remove(event.getGroupIdentifier());
dataCallback.accept(Pair.create(Integer.valueOf(userId), groups));
Set<PermissionGroup> 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<ForumUserData>
@EventHandler
public void handleRankSave(GroupRemoveEvent event)
{
Consumer<Pair<Integer, Set<String>>> dataCallback = (p) ->
BiConsumer<Integer, Set<PermissionGroup>> dataCallback = (userId, groups) ->
{
List<Integer> remove = new ArrayList<>();
List<Integer> 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<ForumUserData>
return;
}
final int userId = id;
getClientManager().getRepository().fetchGroups(event.getAccountId(), pair ->
getClientManager().getRepository().fetchGroups(event.getAccountId(), (primaryGroup, additionalGroups) ->
{
Set<String> groups = Sets.newHashSet(pair.getRight());
groups.add(pair.getLeft());
dataCallback.accept(Pair.create(Integer.valueOf(userId), groups));
Set<PermissionGroup> groups = Sets.newHashSet(additionalGroups);
groups.add(primaryGroup);
dataCallback.accept(userId, groups);
}, () -> {}, false);
});
}

View File

@ -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);
}
});

View File

@ -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 ->

View File

@ -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)

View File

@ -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()

View File

@ -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<ClientClan> 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<ClientClan> 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());
}

View File

@ -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);
}
/**

View File

@ -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);
}
/**

View File

@ -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)

Some files were not shown because too many files have changed in this diff Show More