Initial rank rewrite and quest database fixes
This commit is contained in:
parent
2d9da9bc3a
commit
ef4aeaaf64
@ -1,166 +0,0 @@
|
||||
package mineplex.core.common;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayerBase;
|
||||
|
||||
public enum Rank
|
||||
{
|
||||
//Staff
|
||||
LT("Leader", "lt", ChatColor.DARK_RED, "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team.", 11, DyeColor.RED),
|
||||
OWNER("Owner", "owner", ChatColor.DARK_RED, "Owners are the founders of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation.", 55, DyeColor.RED),
|
||||
DEVELOPER("Dev", "dev", ChatColor.DARK_RED, "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", 5, DyeColor.RED),
|
||||
ADMIN("Admin", "adm", ChatColor.DARK_RED, "An Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it.", 10, DyeColor.RED),
|
||||
JNR_DEV("Jr.Dev", "jrdev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", -1, DyeColor.ORANGE),
|
||||
SUPPORT("Support", "spp", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service.", 47, DyeColor.BLUE),
|
||||
CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 32, DyeColor.ORANGE),
|
||||
EVENT_MODERATOR("Sr.Mod", "srmod_event", ChatColor.GOLD, "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>") + ".", 44, DyeColor.ORANGE),
|
||||
SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "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>") + ".", 44, DyeColor.ORANGE),
|
||||
CMA("Mod", "mod_cma", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 32, DyeColor.ORANGE),
|
||||
MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 32, DyeColor.ORANGE),
|
||||
HELPER("Trainee", "train", ChatColor.GOLD, "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>") + ".", 24, DyeColor.ORANGE),
|
||||
MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", 25, DyeColor.BLUE),
|
||||
MAPPER("Mapper", "mapp", ChatColor.BLUE, "These senior staff members work closely with \nthe development and design teams to build new \nmaps for new and old content!", 100, DyeColor.BLUE),
|
||||
MAPDEV("Builder", "mapd", ChatColor.BLUE, "These creative staff members help \nbuild maps for your favorite games!", 26, DyeColor.BLUE),
|
||||
MEDIA("Media", "media", ChatColor.BLUE, "The Media rank is given to talented artists who are\n endorsed to create content for Mineplex.", -1, DyeColor.BLUE),
|
||||
|
||||
EVENT("Event", "evnt", ChatColor.WHITE, "A member of the official Mineplex Events team!", -1, DyeColor.WHITE),
|
||||
|
||||
//Media
|
||||
YOUTUBE("YouTube", "yt", ChatColor.RED, "A YouTuber who creates content for \nor related to Mineplex.", 22, DyeColor.RED),
|
||||
YOUTUBE_SMALL("YT", "ytsm", ChatColor.DARK_PURPLE, "A YouTuber who creates content for \nor related to Mineplex. \n\nThey have fewer subscribers than full YouTubers.", 20, DyeColor.PURPLE),
|
||||
TWITCH("Twitch", "tw", ChatColor.DARK_PURPLE, "A Twitch streamer who often features \nMineplex in their streams.", 21, DyeColor.PURPLE),
|
||||
|
||||
//Player
|
||||
ETERNAL("Eternal", "et", ChatColor.DARK_AQUA, true, "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", 18, DyeColor.CYAN),
|
||||
TITAN("Titan", "t", ChatColor.RED, true, "Ancient myths spoke of a gigantic being \nwith immense power... \n\nThe fourth purchasable rank at Mineplex.com/shop", 15, DyeColor.RED),
|
||||
LEGEND("Legend", "l", ChatColor.GREEN, true, "Years they have told stories of this rank, \nonly for the legends to be true. \n\nThe third purchasable rank at Mineplex.com/shop", 14, DyeColor.GREEN),
|
||||
HERO("Hero", "h", ChatColor.LIGHT_PURPLE, true, "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", 13, DyeColor.MAGENTA),
|
||||
ULTRA("Ultra", "u", ChatColor.AQUA, true, "A first step into the stories of the mist. \nOnly those brave enough may enter. \n\nThe first purchasable rank at Mineplex.com/shop", 12, DyeColor.LIGHT_BLUE),
|
||||
ALL("", "", ChatColor.WHITE, null, -1, DyeColor.WHITE);
|
||||
|
||||
private ChatColor _color;
|
||||
private boolean _donor;
|
||||
private String _description;
|
||||
private int _forumId;
|
||||
private DyeColor _dyeColor;
|
||||
|
||||
public String Name;
|
||||
public String ScoreboardTag;
|
||||
|
||||
Rank(String name, String scoreboardTag, ChatColor color, String description, int forumId, DyeColor dyeColor)
|
||||
{
|
||||
_color = color;
|
||||
Name = name;
|
||||
_donor = false;
|
||||
_description = description;
|
||||
ScoreboardTag = scoreboardTag;
|
||||
_forumId = forumId;
|
||||
_dyeColor = dyeColor;
|
||||
}
|
||||
|
||||
Rank(String name, String scoreboardTag, ChatColor color, boolean donor, String description, int forumId, DyeColor dyeColor)
|
||||
{
|
||||
_color = color;
|
||||
Name = name;
|
||||
_donor = donor;
|
||||
_description = description;
|
||||
ScoreboardTag = scoreboardTag;
|
||||
_forumId = forumId;
|
||||
_dyeColor = dyeColor;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public String getRawTag()
|
||||
{
|
||||
if (Name.equalsIgnoreCase("ALL"))
|
||||
return "";
|
||||
|
||||
return Name;
|
||||
}
|
||||
|
||||
public boolean has(Rank rank)
|
||||
{
|
||||
return has(null, rank, false);
|
||||
}
|
||||
|
||||
public boolean has(Player player, Rank rank, boolean inform)
|
||||
{
|
||||
return has(player, rank, null, inform);
|
||||
}
|
||||
|
||||
public boolean has(Player player, Rank rank, Rank[] specific, boolean inform)
|
||||
{
|
||||
//Specific Rank
|
||||
if (specific != null)
|
||||
{
|
||||
for (Rank curRank : specific)
|
||||
{
|
||||
if (compareTo(curRank) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (compareTo(rank) <= 0)
|
||||
return true;
|
||||
|
||||
if (inform)
|
||||
{
|
||||
UtilPlayerBase.message(player, C.mHead + "Permissions> " +
|
||||
C.mBody + "This requires Permission Rank [" +
|
||||
C.mHead + rank.Name.toUpperCase() +
|
||||
C.mBody + "].");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getTag(boolean bold, boolean uppercase)
|
||||
{
|
||||
if (Name.equalsIgnoreCase("ALL"))
|
||||
return "";
|
||||
|
||||
String name = Name;
|
||||
if (uppercase)
|
||||
name = Name.toUpperCase();
|
||||
|
||||
if (bold) return _color + C.Bold + name;
|
||||
else return _color + name;
|
||||
}
|
||||
|
||||
public ChatColor getColor()
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
public boolean isDonor()
|
||||
{
|
||||
return _donor;
|
||||
}
|
||||
|
||||
public int getForumId()
|
||||
{
|
||||
return _forumId;
|
||||
}
|
||||
|
||||
public DyeColor getDyeColor()
|
||||
{
|
||||
return _dyeColor;
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ package mineplex.core.common.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.Currency;
|
||||
|
||||
public class F
|
||||
@ -104,22 +103,9 @@ public class F
|
||||
return C.wFrame + "[" + C.wField + field + C.wFrame + "] " + C.mBody + data + " ";
|
||||
}
|
||||
|
||||
public static String help(String cmd, String body, Rank rank)
|
||||
public static String help(String cmd, String body, ChatColor displayColor)
|
||||
{
|
||||
return rank.getColor() + cmd + " " + C.mBody + body + " " + rank(rank);
|
||||
}
|
||||
|
||||
public static String help(String cmd, String body, Rank rank, ChatColor displayColor)
|
||||
{
|
||||
return displayColor + cmd + " " + C.mBody + body + " " + rank(rank);
|
||||
}
|
||||
|
||||
public static String rank(Rank rank)
|
||||
{
|
||||
if (rank == Rank.ALL)
|
||||
return rank.getColor() + "Player";
|
||||
|
||||
return rank.getTag(false, false);
|
||||
return displayColor + cmd + " " + C.mBody + body;
|
||||
}
|
||||
|
||||
public static String value(String variable, int value)
|
||||
|
@ -1,20 +1,21 @@
|
||||
package mineplex.core;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
|
||||
/**
|
||||
* A helper for selecting arbitrary players given a set of conditions
|
||||
@ -74,13 +75,13 @@ public class PlayerSelector
|
||||
public static final Predicate<Player> NOT_SPECTATING = player -> player.getGameMode() != GameMode.SPECTATOR;
|
||||
|
||||
/**
|
||||
* This condition will return true if the player has one of the given ranks
|
||||
* This condition will return true if the player has one of the given ranks as their primary
|
||||
*
|
||||
* @param useDisguisedRank Whether to use the disguised rank of the player should they be disguised
|
||||
* @param ranks The ranks to check
|
||||
* @return The resulting criterion
|
||||
*/
|
||||
public static Predicate<Player> hasAnyRank(boolean useDisguisedRank, Rank... ranks)
|
||||
public static Predicate<Player> hasAnyRank(boolean useDisguisedRank, PermissionGroup... groups)
|
||||
{
|
||||
return player ->
|
||||
{
|
||||
@ -90,11 +91,11 @@ public class PlayerSelector
|
||||
return true;
|
||||
}
|
||||
CoreClient client = coreClientManager.Get(player);
|
||||
Rank rank = useDisguisedRank ? client.getRealOrDisguisedRank() : client.GetRank();
|
||||
PermissionGroup group = useDisguisedRank ? client.getRealOrDisguisedPrimaryGroup() : client.getPrimaryGroup();
|
||||
|
||||
for (Rank requiredRank : ranks)
|
||||
for (PermissionGroup requiredGroup : groups)
|
||||
{
|
||||
if (rank == requiredRank)
|
||||
if (group.getIdentifier().equals(requiredGroup.getIdentifier()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package mineplex.core.account;
|
||||
|
||||
import mineplex.core.account.event.OnlineRankUpdateEvent;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.serverdata.Utility;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.serverdata.Utility;
|
||||
|
||||
public class CoreClient
|
||||
{
|
||||
@ -18,8 +18,8 @@ public class CoreClient
|
||||
private String _name;
|
||||
private UUID _uuid;
|
||||
private Player _player;
|
||||
private Rank _rank, _lastRank;
|
||||
private Rank _tempRank, _lastTemp;
|
||||
private PermissionGroup _primary, _lastPrimary;
|
||||
private Set<PermissionGroup> _extra = new HashSet<>();
|
||||
|
||||
/*
|
||||
* Disguise info
|
||||
@ -27,7 +27,7 @@ public class CoreClient
|
||||
private String _disguisedName;
|
||||
private String _disguisedSkin;
|
||||
private UUID _disguisedUUID;
|
||||
private Rank _disguisedRank;
|
||||
private PermissionGroup _disguisedPrimary;
|
||||
|
||||
public CoreClient(Player player)
|
||||
{
|
||||
@ -73,58 +73,71 @@ public class CoreClient
|
||||
_accountId = accountId;
|
||||
}
|
||||
|
||||
public Rank GetRank()
|
||||
protected PermissionGroup getRawPrimaryGroup()
|
||||
{
|
||||
return GetRank(false);
|
||||
return _primary;
|
||||
}
|
||||
|
||||
public Rank GetRank(boolean bypass)
|
||||
public PermissionGroup getPrimaryGroup()
|
||||
{
|
||||
if (_rank == null)
|
||||
_rank = Rank.ALL;
|
||||
|
||||
if (bypass || _tempRank == null)
|
||||
return _rank;
|
||||
else
|
||||
return _tempRank;
|
||||
}
|
||||
|
||||
public Rank GetLastRank(boolean temp)
|
||||
{
|
||||
if (temp)
|
||||
if (_primary == null)
|
||||
{
|
||||
if ((_lastTemp == null) && (_tempRank == null))
|
||||
{
|
||||
return _rank;
|
||||
}
|
||||
else if (_lastTemp == null)
|
||||
{
|
||||
return _tempRank;
|
||||
}
|
||||
return _lastTemp;
|
||||
_primary = Managers.get(CoreClientManager.class).getPermissionManager().getGroup("player");
|
||||
}
|
||||
|
||||
return _primary;
|
||||
}
|
||||
|
||||
public Set<PermissionGroup> getAdditionalGroups()
|
||||
{
|
||||
return _extra;
|
||||
}
|
||||
|
||||
public PermissionGroup getLastPrimaryGroup()
|
||||
{
|
||||
if (_lastPrimary == null)
|
||||
{
|
||||
return _primary;
|
||||
}
|
||||
|
||||
return _lastPrimary;
|
||||
}
|
||||
|
||||
public boolean isMemberOf(PermissionGroup group)
|
||||
{
|
||||
if (_extra.contains(group))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return group.equals(_primary);
|
||||
}
|
||||
|
||||
public void setPrimaryGroup(PermissionGroup group)
|
||||
{
|
||||
if (_primary != null)
|
||||
{
|
||||
_lastPrimary = _primary;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_lastRank == null) return _rank;
|
||||
return _lastRank;
|
||||
_lastPrimary = group;
|
||||
}
|
||||
|
||||
_primary = group;
|
||||
}
|
||||
|
||||
public void addAdditionalGroup(PermissionGroup group)
|
||||
{
|
||||
if (!isMemberOf(group))
|
||||
{
|
||||
_extra.add(group);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRank(Rank rank, boolean temp)
|
||||
public void removeAdditionalGroup(PermissionGroup group)
|
||||
{
|
||||
if (temp)
|
||||
{
|
||||
if (_lastTemp == null) _lastTemp = rank;
|
||||
else _lastTemp = _tempRank;
|
||||
_lastRank = _rank;
|
||||
_tempRank = rank;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_rank != null) _lastRank = _rank;
|
||||
else _lastRank = rank;
|
||||
_rank = rank;
|
||||
}
|
||||
_extra.remove(group);
|
||||
}
|
||||
|
||||
public long getNetworkSessionLoginTime()
|
||||
@ -136,7 +149,8 @@ public class CoreClient
|
||||
{
|
||||
_disguisedName = null;
|
||||
_disguisedSkin = null;
|
||||
_disguisedRank = null;
|
||||
_lastPrimary = _disguisedPrimary;
|
||||
_disguisedPrimary = null;
|
||||
_disguisedUUID = null;
|
||||
}
|
||||
|
||||
@ -150,9 +164,9 @@ public class CoreClient
|
||||
return _disguisedSkin;
|
||||
}
|
||||
|
||||
public Rank getDisguisedRank()
|
||||
public PermissionGroup getDisguisedPrimaryGroup()
|
||||
{
|
||||
return _disguisedRank;
|
||||
return _disguisedPrimary;
|
||||
}
|
||||
|
||||
public UUID getDisguisedAsUUID()
|
||||
@ -169,20 +183,28 @@ public class CoreClient
|
||||
return !_name.equalsIgnoreCase(_disguisedName);
|
||||
}
|
||||
|
||||
public void disguise(String name, UUID uuid, Rank rank)
|
||||
public void disguise(String name, UUID uuid, PermissionGroup group)
|
||||
{
|
||||
_disguisedName = name;
|
||||
_disguisedUUID = uuid;
|
||||
_disguisedRank = rank;
|
||||
_disguisedPrimary = group;
|
||||
if (_primary != null)
|
||||
{
|
||||
_lastPrimary = _primary;
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastPrimary = group;
|
||||
}
|
||||
}
|
||||
|
||||
public Rank getRealOrDisguisedRank()
|
||||
public PermissionGroup getRealOrDisguisedPrimaryGroup()
|
||||
{
|
||||
if (_disguisedRank != null)
|
||||
if (_disguisedPrimary != null)
|
||||
{
|
||||
return _disguisedRank;
|
||||
return _disguisedPrimary;
|
||||
}
|
||||
return GetRank();
|
||||
return getPrimaryGroup();
|
||||
}
|
||||
|
||||
public void setNetworkSessionLoginTime(long loginTime)
|
||||
@ -190,22 +212,12 @@ public class CoreClient
|
||||
_networkSessionLoginTime = loginTime;
|
||||
}
|
||||
|
||||
public void resetTemp()
|
||||
{
|
||||
if (_tempRank != null)
|
||||
{
|
||||
OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(_player, _tempRank, _rank, true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
_lastTemp = _tempRank;
|
||||
_tempRank = null;
|
||||
UtilPlayer.message(_player, C.cGold + "Your test rank has been reset!");
|
||||
}
|
||||
}
|
||||
|
||||
public String getRealOrDisguisedName()
|
||||
{
|
||||
if (getDisguisedAs() != null)
|
||||
{
|
||||
return getDisguisedAs();
|
||||
}
|
||||
return getName();
|
||||
}
|
||||
|
||||
@ -217,7 +229,8 @@ public class CoreClient
|
||||
", _name='" + _name + '\'' +
|
||||
", _uuid=" + _uuid +
|
||||
", _player=" + _player +
|
||||
", _rank=" + _rank +
|
||||
", _primary=" + _primary +
|
||||
", _extra=[" + _extra.stream().map(PermissionGroup::toString).collect(Collectors.joining(", ")) + "]" +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -8,15 +8,16 @@ 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.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -33,33 +34,57 @@ import com.google.gson.Gson;
|
||||
import mineplex.cache.player.PlayerCache;
|
||||
import mineplex.cache.player.PlayerInfo;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.command.TestRank;
|
||||
import mineplex.core.account.command.UpdateRank;
|
||||
import mineplex.core.account.command.RanksCommand;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
import mineplex.core.account.event.RankSaveEvent;
|
||||
import mineplex.core.account.event.OnlineGroupAddEvent;
|
||||
import mineplex.core.account.event.OnlineGroupRemoveEvent;
|
||||
import mineplex.core.account.event.OnlinePrimaryGroupUpdateEvent;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.account.permissions.PermissionManager;
|
||||
import mineplex.core.account.redis.AddPermissionGroup;
|
||||
import mineplex.core.account.redis.AddPermissionGroupHandler;
|
||||
import mineplex.core.account.redis.ClearGroups;
|
||||
import mineplex.core.account.redis.ClearGroupsHandler;
|
||||
import mineplex.core.account.redis.PrimaryGroupUpdate;
|
||||
import mineplex.core.account.redis.PrimaryGroupUpdateHandler;
|
||||
import mineplex.core.account.redis.RemovePermissionGroup;
|
||||
import mineplex.core.account.redis.RemovePermissionGroupHandler;
|
||||
import mineplex.core.account.repository.AccountRepository;
|
||||
import mineplex.core.account.repository.token.ClientToken;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.timing.TimingManager;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTasks;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.utils.UtilGameProfile;
|
||||
import mineplex.core.utils.UtilScheduler;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
public class CoreClientManager extends MiniPlugin
|
||||
{
|
||||
public static final String JOIN_FULL_PERMISSION = "mineplex.core.account.joinfull";
|
||||
public static final String RANK_COMMAND_PERMISSION = "mineplex.core.account.rankcommand";
|
||||
public static final String ADD_RANK_COMMAND_PERMISSION = "mineplex.core.account.addrank";
|
||||
public static final String RANK_INFO_COMMAND_PERMISSION = "mineplex.core.account.rankinfo";
|
||||
public static final String LIST_RANKS_COMMAND_PERMISSION = "mineplex.core.account.listranks";
|
||||
public static final String REMOVE_RANK_COMMAND_PERMISSION = "mineplex.core.account.removerank";
|
||||
public static final String RESET_PLAYER_COMMAND_PERMISSION = "mineplex.core.account.resetplayer";
|
||||
public static final String SET_RANK_COMMAND_PERMISSION = "mineplex.core.account.setrank";
|
||||
|
||||
private static final Map<String, Object> CLIENT_LOGIN_LOCKS = new ConcurrentHashMap<>();
|
||||
|
||||
private JavaPlugin _plugin;
|
||||
private AccountRepository _repository;
|
||||
private PermissionManager _perm;
|
||||
private Map<UUID, CoreClient> _clientList = new HashMap<>();
|
||||
private HashSet<UUID> _duplicateLoginGlitchPreventionList = new HashSet<>();
|
||||
private Set<UUID> _duplicateLoginGlitchPreventionList = new HashSet<>();
|
||||
|
||||
private List<ILoginProcessor> _loginProcessors = new ArrayList<>();
|
||||
|
||||
@ -68,30 +93,45 @@ public class CoreClientManager extends MiniPlugin
|
||||
private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
|
||||
private static AtomicInteger _clientsProcessing = new AtomicInteger(0);
|
||||
|
||||
private final Rank WHITELIST_BYPASS;
|
||||
|
||||
private final Set<UUID> _reservedSlots = Sets.newConcurrentHashSet();
|
||||
|
||||
public CoreClientManager(JavaPlugin plugin)
|
||||
{
|
||||
this(plugin, Rank.MODERATOR);
|
||||
}
|
||||
|
||||
public CoreClientManager(JavaPlugin plugin, Rank whitelistBypass)
|
||||
{
|
||||
super("Client Manager", plugin);
|
||||
|
||||
_plugin = plugin;
|
||||
_repository = new AccountRepository();
|
||||
WHITELIST_BYPASS = whitelistBypass;
|
||||
_perm = new PermissionManager(plugin, this);
|
||||
|
||||
UtilScheduler.runEvery(UpdateType.TICK, this::checkForIllegalAccounts);
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType(AddPermissionGroup.class, new AddPermissionGroupHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType(ClearGroups.class, new ClearGroupsHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType(PrimaryGroupUpdate.class, new PrimaryGroupUpdateHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType(RemovePermissionGroup.class, new RemovePermissionGroupHandler(this));
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void checkForIllegalAccounts() {
|
||||
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);
|
||||
}
|
||||
|
||||
private void checkForIllegalAccounts()
|
||||
{
|
||||
// Use getOnlinePlayers because in the future, I might change UtilServer.getPlayers to account for vanish
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (Get(player).getAccountId() == -1) {
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (Get(player).getAccountId() == -1)
|
||||
{
|
||||
// ew ew getim outta here
|
||||
player.kickPlayer("There was a problem logging you in");
|
||||
}
|
||||
@ -103,11 +143,15 @@ public class CoreClientManager extends MiniPlugin
|
||||
return _repository;
|
||||
}
|
||||
|
||||
public PermissionManager getPermissionManager()
|
||||
{
|
||||
return _perm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new UpdateRank(this));
|
||||
addCommand(new TestRank(this));
|
||||
addCommand(new RanksCommand(this));
|
||||
}
|
||||
|
||||
public CoreClient Add(String name, UUID uuid)
|
||||
@ -209,7 +253,9 @@ public class CoreClientManager extends MiniPlugin
|
||||
_clientsProcessing.incrementAndGet();
|
||||
|
||||
if (!LoadClient(Add(event.getName(), event.getUniqueId()), event.getUniqueId(), event.getAddress().getHostAddress()))
|
||||
{
|
||||
event.disallow(Result.KICK_OTHER, "There was a problem logging you in.");
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -220,19 +266,6 @@ public class CoreClientManager extends MiniPlugin
|
||||
{
|
||||
_clientsProcessing.decrementAndGet();
|
||||
}
|
||||
|
||||
if (Bukkit.hasWhitelist() && !Get(event.getUniqueId()).GetRank().has(WHITELIST_BYPASS))
|
||||
{
|
||||
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(event.getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.disallow(Result.KICK_WHITELIST, "You are not whitelisted my friend.");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -280,8 +313,23 @@ public class CoreClientManager extends MiniPlugin
|
||||
}
|
||||
|
||||
CoreClient client = Add(token.Name, uuid);
|
||||
client.SetRank(Rank.valueOf(token.Rank), false);
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName()));
|
||||
Pair<Integer, Pair<String, Set<String>>> result = _repository.login(_loginProcessors, uuid, client.getName());
|
||||
|
||||
client.setAccountId(result.getLeft().intValue());
|
||||
if (result.getRight().getLeft() == null)
|
||||
{
|
||||
PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank);
|
||||
client.setPrimaryGroup(newGroup);
|
||||
_repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft()));
|
||||
}
|
||||
for (String id : result.getRight().getRight())
|
||||
{
|
||||
client.addAdditionalGroup(_perm.getGroup(id));
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
|
||||
@ -323,9 +371,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
if (uuid == null)
|
||||
{
|
||||
uuid = UtilGameProfile.getProfileByName(playerName, false, profile ->
|
||||
{
|
||||
}).get().getId();
|
||||
uuid = UtilGameProfile.getProfileByName(playerName, false, profile -> {}).get().getId();
|
||||
}
|
||||
|
||||
String response = "";
|
||||
@ -342,8 +388,23 @@ public class CoreClientManager extends MiniPlugin
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
CoreClient client = Add(playerName, uuid);
|
||||
client.SetRank(Rank.valueOf(token.Rank), false);
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName()));
|
||||
Pair<Integer, Pair<String, Set<String>>> result = _repository.login(_loginProcessors, uuid, client.getName());
|
||||
|
||||
client.setAccountId(result.getLeft().intValue());
|
||||
if (result.getRight().getLeft() == null)
|
||||
{
|
||||
PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank);
|
||||
client.setPrimaryGroup(newGroup);
|
||||
_repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft()));
|
||||
}
|
||||
for (String id : result.getRight().getRight())
|
||||
{
|
||||
client.addAdditionalGroup(_perm.getGroup(id));
|
||||
}
|
||||
|
||||
// JSON sql response
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
@ -402,8 +463,23 @@ public class CoreClientManager extends MiniPlugin
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
CoreClient client = Add(playerName, uuid);
|
||||
client.SetRank(Rank.valueOf(token.Rank), false);
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName()));
|
||||
Pair<Integer, Pair<String, Set<String>>> result = _repository.login(_loginProcessors, uuid, client.getName());
|
||||
|
||||
client.setAccountId(result.getLeft().intValue());
|
||||
if (result.getRight().getLeft() == null)
|
||||
{
|
||||
PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank);
|
||||
client.setPrimaryGroup(newGroup);
|
||||
_repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft()));
|
||||
}
|
||||
for (String id : result.getRight().getRight())
|
||||
{
|
||||
client.addAdditionalGroup(_perm.getGroup(id));
|
||||
}
|
||||
|
||||
// JSON sql response
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
@ -436,25 +512,32 @@ public class CoreClientManager extends MiniPlugin
|
||||
long timeStart = System.currentTimeMillis();
|
||||
|
||||
CLIENT_LOGIN_LOCKS.put(client.getName(), new Object());
|
||||
ClientToken token = null;
|
||||
Gson gson = new Gson();
|
||||
|
||||
runAsync(new Runnable()
|
||||
runAsync(() ->
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
try
|
||||
{
|
||||
try
|
||||
Pair<Integer, Pair<String, Set<String>>> result = _repository.login(_loginProcessors, uuid, client.getName());
|
||||
client.setAccountId(result.getLeft().intValue());
|
||||
if (result.getRight().getLeft() == null)
|
||||
{
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName()));
|
||||
client.setPrimaryGroup(null);
|
||||
}
|
||||
catch (SQLException e)
|
||||
else
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft()));
|
||||
}
|
||||
for (String id : result.getRight().getRight())
|
||||
{
|
||||
client.addAdditionalGroup(_perm.getGroup(id));
|
||||
}
|
||||
CLIENT_LOGIN_LOCKS.remove(client.getName());
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
CLIENT_LOGIN_LOCKS.remove(client.getName());
|
||||
});
|
||||
|
||||
TimingManager.start(client.getName() + " GetClient.");
|
||||
@ -462,11 +545,6 @@ public class CoreClientManager extends MiniPlugin
|
||||
TimingManager.stop(client.getName() + " GetClient.");
|
||||
|
||||
TimingManager.start(client.getName() + " Event.");
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
client.SetRank(Rank.valueOf(token.Rank), false);
|
||||
|
||||
// _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
|
||||
|
||||
// JSON sql response
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
@ -491,6 +569,16 @@ public class CoreClientManager extends MiniPlugin
|
||||
System.out.println("MYSQL TOO LONG TO LOGIN....");
|
||||
}
|
||||
|
||||
ClientToken token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
if (client.getRawPrimaryGroup() == null)
|
||||
{
|
||||
String mssqlRank = token.Rank;
|
||||
PermissionGroup newGroup = _perm.getGroupFromLegacy(mssqlRank);
|
||||
client.setPrimaryGroup(newGroup);
|
||||
_repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null);
|
||||
}
|
||||
|
||||
TimingManager.stop(client.getName() + " LoadClient Total.");
|
||||
|
||||
if (client.getAccountId() > 0)
|
||||
@ -520,7 +608,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
CoreClient client = Get(event.getPlayer().getUniqueId());
|
||||
|
||||
if (client == null || client.GetRank() == null)
|
||||
if (client == null || client.getRawPrimaryGroup() == null)
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect.");
|
||||
return;
|
||||
@ -533,7 +621,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
// Reserved Slot Check
|
||||
if (Bukkit.getOnlinePlayers().size() + _reservedSlots.size() >= Bukkit.getServer().getMaxPlayers())
|
||||
{
|
||||
if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false))
|
||||
if (_perm.hasPermission(client, GroupPermission.of(JOIN_FULL_PERMISSION)))
|
||||
{
|
||||
event.allow();
|
||||
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||
@ -546,7 +634,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
public void reserveFor(UUID player)
|
||||
{
|
||||
this._reservedSlots.add(player);
|
||||
_reservedSlots.add(player);
|
||||
}
|
||||
|
||||
public void unreserve(UUID uuid)
|
||||
@ -560,14 +648,14 @@ public class CoreClientManager extends MiniPlugin
|
||||
if (event.getReason().contains("You logged in from another location"))
|
||||
{
|
||||
_duplicateLoginGlitchPreventionList.add(event.getPlayer().getUniqueId());
|
||||
Bukkit.getScheduler().runTask(_plugin, new Runnable()
|
||||
Bukkit.getScheduler().runTask(_plugin, () ->
|
||||
{
|
||||
public void run()
|
||||
if (!_clientList.containsKey(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
if (!_clientList.containsKey(event.getPlayer().getUniqueId())) return;
|
||||
Player p = _clientList.get(event.getPlayer().getUniqueId()).GetPlayer();
|
||||
p.kickPlayer("You're already logged in.");
|
||||
return;
|
||||
}
|
||||
Player p = _clientList.get(event.getPlayer().getUniqueId()).GetPlayer();
|
||||
p.kickPlayer("You're already logged in.");
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -590,107 +678,231 @@ public class CoreClientManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveRank(final String name, final UUID uuid, Rank rank, boolean perm)
|
||||
public void setPrimaryGroup(Player player, final PermissionGroup group, Runnable after)
|
||||
{
|
||||
_repository.saveRank(new Callback<Rank>()
|
||||
setPrimaryGroup(Get(player).getAccountId(), group, () ->
|
||||
{
|
||||
public void run(Rank newRank)
|
||||
PermissionGroup old = Get(player).getPrimaryGroup();
|
||||
Get(player).setPrimaryGroup(group);
|
||||
UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(player, old, group));
|
||||
if (after != null)
|
||||
{
|
||||
if (_plugin.getServer().getPlayer(name) != null)
|
||||
{
|
||||
CoreClient client = Get(name);
|
||||
|
||||
client.SetRank(newRank, false);
|
||||
}
|
||||
UtilServer.CallEvent(new RankSaveEvent(uuid, newRank));
|
||||
after.run();
|
||||
}
|
||||
}, name, uuid, rank, perm);
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveRank(final Callback<Rank> callback, final String name, final UUID uuid, Rank rank, boolean perm)
|
||||
public void setPrimaryGroup(final int accountId, final PermissionGroup group, Runnable after)
|
||||
{
|
||||
_repository.saveRank(new Callback<Rank>()
|
||||
_repository.setPrimaryGroup(accountId, group.getIdentifier(), after);
|
||||
}
|
||||
|
||||
public void addAdditionalGroup(Player player, final PermissionGroup group, Consumer<Boolean> successCallback)
|
||||
{
|
||||
addAdditionalGroup(Get(player).getAccountId(), group, success ->
|
||||
{
|
||||
public void run(Rank newRank)
|
||||
if (success.booleanValue())
|
||||
{
|
||||
if (_plugin.getServer().getPlayer(name) != null)
|
||||
{
|
||||
CoreClient client = Get(name);
|
||||
|
||||
client.SetRank(newRank, false);
|
||||
}
|
||||
|
||||
if (callback != null)
|
||||
callback.run(newRank);
|
||||
|
||||
UtilServer.CallEvent(new RankSaveEvent(uuid, newRank));
|
||||
Get(player).addAdditionalGroup(group);
|
||||
UtilServer.CallEvent(new OnlineGroupAddEvent(player, group));
|
||||
}
|
||||
}, name, uuid, rank, perm);
|
||||
if (successCallback != null)
|
||||
{
|
||||
successCallback.accept(success);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addAdditionalGroup(final int accountId, final PermissionGroup group, Consumer<Boolean> successCallback)
|
||||
{
|
||||
_repository.addAdditionalGroup(accountId, group.getIdentifier(), success ->
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
successCallback.accept(success);
|
||||
}
|
||||
if (!success.booleanValue())
|
||||
{
|
||||
System.out.println("Error adding additional group " + group.getIdentifier() + " to account " + accountId + "!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void removeAdditionalGroup(Player player, final PermissionGroup group, Consumer<Boolean> successCallback)
|
||||
{
|
||||
removeAdditionalGroup(Get(player).getAccountId(), group, success ->
|
||||
{
|
||||
if (success.booleanValue())
|
||||
{
|
||||
Get(player).removeAdditionalGroup(group);
|
||||
UtilServer.CallEvent(new OnlineGroupRemoveEvent(player, group));
|
||||
}
|
||||
if (successCallback != null)
|
||||
{
|
||||
successCallback.accept(success);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void removeAdditionalGroup(final int accountId, final PermissionGroup group, Consumer<Boolean> successCallback)
|
||||
{
|
||||
_repository.removeAdditionalGroup(accountId, group.getIdentifier(), success ->
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
successCallback.accept(success);
|
||||
}
|
||||
if (!success.booleanValue())
|
||||
{
|
||||
System.out.println("Error removing additional group " + group.getIdentifier() + " from account " + accountId + "!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void clearGroups(Player player, Consumer<Boolean> successCallback)
|
||||
{
|
||||
clearGroups(Get(player).getAccountId(), success ->
|
||||
{
|
||||
if (success.booleanValue())
|
||||
{
|
||||
PermissionGroup old = Get(player).getPrimaryGroup();
|
||||
Set<PermissionGroup> cleared = Sets.newHashSet(Get(player).getAdditionalGroups());
|
||||
Get(player).setPrimaryGroup(_perm.getGroup("player"));
|
||||
Get(player).getAdditionalGroups().clear();
|
||||
UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(player, old, _perm.getGroup("player")));
|
||||
for (PermissionGroup clr : cleared)
|
||||
{
|
||||
UtilServer.CallEvent(new OnlineGroupRemoveEvent(player, clr));
|
||||
}
|
||||
}
|
||||
if (successCallback != null)
|
||||
{
|
||||
successCallback.accept(success);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void clearGroups(final int accountId, Consumer<Boolean> successCallback)
|
||||
{
|
||||
_repository.clearGroups(accountId, success ->
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
successCallback.accept(success);
|
||||
}
|
||||
if (!success.booleanValue())
|
||||
{
|
||||
System.out.println("Error clearing groups from account " + accountId + "!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fetchGroups(final int accountId, Consumer<Pair<PermissionGroup, Set<PermissionGroup>>> resultCallback, Runnable onError)
|
||||
{
|
||||
_repository.fetchGroups(accountId, pair ->
|
||||
{
|
||||
AtomicReference<PermissionGroup> primaryReference = new AtomicReference<>();
|
||||
UUID uuid;
|
||||
if (pair.getLeft() == null && (uuid = _repository.getClientUUID(accountId)) != null)
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
String legacy = loadOfflineClient(uuid).Rank;
|
||||
PermissionGroup defaultGroup = _perm.getGroup("player");
|
||||
PermissionGroup loaded = _perm.getGroupFromLegacy(legacy);
|
||||
if (loaded == null)
|
||||
{
|
||||
primaryReference.compareAndSet(null, defaultGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
primaryReference.compareAndSet(null, loaded);
|
||||
}
|
||||
});
|
||||
long start = System.currentTimeMillis();
|
||||
while (primaryReference.get() == null && !UtilTime.elapsed(start, 5000)) {}
|
||||
primaryReference.compareAndSet(null, _perm.getGroup("player"));
|
||||
}
|
||||
else
|
||||
{
|
||||
PermissionGroup defaultGroup = _perm.getGroup("player");
|
||||
PermissionGroup loaded = _perm.getGroup(pair.getLeft());
|
||||
if (loaded == null)
|
||||
{
|
||||
primaryReference.set(defaultGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
primaryReference.set(loaded);
|
||||
}
|
||||
}
|
||||
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)));
|
||||
}, () ->
|
||||
{
|
||||
if (onError != null)
|
||||
{
|
||||
onError.run();
|
||||
}
|
||||
System.out.println("Error fetching groups of account " + accountId + "!");
|
||||
});
|
||||
}
|
||||
|
||||
public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
|
||||
{
|
||||
_repository.matchPlayerName(new Callback<List<String>>()
|
||||
_repository.matchPlayerName(matches ->
|
||||
{
|
||||
public void run(List<String> matches)
|
||||
for (String match : matches)
|
||||
{
|
||||
for (String match : matches)
|
||||
if (match.equalsIgnoreCase(playerName))
|
||||
{
|
||||
if (match.equalsIgnoreCase(playerName))
|
||||
{
|
||||
callback.run(true);
|
||||
}
|
||||
callback.run(true);
|
||||
}
|
||||
|
||||
callback.run(false);
|
||||
}
|
||||
|
||||
callback.run(false);
|
||||
}, playerName);
|
||||
}
|
||||
|
||||
public void checkPlayerName(final Player caller, final String playerName, final Callback<String> callback)
|
||||
{
|
||||
_repository.matchPlayerName(new Callback<List<String>>()
|
||||
_repository.matchPlayerName(matches ->
|
||||
{
|
||||
public void run(List<String> matches)
|
||||
String tempName = null;
|
||||
|
||||
for (String match : matches)
|
||||
{
|
||||
String tempName = null;
|
||||
|
||||
for (String match : matches)
|
||||
if (match.equalsIgnoreCase(playerName))
|
||||
{
|
||||
if (match.equalsIgnoreCase(playerName))
|
||||
{
|
||||
tempName = match;
|
||||
break;
|
||||
}
|
||||
tempName = match;
|
||||
break;
|
||||
}
|
||||
|
||||
final String matchedName = tempName;
|
||||
|
||||
if (matchedName != null)
|
||||
{
|
||||
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext(); )
|
||||
{
|
||||
if (!matchIterator.next().equalsIgnoreCase(playerName))
|
||||
{
|
||||
matchIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UtilPlayer.searchOffline(matches, new Callback<String>()
|
||||
{
|
||||
public void run(final String target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
callback.run(matchedName);
|
||||
return;
|
||||
}
|
||||
|
||||
callback.run(matchedName);
|
||||
}
|
||||
}, caller, playerName, true);
|
||||
}
|
||||
|
||||
final String matchedName = tempName;
|
||||
|
||||
if (matchedName != null)
|
||||
{
|
||||
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext(); )
|
||||
{
|
||||
if (!matchIterator.next().equalsIgnoreCase(playerName))
|
||||
{
|
||||
matchIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UtilPlayer.searchOffline(matches, target ->
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
callback.run(matchedName);
|
||||
return;
|
||||
}
|
||||
|
||||
callback.run(matchedName);
|
||||
}, caller, playerName, true);
|
||||
}, playerName);
|
||||
}
|
||||
|
||||
@ -726,29 +938,8 @@ public class CoreClientManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void debug(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOWER)
|
||||
return;
|
||||
|
||||
// System.out.println("=====");
|
||||
// System.out.println("Connecting : " + _clientsConnecting.get());
|
||||
// System.out.println("Processing : " + _clientsProcessing.get());
|
||||
// System.out.println("=====");
|
||||
}
|
||||
|
||||
public void addStoredProcedureLoginProcessor(ILoginProcessor processor)
|
||||
{
|
||||
_loginProcessors.add(processor);
|
||||
}
|
||||
|
||||
public boolean hasRank(Player player, Rank rank)
|
||||
{
|
||||
CoreClient client = Get(player);
|
||||
if (client == null)
|
||||
return false;
|
||||
|
||||
return client.GetRank().has(rank);
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.OnlineGroupAddEvent;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
public class AddRankCommand extends CommandBase<CoreClientManager>
|
||||
{
|
||||
public AddRankCommand(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, CoreClientManager.ADD_RANK_COMMAND_PERMISSION, "add");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " <Player> <Rank>"));
|
||||
return;
|
||||
}
|
||||
final String target = args[0];
|
||||
final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]);
|
||||
if (group == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!"));
|
||||
return;
|
||||
}
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
UUID uuid = Plugin.loadUUIDFromDB(target);
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (uuid == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bukkit.getPlayer(uuid) != null)
|
||||
{
|
||||
final CoreClient client = Plugin.Get(uuid);
|
||||
Plugin.addAdditionalGroup(client.getAccountId(), group, success ->
|
||||
{
|
||||
if (success.booleanValue())
|
||||
{
|
||||
client.addAdditionalGroup(group);
|
||||
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) + "!"));
|
||||
}
|
||||
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."));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.loadAccountIdFromUUID(uuid, id ->
|
||||
{
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (id.intValue() == -1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.addAdditionalGroup(id.intValue(), group, success ->
|
||||
{
|
||||
if (success.booleanValue())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have added sub-rank " + F.elem(group.getIdentifier()) + " 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."));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
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;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class InfoPlayerCommand extends CommandBase<CoreClientManager>
|
||||
{
|
||||
public InfoPlayerCommand(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, CoreClientManager.RANK_INFO_COMMAND_PERMISSION, "info");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " <Player>"));
|
||||
return;
|
||||
}
|
||||
final String target = args[0];
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
UUID uuid = Plugin.loadUUIDFromDB(target);
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (uuid == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bukkit.getPlayer(uuid) != null)
|
||||
{
|
||||
final CoreClient client = Plugin.Get(uuid);
|
||||
Plugin.fetchGroups(client.getAccountId(), pair ->
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":"));
|
||||
UtilPlayer.message(caller, C.cBlue + "Primary: " + pair.getLeft().getIdentifier());
|
||||
UtilPlayer.message(caller, C.cBlue + "Additional (" + pair.getRight().size() + "):");
|
||||
for (PermissionGroup group : pair.getRight())
|
||||
{
|
||||
UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.getIdentifier());
|
||||
}
|
||||
}, () ->
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while listing " + F.elem(target) + "'s ranks!"));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.loadAccountIdFromUUID(uuid, id ->
|
||||
{
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (id.intValue() == -1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.fetchGroups(id.intValue(), pair ->
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":"));
|
||||
UtilPlayer.message(caller, C.cBlue + "Primary: " + pair.getLeft().getIdentifier());
|
||||
UtilPlayer.message(caller, C.cBlue + "Additional (" + pair.getRight().size() + "):");
|
||||
for (PermissionGroup group : pair.getRight())
|
||||
{
|
||||
UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.getIdentifier());
|
||||
}
|
||||
}, () ->
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while listing " + F.elem(target) + "'s ranks!"));
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
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;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class ListRanksCommand extends CommandBase<CoreClientManager>
|
||||
{
|
||||
public ListRanksCommand(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, CoreClientManager.LIST_RANKS_COMMAND_PERMISSION, "list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Available Ranks:"));
|
||||
for (PermissionGroup group : Plugin.getPermissionManager().getGroups())
|
||||
{
|
||||
UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.getIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class RanksCommand extends MultiCommandBase<CoreClientManager>
|
||||
{
|
||||
public RanksCommand(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, CoreClientManager.RANK_COMMAND_PERMISSION, "rank", "ranks", "permissions");
|
||||
|
||||
AddCommand(new AddRankCommand(plugin));
|
||||
AddCommand(new InfoPlayerCommand(plugin));
|
||||
AddCommand(new ListRanksCommand(plugin));
|
||||
AddCommand(new RemoveRankCommand(plugin));
|
||||
AddCommand(new ResetPlayerCommand(plugin));
|
||||
AddCommand(new SetRankCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/" + _aliasUsed + " clear <Player>", "Resets a player's ranks to default", ChatColor.DARK_RED));
|
||||
UtilPlayer.message(caller, F.help("/" + _aliasUsed + " set <Player> <Rank>", "Sets a player's primary rank", ChatColor.DARK_RED));
|
||||
UtilPlayer.message(caller, F.help("/" + _aliasUsed + " add <Player> <Rank>", "Adds a sub-rank to a player", ChatColor.DARK_RED));
|
||||
UtilPlayer.message(caller, F.help("/" + _aliasUsed + " remove <Player> <Rank>", "Removes a sub-rank from a player", ChatColor.DARK_RED));
|
||||
UtilPlayer.message(caller, F.help("/" + _aliasUsed + " list", "Lists all existing ranks", ChatColor.DARK_RED));
|
||||
UtilPlayer.message(caller, F.help("/" + _aliasUsed + " info <Player>", "Displays a player's rank information", ChatColor.DARK_RED));
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.OnlineGroupRemoveEvent;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
public class RemoveRankCommand extends CommandBase<CoreClientManager>
|
||||
{
|
||||
public RemoveRankCommand(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, CoreClientManager.REMOVE_RANK_COMMAND_PERMISSION, "remove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " <Player> <Rank>"));
|
||||
return;
|
||||
}
|
||||
final String target = args[0];
|
||||
final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]);
|
||||
if (group == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!"));
|
||||
return;
|
||||
}
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
UUID uuid = Plugin.loadUUIDFromDB(target);
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (uuid == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bukkit.getPlayer(uuid) != null)
|
||||
{
|
||||
final CoreClient client = Plugin.Get(uuid);
|
||||
Plugin.removeAdditionalGroup(client.getAccountId(), group, success ->
|
||||
{
|
||||
if (success.booleanValue())
|
||||
{
|
||||
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) + "!"));
|
||||
}
|
||||
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."));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.loadAccountIdFromUUID(uuid, id ->
|
||||
{
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (id.intValue() == -1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.removeAdditionalGroup(id.intValue(), group, success ->
|
||||
{
|
||||
if (success.booleanValue())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have removed sub-rank " + F.elem(group.getIdentifier()) + " 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."));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.OnlineGroupRemoveEvent;
|
||||
import mineplex.core.account.event.OnlinePrimaryGroupUpdateEvent;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
public class ResetPlayerCommand extends CommandBase<CoreClientManager>
|
||||
{
|
||||
public ResetPlayerCommand(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, CoreClientManager.RESET_PLAYER_COMMAND_PERMISSION, "clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " <Player>"));
|
||||
return;
|
||||
}
|
||||
final String target = args[0];
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
UUID uuid = Plugin.loadUUIDFromDB(target);
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (uuid == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bukkit.getPlayer(uuid) != null)
|
||||
{
|
||||
final CoreClient client = Plugin.Get(uuid);
|
||||
Plugin.clearGroups(client.getAccountId(), success ->
|
||||
{
|
||||
if (success.booleanValue())
|
||||
{
|
||||
PermissionGroup old = client.getPrimaryGroup();
|
||||
client.setPrimaryGroup(Plugin.getPermissionManager().getGroup("player"));
|
||||
Set<PermissionGroup> cleared = Sets.newHashSet(client.getAdditionalGroups());
|
||||
client.getAdditionalGroups().clear();
|
||||
UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(Bukkit.getPlayer(uuid), old, client.getPrimaryGroup()));
|
||||
for (PermissionGroup clr : cleared)
|
||||
{
|
||||
UtilServer.CallEvent(new OnlineGroupRemoveEvent(Bukkit.getPlayer(uuid), clr));
|
||||
}
|
||||
UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "Your ranks have been cleared!"));
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have cleared " + F.elem(target + "'s") + " ranks!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while clearing " + F.elem(target) + "'s ranks!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.loadAccountIdFromUUID(uuid, id ->
|
||||
{
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (id.intValue() == -1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.clearGroups(id.intValue(), success ->
|
||||
{
|
||||
if (success.booleanValue())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have cleared " + F.elem(target + "'s") + " ranks!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while clearing " + F.elem(target) + "'s ranks!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.OnlinePrimaryGroupUpdateEvent;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
public class SetRankCommand extends CommandBase<CoreClientManager>
|
||||
{
|
||||
public SetRankCommand(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, CoreClientManager.SET_RANK_COMMAND_PERMISSION, "set");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " <Player> <Rank>"));
|
||||
return;
|
||||
}
|
||||
final String target = args[0];
|
||||
final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]);
|
||||
if (group == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!"));
|
||||
return;
|
||||
}
|
||||
if (!group.canBePrimary())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That rank cannot be primary!"));
|
||||
return;
|
||||
}
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
UUID uuid = Plugin.loadUUIDFromDB(target);
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (uuid == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Bukkit.getPlayer(uuid) != null)
|
||||
{
|
||||
final CoreClient client = Plugin.Get(uuid);
|
||||
Plugin.setPrimaryGroup(client.getAccountId(), group, () ->
|
||||
{
|
||||
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()) + "!"));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.loadAccountIdFromUUID(uuid, id ->
|
||||
{
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (id.intValue() == -1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.setPrimaryGroup(id.intValue(), group, () ->
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have updated " + F.elem(target + "'s") + " rank to " + F.elem(group.getIdentifier()) + "!"));
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.OnlineRankUpdateEvent;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TestRank extends CommandBase<CoreClientManager>
|
||||
{
|
||||
public TestRank(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "testRank");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (!Plugin.Get(caller).GetRank(true).has(Rank.SNR_MODERATOR))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Permissions", "This requires Permission Rank [" + Rank.SNR_MODERATOR.getTag(false, true) + C.cGray + "]."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilServer.isTestServer())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem("This command can only be used on test servers!")));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + _aliasUsed + " MODERATOR"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank argument missing."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("RESET"))
|
||||
{
|
||||
Plugin.Get(caller).resetTemp();
|
||||
}
|
||||
else
|
||||
{
|
||||
Rank tempRank = null;
|
||||
|
||||
try
|
||||
{
|
||||
tempRank = Rank.valueOf(args[0].toUpperCase());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!"));
|
||||
return;
|
||||
}
|
||||
if (!Plugin.Get(caller).GetRank(true).has(Rank.JNR_DEV))
|
||||
{
|
||||
if (tempRank.has(Rank.TWITCH))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Command", "You can only test Player ranks!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Plugin.Get(caller).SetRank(tempRank, true);
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Your rank has been set to " + tempRank.getTag(false, false) + C.cGray + "!"));
|
||||
UtilPlayer.message(caller, F.main("NOTICE", "This is only to be used for testing purposes. Misuse of this command will result in a demotion."));
|
||||
OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(caller, Plugin.Get(caller).GetRank(true), Plugin.Get(caller).GetRank(), true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.OnlineRankUpdateEvent;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.serverdata.commands.UpdateRankCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class UpdateRank extends CommandBase<CoreClientManager>
|
||||
{
|
||||
public UpdateRank(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "updateRank");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + _aliasUsed + " joeschmo MODERATOR"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing."));
|
||||
return;
|
||||
}
|
||||
|
||||
final String playerName = args[0];
|
||||
Rank tempRank = null;
|
||||
|
||||
try
|
||||
{
|
||||
tempRank = Rank.valueOf(args[1]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!"));
|
||||
return;
|
||||
}
|
||||
|
||||
final Rank rank = tempRank;
|
||||
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
new UpdateRankCommand(caller.getName(), caller.getUniqueId().toString(), playerName, rank.name()).publish();
|
||||
});
|
||||
|
||||
Plugin.getRepository().matchPlayerName(new Callback<List<String>>()
|
||||
{
|
||||
public void run(List<String> matches)
|
||||
{
|
||||
boolean matchedExact = false;
|
||||
|
||||
for (String match : matches)
|
||||
{
|
||||
if (match.equalsIgnoreCase(playerName))
|
||||
{
|
||||
matchedExact = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedExact)
|
||||
{
|
||||
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
|
||||
{
|
||||
if (!matchIterator.next().equalsIgnoreCase(playerName))
|
||||
{
|
||||
matchIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilPlayer.isOnline(playerName))
|
||||
{
|
||||
Player p = UtilServer.getServer().getPlayer(playerName);
|
||||
if (Plugin.Get(p).GetRank() != Plugin.Get(p).GetRank(true))
|
||||
Plugin.Get(p).resetTemp();
|
||||
|
||||
OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(caller, Plugin.Get(caller).GetRank(), rank, false);
|
||||
Plugin.Get(p).SetRank(rank, false);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
UtilPlayer.message(p, F.main(Plugin.getName(), "Your rank has been updated to " + rank.Name + "!"));
|
||||
}
|
||||
|
||||
UtilPlayer.searchOffline(matches, new Callback<String>()
|
||||
{
|
||||
public void run(final String target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = Plugin.loadUUIDFromDB(playerName);
|
||||
|
||||
if (uuid == null)
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
|
||||
Plugin.getRepository().saveRank(new Callback<Rank>()
|
||||
{
|
||||
public void run(Rank rank)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), target + "'s rank has been updated to " + rank.Name + "!"));
|
||||
}
|
||||
}, target, uuid, rank, true);
|
||||
|
||||
}
|
||||
}, caller, playerName, true);
|
||||
}
|
||||
}, playerName);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package mineplex.core.account.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class GroupAddEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private int _accountId;
|
||||
private String _groupIdentifier;
|
||||
|
||||
public GroupAddEvent(int accountId, String groupIdentifier)
|
||||
{
|
||||
_accountId = accountId;
|
||||
_groupIdentifier = groupIdentifier;
|
||||
}
|
||||
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public String getGroupIdentifier()
|
||||
{
|
||||
return _groupIdentifier;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package mineplex.core.account.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class GroupRemoveEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private int _accountId;
|
||||
private String _groupIdentifier;
|
||||
|
||||
public GroupRemoveEvent(int accountId, String groupIdentifier)
|
||||
{
|
||||
_accountId = accountId;
|
||||
_groupIdentifier = groupIdentifier;
|
||||
}
|
||||
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public String getGroupIdentifier()
|
||||
{
|
||||
return _groupIdentifier;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package mineplex.core.account.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
|
||||
public class OnlineGroupAddEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private PermissionGroup _group;
|
||||
|
||||
public OnlineGroupAddEvent(Player player, PermissionGroup group)
|
||||
{
|
||||
_player = player;
|
||||
_group = group;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public PermissionGroup getGroup()
|
||||
{
|
||||
return _group;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package mineplex.core.account.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
|
||||
public class OnlineGroupRemoveEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private PermissionGroup _group;
|
||||
|
||||
public OnlineGroupRemoveEvent(Player player, PermissionGroup group)
|
||||
{
|
||||
_player = player;
|
||||
_group = group;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public PermissionGroup getGroup()
|
||||
{
|
||||
return _group;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,25 +1,23 @@
|
||||
package mineplex.core.account.event;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class OnlineRankUpdateEvent extends Event
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
|
||||
public class OnlinePrimaryGroupUpdateEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private Rank _from, _to;
|
||||
private boolean _temp;
|
||||
private PermissionGroup _from, _to;
|
||||
|
||||
public OnlineRankUpdateEvent(Player player, Rank from, Rank to, boolean temp)
|
||||
public OnlinePrimaryGroupUpdateEvent(Player player, PermissionGroup from, PermissionGroup to)
|
||||
{
|
||||
_player = player;
|
||||
_from = from;
|
||||
_to = to;
|
||||
_temp = temp;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
@ -27,21 +25,16 @@ public class OnlineRankUpdateEvent extends Event
|
||||
return _player;
|
||||
}
|
||||
|
||||
public Rank getFrom()
|
||||
public PermissionGroup getFrom()
|
||||
{
|
||||
return _from;
|
||||
}
|
||||
|
||||
public Rank getTo()
|
||||
public PermissionGroup getTo()
|
||||
{
|
||||
return _to;
|
||||
}
|
||||
|
||||
public boolean isTemporary()
|
||||
{
|
||||
return _temp;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
@ -51,5 +44,4 @@ public class OnlineRankUpdateEvent extends Event
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package mineplex.core.account.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PrimaryGroupUpdateEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private int _accountId;
|
||||
private String _groupIdentifier;
|
||||
|
||||
public PrimaryGroupUpdateEvent(int accountId, String groupIdentifier)
|
||||
{
|
||||
_accountId = accountId;
|
||||
_groupIdentifier = groupIdentifier;
|
||||
}
|
||||
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public String getGroupIdentifier()
|
||||
{
|
||||
return _groupIdentifier;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package mineplex.core.account.event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
public class RankSaveEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private UUID _uuid;
|
||||
private Rank _rank;
|
||||
|
||||
public RankSaveEvent(UUID uuid, Rank rank)
|
||||
{
|
||||
_uuid = uuid;
|
||||
_rank = rank;
|
||||
}
|
||||
|
||||
public UUID getUUID()
|
||||
{
|
||||
return _uuid;
|
||||
}
|
||||
|
||||
public Rank getRank()
|
||||
{
|
||||
return _rank;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package mineplex.core.account.permissions;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class GroupPermission
|
||||
{
|
||||
private final String _identifier;
|
||||
|
||||
public GroupPermission(String identifier)
|
||||
{
|
||||
_identifier = Objects.requireNonNull(identifier, "Permission identifier cannot be null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return _identifier.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o == null || !(o instanceof GroupPermission))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _identifier.hashCode() == ((GroupPermission)o)._identifier.hashCode();
|
||||
}
|
||||
|
||||
public static GroupPermission of(String identifier)
|
||||
{
|
||||
return new GroupPermission(identifier);
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package mineplex.core.account.permissions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class PermissionGroup
|
||||
{
|
||||
protected 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<Integer> _inherited;
|
||||
|
||||
public PermissionGroup(String identifier, String display, String description, ChatColor color, int forumId, boolean canBePrimary, String... inherited)
|
||||
{
|
||||
_id = Objects.requireNonNull(identifier, "Group identifier cannot be null").toLowerCase();
|
||||
_display = Objects.requireNonNull(display, "Group display cannot be null");
|
||||
_description = Objects.requireNonNull(description, "Group description cannot be null");
|
||||
_color = Objects.requireNonNull(color, "Group color cannot be null");
|
||||
_forumId = forumId;
|
||||
_canBePrimary = canBePrimary;
|
||||
_inherited = Collections.unmodifiableSet(Arrays.asList(inherited).stream().map(i -> i.hashCode()).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
public String getIdentifier()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public String getDisplay(boolean color, boolean uppercase, boolean bold, boolean defaultIdentifier)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if (uppercase)
|
||||
{
|
||||
builder.append((_display.isEmpty() && defaultIdentifier) ? _id.toUpperCase() :_display.toUpperCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.append((_display.isEmpty() && defaultIdentifier) ? (_id.substring(0, 1).toUpperCase() + _id.substring(1)) :_display);
|
||||
}
|
||||
|
||||
if (bold)
|
||||
{
|
||||
builder.insert(0, ChatColor.BOLD);
|
||||
}
|
||||
if (color)
|
||||
{
|
||||
builder.insert(0, _color);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
public int getForumId()
|
||||
{
|
||||
return _forumId;
|
||||
}
|
||||
|
||||
public ChatColor getColor()
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
public boolean canBePrimary()
|
||||
{
|
||||
return _canBePrimary;
|
||||
}
|
||||
|
||||
public boolean inherits(PermissionGroup group)
|
||||
{
|
||||
return _inherited.contains(group._id.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
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.hashCode() == _id.hashCode();
|
||||
}
|
||||
}
|
@ -0,0 +1,317 @@
|
||||
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
|
||||
{
|
||||
private final CoreClientManager _clientManager;
|
||||
private final Map<String, PermissionGroup> _groups = new HashMap<>();
|
||||
private final Map<PermissionGroup, Map<GroupPermission, Boolean>> _specific = new HashMap<>();
|
||||
private final Map<PermissionGroup, Map<GroupPermission, Boolean>> _inheritable = new HashMap<>();
|
||||
|
||||
public PermissionManager(JavaPlugin plugin, CoreClientManager client)
|
||||
{
|
||||
super("Permission Manager");
|
||||
|
||||
_clientManager = client;
|
||||
generateGroups();
|
||||
}
|
||||
|
||||
private Set<GroupPermission> getPermissions(PermissionGroup group, boolean allowSpecific)
|
||||
{
|
||||
Set<GroupPermission> perms = new HashSet<>();
|
||||
|
||||
if (group == null)
|
||||
{
|
||||
return perms;
|
||||
}
|
||||
|
||||
_groups.values().forEach(g ->
|
||||
{
|
||||
if (group.inherits(g))
|
||||
{
|
||||
perms.addAll(getPermissions(g, false));
|
||||
}
|
||||
});
|
||||
|
||||
synchronized (group.LOCK)
|
||||
{
|
||||
_inheritable.get(group).entrySet().forEach(p ->
|
||||
{
|
||||
if (p.getValue().booleanValue())
|
||||
{
|
||||
perms.add(p.getKey());
|
||||
}
|
||||
else
|
||||
{
|
||||
perms.remove(p.getKey());
|
||||
}
|
||||
});
|
||||
if (allowSpecific)
|
||||
{
|
||||
_specific.get(group).entrySet().forEach(p ->
|
||||
{
|
||||
if (p.getValue().booleanValue())
|
||||
{
|
||||
perms.add(p.getKey());
|
||||
}
|
||||
else
|
||||
{
|
||||
perms.remove(p.getKey());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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 Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it.", ChatColor.DARK_RED, 10, true, "support", "content"));
|
||||
createPermissionGroup(new PermissionGroup("dev", "Dev", "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", ChatColor.DARK_RED, 5, true, "admin"));
|
||||
createPermissionGroup(new PermissionGroup("lt", "Leader", "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team.", ChatColor.DARK_RED, 11, true, "dev"));
|
||||
createPermissionGroup(new PermissionGroup("owner", "Owner", "Owners are the core managers of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation.", ChatColor.DARK_RED, 55, true, "lt"));
|
||||
|
||||
//SUB-GROUPS
|
||||
createPermissionGroup(new PermissionGroup("cmod", "", "Members of the Clans Management team.", ChatColor.WHITE, 32, 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)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _groups.get(identifier.toLowerCase());
|
||||
}
|
||||
|
||||
public PermissionGroup getGroupFromLegacy(String legacyValue)
|
||||
{
|
||||
if (legacyValue == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String legacy = legacyValue == null ? "all" : legacyValue.toLowerCase();
|
||||
String current = null;
|
||||
|
||||
if (legacy.equals("developer"))
|
||||
{
|
||||
current = "dev";
|
||||
}
|
||||
else if (legacy.equals("jnr_dev"))
|
||||
{
|
||||
current = "player";
|
||||
}
|
||||
else if (legacy.equals("event_moderator"))
|
||||
{
|
||||
current = "eventmod";
|
||||
}
|
||||
else if (legacy.equals("snr_moderator"))
|
||||
{
|
||||
current = "srmod";
|
||||
}
|
||||
else if (legacy.equals("moderator"))
|
||||
{
|
||||
current = "mod";
|
||||
}
|
||||
else if (legacy.equals("helper"))
|
||||
{
|
||||
current = "trainee";
|
||||
}
|
||||
else if (legacy.equals("mapdev"))
|
||||
{
|
||||
current = "builder";
|
||||
}
|
||||
else if (legacy.equals("media"))
|
||||
{
|
||||
current = "player";
|
||||
}
|
||||
else if (legacy.equals("youtube_small"))
|
||||
{
|
||||
current = "yt";
|
||||
}
|
||||
else if (legacy.equals("all"))
|
||||
{
|
||||
current = "player";
|
||||
}
|
||||
|
||||
return getGroup(current);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a group is an ancestor of a base group rather than just a direct parent
|
||||
*/
|
||||
public boolean inheritsFully(PermissionGroup base, PermissionGroup check)
|
||||
{
|
||||
if (base == null || check == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (base.inherits(check))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
for (PermissionGroup group : _groups.values())
|
||||
{
|
||||
if (base.inherits(group))
|
||||
{
|
||||
boolean inherits = inheritsFully(group, check);
|
||||
if (inherits)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(PermissionGroup group, GroupPermission permission)
|
||||
{
|
||||
Set<GroupPermission> total = getPermissions(group, true);
|
||||
|
||||
return total.contains(permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(CoreClient client, GroupPermission permission)
|
||||
{
|
||||
if (hasPermission(client.getPrimaryGroup(), permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
for (PermissionGroup group : client.getAdditionalGroups())
|
||||
{
|
||||
if (hasPermission(group, permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Pair<PermissionGroup, Set<PermissionGroup>> groups, GroupPermission permission)
|
||||
{
|
||||
if (hasPermission(groups.getLeft(), permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
for (PermissionGroup group : groups.getRight())
|
||||
{
|
||||
if (hasPermission(group, permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, GroupPermission permission)
|
||||
{
|
||||
CoreClient client = _clientManager.Get(player);
|
||||
|
||||
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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
synchronized (group.LOCK)
|
||||
{
|
||||
if (inheritable)
|
||||
{
|
||||
_inheritable.computeIfAbsent(group, (g) -> new HashMap<>()).put(permission, Boolean.valueOf(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_specific.computeIfAbsent(group, (g) -> new HashMap<>()).put(permission, Boolean.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void revokePermission(PermissionGroup group, GroupPermission permission, boolean inheritable)
|
||||
{
|
||||
if (group == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
synchronized (group.LOCK)
|
||||
{
|
||||
if (inheritable)
|
||||
{
|
||||
_inheritable.computeIfAbsent(group, (g) -> new HashMap<>()).remove(permission);
|
||||
}
|
||||
else
|
||||
{
|
||||
_specific.computeIfAbsent(group, (g) -> new HashMap<>()).remove(permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.account.redis;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class AddPermissionGroup extends ServerCommand
|
||||
{
|
||||
private final int _accountId;
|
||||
private final String _groupIdentifier;
|
||||
|
||||
public AddPermissionGroup(int accountId, String groupIdentifier)
|
||||
{
|
||||
_accountId = accountId;
|
||||
_groupIdentifier = groupIdentifier;
|
||||
}
|
||||
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public String getGroupIdentifier()
|
||||
{
|
||||
return _groupIdentifier;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package mineplex.core.account.redis;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
|
||||
public class AddPermissionGroupHandler implements CommandCallback<AddPermissionGroup>
|
||||
{
|
||||
private final CoreClientManager _clientManager;
|
||||
|
||||
public AddPermissionGroupHandler(CoreClientManager clientManager)
|
||||
{
|
||||
_clientManager = clientManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(AddPermissionGroup command)
|
||||
{
|
||||
_clientManager.runSync(() ->
|
||||
{
|
||||
Optional<Player> opt = Bukkit.getOnlinePlayers().stream().map(Player.class::cast).filter(player -> _clientManager.getAccountId(player) == command.getAccountId()).findAny();
|
||||
|
||||
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()) + "!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package mineplex.core.account.redis;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class ClearGroups extends ServerCommand
|
||||
{
|
||||
private final int _accountId;
|
||||
|
||||
public ClearGroups(int accountId)
|
||||
{
|
||||
_accountId = accountId;
|
||||
}
|
||||
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package mineplex.core.account.redis;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
|
||||
public class ClearGroupsHandler implements CommandCallback<ClearGroups>
|
||||
{
|
||||
private final CoreClientManager _clientManager;
|
||||
|
||||
public ClearGroupsHandler(CoreClientManager clientManager)
|
||||
{
|
||||
_clientManager = clientManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ClearGroups command)
|
||||
{
|
||||
_clientManager.runSync(() ->
|
||||
{
|
||||
Optional<Player> opt = Bukkit.getOnlinePlayers().stream().map(Player.class::cast).filter(player -> _clientManager.getAccountId(player) == command.getAccountId()).findAny();
|
||||
|
||||
if (opt.isPresent())
|
||||
{
|
||||
PermissionGroup group = _clientManager.getPermissionManager().getGroup("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!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.account.redis;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class PrimaryGroupUpdate extends ServerCommand
|
||||
{
|
||||
private final int _accountId;
|
||||
private final String _groupIdentifier;
|
||||
|
||||
public PrimaryGroupUpdate(int accountId, String groupIdentifier)
|
||||
{
|
||||
_accountId = accountId;
|
||||
_groupIdentifier = groupIdentifier;
|
||||
}
|
||||
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public String getGroupIdentifier()
|
||||
{
|
||||
return _groupIdentifier;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package mineplex.core.account.redis;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
|
||||
public class PrimaryGroupUpdateHandler implements CommandCallback<PrimaryGroupUpdate>
|
||||
{
|
||||
private final CoreClientManager _clientManager;
|
||||
|
||||
public PrimaryGroupUpdateHandler(CoreClientManager clientManager)
|
||||
{
|
||||
_clientManager = clientManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(PrimaryGroupUpdate command)
|
||||
{
|
||||
_clientManager.runSync(() ->
|
||||
{
|
||||
Optional<Player> opt = Bukkit.getOnlinePlayers().stream().map(Player.class::cast).filter(player -> _clientManager.getAccountId(player) == command.getAccountId()).findAny();
|
||||
|
||||
if (opt.isPresent())
|
||||
{
|
||||
PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getGroupIdentifier());
|
||||
if (group == null)
|
||||
{
|
||||
group = _clientManager.getPermissionManager().getGroup("player");
|
||||
}
|
||||
_clientManager.Get(opt.get()).setPrimaryGroup(group);
|
||||
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "Your rank has been updated to " + F.elem(group.getIdentifier()) + "!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.account.redis;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class RemovePermissionGroup extends ServerCommand
|
||||
{
|
||||
private final int _accountId;
|
||||
private final String _groupIdentifier;
|
||||
|
||||
public RemovePermissionGroup(int accountId, String groupIdentifier)
|
||||
{
|
||||
_accountId = accountId;
|
||||
_groupIdentifier = groupIdentifier;
|
||||
}
|
||||
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public String getGroupIdentifier()
|
||||
{
|
||||
return _groupIdentifier;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package mineplex.core.account.redis;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
|
||||
public class RemovePermissionGroupHandler implements CommandCallback<RemovePermissionGroup>
|
||||
{
|
||||
private final CoreClientManager _clientManager;
|
||||
|
||||
public RemovePermissionGroupHandler(CoreClientManager clientManager)
|
||||
{
|
||||
_clientManager = clientManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(RemovePermissionGroup command)
|
||||
{
|
||||
_clientManager.runSync(() ->
|
||||
{
|
||||
Optional<Player> opt = Bukkit.getOnlinePlayers().stream().map(Player.class::cast).filter(player -> _clientManager.getAccountId(player) == command.getAccountId()).findAny();
|
||||
|
||||
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()) + "!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -5,8 +5,13 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -16,27 +21,32 @@ import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import mineplex.cache.player.PlayerCache;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.core.account.event.RankSaveEvent;
|
||||
import mineplex.core.account.event.GroupAddEvent;
|
||||
import mineplex.core.account.event.GroupRemoveEvent;
|
||||
import mineplex.core.account.event.PrimaryGroupUpdateEvent;
|
||||
import mineplex.core.account.repository.token.LoginToken;
|
||||
import mineplex.core.account.repository.token.RankUpdateToken;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class AccountRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));";
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name));";
|
||||
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now());";
|
||||
private static String UPDATE_ACCOUNT_RANK = "UPDATE accounts SET rank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_RANK_DONOR = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_RANK_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_RANK_DONOR_PERM = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=true WHERE uuid = ?;";
|
||||
|
||||
private static String CREATE_RANKS_TABLE = "CREATE TABLE IF NOT EXISTS accountRanks (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, rankIdentifier VARCHAR(40), primaryGroup BOOL, PRIMARY KEY(id), INDEX accountIndex (accountId), INDEX rankIndex (rankIdentifier), UNIQUE INDEX additionalIndex (accountId, rankIdentifier, primaryGroup), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||
private static String UPDATE_PRIMARY_RANK = "UPDATE accountRanks SET rankIdentifier=? WHERE accountId=? AND primaryGroup=true;";
|
||||
private static String ADD_PRIMARY_RANK = "INSERT INTO accountRanks (accountId, rankIdentifier, primaryGroup) VALUES (?, NULL, true);";
|
||||
private static String ADD_ADDITIONAL_RANK = "INSERT INTO accountRanks (accountId, rankIdentifier, primaryGroup) VALUES (?, ?, false);";
|
||||
private static String REMOVE_ADDITIONAL_RANK = "DELETE FROM accountRanks WHERE accountId=? AND rankIdentifier=? AND primaryGroup=false;";
|
||||
private static String REMOVE_ADDITIONAL_RANKS = "DELETE FROM accountRanks WHERE accountId=? AND primaryGroup=false;";
|
||||
|
||||
private static String SELECT_ACCOUNT_UUID_BY_NAME = "SELECT uuid FROM accounts WHERE name = ? ORDER BY lastLogin DESC;";
|
||||
private static String SELECT_ACCOUNT_UUID_BY_ID = "SELECT uuid FROM accounts WHERE id= DESC;";
|
||||
private static String SELECT_ACCOUNT_ID_BY_UUID = "SELECT id FROM accounts WHERE accounts.uuid = ? LIMIT 1";
|
||||
|
||||
public AccountRepository()
|
||||
@ -44,10 +54,12 @@ public class AccountRepository extends MinecraftRepository
|
||||
super(DBPool.getAccount());
|
||||
}
|
||||
|
||||
public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name) throws SQLException
|
||||
public Pair<Integer, Pair<String, Set<String>>> 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<>();
|
||||
|
||||
System.out.println("LOGIN... IDLE: " + ((BasicDataSource) DBPool.getAccount()).getNumIdle() + " ACTIVE: " + ((BasicDataSource) DBPool.getAccount()).getNumActive());
|
||||
try (Connection connection = getConnection(); Statement statement = connection.createStatement())
|
||||
@ -65,19 +77,15 @@ public class AccountRepository extends MinecraftRepository
|
||||
else
|
||||
{
|
||||
// Player doesn't exist in our database, add them to the accounts table
|
||||
final List<Integer> tempList = new ArrayList<Integer>(1);
|
||||
final List<Integer> tempList = new ArrayList<>(1);
|
||||
|
||||
executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable()
|
||||
executeInsert(connection, ACCOUNT_LOGIN_NEW, rs ->
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
while (rs.next())
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
tempList.add(resultSet.getInt(1));
|
||||
}
|
||||
tempList.add(rs.getInt(1));
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 100, uuid.toString()), new ColumnVarChar("name", 100, name));
|
||||
}, () -> {}, new ColumnVarChar("uuid", 100, uuid.toString()), new ColumnVarChar("name", 100, name));
|
||||
|
||||
accountId = tempList.get(0);
|
||||
}
|
||||
@ -87,6 +95,34 @@ public class AccountRepository extends MinecraftRepository
|
||||
System.out.println(name + " Loaded Account ID From Cache [" + name + " - " + accountId + "]");
|
||||
}
|
||||
|
||||
{
|
||||
statement.execute("SELECT * FROM accountRanks WHERE accountId=" + accountId + ";");
|
||||
try (ResultSet rankSet = statement.getResultSet())
|
||||
{
|
||||
boolean anyRows = false;
|
||||
while (rankSet.next())
|
||||
{
|
||||
anyRows = true;
|
||||
String id = rankSet.getString("rankIdentifier");
|
||||
boolean primary = rankSet.getBoolean("primaryGroup");
|
||||
|
||||
if (primary)
|
||||
{
|
||||
primaryId = id;
|
||||
}
|
||||
else
|
||||
{
|
||||
extraIds.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyRows)
|
||||
{
|
||||
statement.execute(UPDATE_PRIMARY_RANK.replace("?", "" + accountId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final int finalId = accountId;
|
||||
final String uuidString = uuid.toString();
|
||||
|
||||
@ -120,7 +156,7 @@ public class AccountRepository extends MinecraftRepository
|
||||
}
|
||||
|
||||
|
||||
return accountId;
|
||||
return Pair.create(Integer.valueOf(accountId), Pair.create(primaryId, extraIds));
|
||||
}
|
||||
|
||||
public void getAccountId(UUID uuid, Callback<Integer> callback)
|
||||
@ -150,67 +186,256 @@ public class AccountRepository extends MinecraftRepository
|
||||
|
||||
public UUID getClientUUID(String name)
|
||||
{
|
||||
final List<UUID> uuids = new ArrayList<UUID>();
|
||||
final List<UUID> uuids = new LinkedList<>();
|
||||
|
||||
executeQuery(SELECT_ACCOUNT_UUID_BY_NAME, new ResultSetCallable()
|
||||
executeQuery(SELECT_ACCOUNT_UUID_BY_NAME, resultSet ->
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
while (resultSet.next())
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
uuids.add(UUID.fromString(resultSet.getString(1)));
|
||||
}
|
||||
uuids.add(UUID.fromString(resultSet.getString(1)));
|
||||
}
|
||||
}, new ColumnVarChar("name", 100, name));
|
||||
|
||||
if (uuids.size() > 0)
|
||||
{
|
||||
return uuids.get(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void saveRank(final Callback<Rank> callback, final String name, final UUID uuid, final Rank rank, final boolean perm)
|
||||
public UUID getClientUUID(final int accountId)
|
||||
{
|
||||
final RankUpdateToken token = new RankUpdateToken();
|
||||
token.Name = name;
|
||||
token.Rank = rank.toString();
|
||||
token.Perm = perm;
|
||||
|
||||
final Consumer<Rank> extraCallback = response ->
|
||||
StringBuilder uuidBuilder = new StringBuilder();
|
||||
executeQuery(SELECT_ACCOUNT_UUID_BY_ID, resultSet ->
|
||||
{
|
||||
if (rank == Rank.ULTRA || rank == Rank.HERO || rank == Rank.LEGEND || rank == Rank.TITAN)
|
||||
if (resultSet.next())
|
||||
{
|
||||
if (rank.isDonor())
|
||||
uuidBuilder.append(resultSet.getString("uuid"));
|
||||
}
|
||||
}, new ColumnInt("id", accountId));
|
||||
|
||||
if (uuidBuilder.length() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return UUID.fromString(uuidBuilder.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void setPrimaryGroup(final int accountId, final String rankIdentifier, Runnable after)
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
try (Connection c = getConnection())
|
||||
{
|
||||
try (Statement s = c.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM accountRanks WHERE accountId=" + accountId + " AND primaryGroup=true;");
|
||||
)
|
||||
{
|
||||
if (perm)
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
else
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
if (!rs.next())
|
||||
{
|
||||
s.execute(ADD_PRIMARY_RANK.replace("?", "" + accountId));
|
||||
}
|
||||
}
|
||||
if (perm)
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
else
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
|
||||
executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier));
|
||||
|
||||
UtilServer.runSync(() ->
|
||||
{
|
||||
if (after != null)
|
||||
{
|
||||
after.run();
|
||||
}
|
||||
UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, rankIdentifier));
|
||||
});
|
||||
}
|
||||
else
|
||||
catch (SQLException e)
|
||||
{
|
||||
if (perm)
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addAdditionalGroup(final int accountId, final String rankIdentifier, Consumer<Boolean> successCallback)
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
executeInsert(ADD_ADDITIONAL_RANK, rs ->
|
||||
{
|
||||
if (rs.next())
|
||||
{
|
||||
UtilServer.runSync(() ->
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
successCallback.accept(Boolean.TRUE);
|
||||
}
|
||||
UtilServer.CallEvent(new GroupAddEvent(accountId, rankIdentifier));
|
||||
});
|
||||
}
|
||||
else
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE));
|
||||
}
|
||||
}
|
||||
}, () ->
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE));
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier));
|
||||
});
|
||||
}
|
||||
|
||||
public void removeAdditionalGroup(final int accountId, final String rankIdentifier, Consumer<Boolean> successCallback)
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
AtomicBoolean callbackRun = new AtomicBoolean();
|
||||
int updated = executeUpdate(REMOVE_ADDITIONAL_RANK, () ->
|
||||
{
|
||||
callbackRun.set(true);
|
||||
if (successCallback != null)
|
||||
{
|
||||
UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE));
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier));
|
||||
|
||||
if (!callbackRun.get())
|
||||
{
|
||||
if (updated > 0)
|
||||
{
|
||||
UtilServer.runSync(() ->
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
successCallback.accept(Boolean.TRUE);
|
||||
}
|
||||
UtilServer.CallEvent(new GroupRemoveEvent(accountId, rankIdentifier));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void clearGroups(final int accountId, Consumer<Boolean> successCallback)
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
AtomicBoolean success = new AtomicBoolean(true);
|
||||
Set<String> removed = new HashSet<>();
|
||||
|
||||
try (Connection c = getConnection())
|
||||
{
|
||||
try (Statement s = c.createStatement())
|
||||
{
|
||||
try (ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM accountRanks WHERE accountId=" + accountId + " AND primaryGroup=true;"))
|
||||
{
|
||||
if (!rs.next())
|
||||
{
|
||||
s.execute(ADD_PRIMARY_RANK.replace("?", "" + accountId));
|
||||
}
|
||||
}
|
||||
try (ResultSet rs = s.executeQuery("SELECT * FROM accountRanks WHERE accountId=" + accountId + ";"))
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
if (!rs.getBoolean("primaryGroup"))
|
||||
{
|
||||
removed.add(rs.getString("rankIdentifier"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", "player".length(), "player"));
|
||||
executeUpdate(c, REMOVE_ADDITIONAL_RANKS, () -> success.set(false), new ColumnInt("accountId", accountId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
success.set(false);
|
||||
}
|
||||
|
||||
UtilServer.runSync(() ->
|
||||
if (successCallback != null || success.get())
|
||||
{
|
||||
if (callback != null)
|
||||
callback.run(response);
|
||||
UtilServer.runSync(() ->
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
successCallback.accept(Boolean.valueOf(success.get()));
|
||||
}
|
||||
UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, "player"));
|
||||
for (String ident : removed)
|
||||
{
|
||||
UtilServer.CallEvent(new GroupRemoveEvent(accountId, ident));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
UtilServer.CallEvent(new RankSaveEvent(uuid, rank));
|
||||
});
|
||||
public void fetchGroups(final int accountId, Consumer<Pair<String, Set<String>>> resultCallback, Runnable onError)
|
||||
{
|
||||
fetchGroups(accountId, resultCallback, onError, true);
|
||||
}
|
||||
|
||||
public void fetchGroups(final int accountId, Consumer<Pair<String, Set<String>>> resultCallback, Runnable onError, boolean runAsync)
|
||||
{
|
||||
Runnable r = () ->
|
||||
{
|
||||
AtomicBoolean errored = new AtomicBoolean();
|
||||
AtomicReference<String> primary = new AtomicReference<>();
|
||||
Set<String> additional = new HashSet<>();
|
||||
|
||||
executeQuery("SELECT * FROM accountRanks WHERE accountId=?;", rs ->
|
||||
{
|
||||
if (rs.getBoolean("primaryGroup"))
|
||||
{
|
||||
primary.set(rs.getString("rankIdentifier"));
|
||||
}
|
||||
else
|
||||
{
|
||||
additional.add(rs.getString("rankIdentifier"));
|
||||
}
|
||||
}, () ->
|
||||
{
|
||||
if (onError != null)
|
||||
{
|
||||
errored.set(true);
|
||||
UtilServer.runSync(onError);
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId));
|
||||
|
||||
if (!errored.get())
|
||||
{
|
||||
if (resultCallback != null)
|
||||
{
|
||||
resultCallback.accept(Pair.create(primary.get(), additional));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
handleMSSQLCall("PlayerAccount/RankUpdate", String.format("Error saving %s's rank: ", token.Name), token, Rank.class, extraCallback);
|
||||
if (runAsync)
|
||||
{
|
||||
UtilServer.runAsync(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
public void matchPlayerName(final Callback<List<String>> callback, final String userName)
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
@ -310,7 +310,7 @@ public enum AchievementCategory
|
||||
String displayName = _statDisplays[i].getDisplayName();
|
||||
|
||||
// Skip showing Losses, Kills, Deaths for other players
|
||||
if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.getName().equals(targetName) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
|
||||
if (!clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(AchievementManager.SEE_FULL_STATS_PERMISSION)) && !player.getName().equals(targetName) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
|
||||
continue;
|
||||
|
||||
double statNumber = 0;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.core.achievement;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -8,24 +9,23 @@ 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.PermissionManager;
|
||||
import mineplex.core.achievement.command.StatsCommand;
|
||||
import mineplex.core.achievement.ui.AchievementShop;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.stats.event.StatChangeEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AchievementManager extends MiniPlugin
|
||||
{
|
||||
private static final List<String> NO_FAKE_LEVELS = Arrays.asList("samczsun");
|
||||
public static final String FAKE_LEVEL_TIER_PERMISSION = "mineplex.core.achievement.fakelevel.";
|
||||
public static final String SEE_FULL_STATS_PERMISSION = "mineplex.core.achievement.seefullstats";
|
||||
public static final String STATS_COMMAND_PERMISSION = "mineplex.core.achievement.guicommand";
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
private IncognitoManager _incognitoManager;
|
||||
@ -49,6 +49,20 @@ public class AchievementManager extends MiniPlugin
|
||||
_eloManager = eloManager;
|
||||
_clientManager = clientManager;
|
||||
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public AchievementData get(Player player, Achievement type)
|
||||
@ -199,32 +213,33 @@ public class AchievementManager extends MiniPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getMineplexLevelNumber(Player sender, Rank rank)
|
||||
public int getMineplexLevelNumber(Player sender)
|
||||
{
|
||||
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
|
||||
|
||||
if (NO_FAKE_LEVELS.contains(sender.getName()))
|
||||
if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 4)))
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
if (rank.has(Rank.MODERATOR))
|
||||
level = Math.max(level, 5);
|
||||
if (rank.has(Rank.SNR_MODERATOR))
|
||||
level = Math.max(level, 15);
|
||||
if (rank.has(Rank.JNR_DEV))
|
||||
level = Math.max(level, 25);
|
||||
if (rank.has(Rank.ADMIN))
|
||||
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
if (rank.has(Rank.OWNER))
|
||||
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
}
|
||||
else if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 3)))
|
||||
{
|
||||
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
}
|
||||
else if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 2)))
|
||||
{
|
||||
level = Math.max(level, 15);
|
||||
}
|
||||
else if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 1)))
|
||||
{
|
||||
level = Math.max(level, 5);
|
||||
}
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
public String getMineplexLevel(Player sender, Rank rank)
|
||||
public String getMineplexLevel(Player sender)
|
||||
{
|
||||
return Achievement.getExperienceString(getMineplexLevelNumber(sender, rank)) + " " + ChatColor.RESET;
|
||||
return Achievement.getExperienceString(getMineplexLevelNumber(sender)) + " " + ChatColor.RESET;
|
||||
}
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
|
@ -1,23 +1,19 @@
|
||||
package mineplex.core.achievement.command;
|
||||
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class StatsCommand extends CommandBase<AchievementManager>
|
||||
{
|
||||
public StatsCommand(AchievementManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "stats");
|
||||
super(plugin, AchievementManager.STATS_COMMAND_PERMISSION, "stats");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,7 +29,7 @@ public class StatsCommand extends CommandBase<AchievementManager>
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
if (Plugin.getClientManager().hasRank(caller, Rank.MODERATOR)) attemptOffline(caller, args);
|
||||
if (Plugin.getClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(AchievementManager.SEE_FULL_STATS_PERMISSION))) attemptOffline(caller, args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,8 @@ import mineplex.core.MiniPlugin;
|
||||
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.PermissionManager;
|
||||
import mineplex.core.antihack.actions.AntiHackAction;
|
||||
import mineplex.core.antihack.actions.BanwaveAction;
|
||||
import mineplex.core.antihack.actions.GEPBanAction;
|
||||
@ -68,7 +70,6 @@ import mineplex.core.antihack.gep.GwenExtremePrejudice;
|
||||
import mineplex.core.antihack.guardians.GuardianManager;
|
||||
import mineplex.core.antihack.logging.AntihackLogger;
|
||||
import mineplex.core.antihack.redisnotifications.GwenBanNotification;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -128,6 +129,14 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
public static final int ID_LENGTH = 5;
|
||||
|
||||
public static final String SEE_GUARDIANS_PERMISSION = "mineplex.core.antihack.seeguardians";
|
||||
public static final String SEE_ALERTS_PERMISSION = "mineplex.core.antihack.seealerts";
|
||||
public static final String SILENTLY_BANNED_PERMISSION = "mineplex.core.antihack.silentlybanned";
|
||||
public static final String ANTICHEAT_TOGGLE_COMMAND_PERMISSION = "mineplex.core.antihack.togglecommand";
|
||||
public static final String DETAILED_MESSAGES_COMMAND_PERMISSION = "mineplex.core.antihack.detailedmessages";
|
||||
public static final String GET_VLS_COMMAND_PERMISSION = "mineplex.core.antihack.getvls";
|
||||
public static final String TEST_BAN_COMMAND_PERMISSION = "mineplex.core.antihack.testban";
|
||||
|
||||
private final Cache<String, Integer> _cooldown = CacheBuilder.newBuilder()
|
||||
.concurrencyLevel(1)
|
||||
.expireAfterWrite(30, TimeUnit.SECONDS)
|
||||
@ -174,7 +183,7 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
player.spigot().sendMessage(detailed);
|
||||
}
|
||||
else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS)))
|
||||
else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SEE_ALERTS_PERMISSION)) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS)))
|
||||
{
|
||||
player.spigot().sendMessage(minimal);
|
||||
}
|
||||
@ -182,6 +191,29 @@ public class AntiHack extends MiniPlugin
|
||||
});
|
||||
|
||||
new GwenExtremePrejudice(UtilServer.getPlugin());
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
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(pm.getGroup("content"), GroupPermission.of(SILENTLY_BANNED_PERMISSION), true, true);
|
||||
pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SILENTLY_BANNED_PERMISSION), true, true);
|
||||
|
||||
pm.setPermission(pm.getGroup("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(pm.getGroup("dev"), GroupPermission.of(DETAILED_MESSAGES_COMMAND_PERMISSION), true, true);
|
||||
pm.setPermission(pm.getGroup("dev"), GroupPermission.of(GET_VLS_COMMAND_PERMISSION), true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -232,7 +264,7 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish();
|
||||
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.getPrimaryGroup().getIdentifier(), CheckManager.getCheckSimpleName(cause), id, gep).publish();
|
||||
});
|
||||
|
||||
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after);
|
||||
@ -245,7 +277,7 @@ public class AntiHack extends MiniPlugin
|
||||
}
|
||||
};
|
||||
|
||||
if (coreClient.GetRank().has(Rank.TWITCH))
|
||||
if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SILENTLY_BANNED_PERMISSION)))
|
||||
{
|
||||
doPunish.accept(result ->
|
||||
{
|
||||
@ -294,7 +326,7 @@ public class AntiHack extends MiniPlugin
|
||||
}
|
||||
};
|
||||
|
||||
if (coreClient.GetRank().has(Rank.TWITCH))
|
||||
if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SILENTLY_BANNED_PERMISSION)))
|
||||
{
|
||||
doPunish.accept(response -> {});
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class BanWaveManager extends MiniPlugin
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), client.GetRank().name(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan).publish();
|
||||
new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), client.getPrimaryGroup().getIdentifier(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan).publish();
|
||||
});
|
||||
|
||||
JsonObject custom = new JsonObject();
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ -12,7 +11,7 @@ public class AnticheatOffCommand extends CommandBase<AntiHack>
|
||||
{
|
||||
public AnticheatOffCommand(AntiHack plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "acoff");
|
||||
super(plugin, AntiHack.ANTICHEAT_TOGGLE_COMMAND_PERMISSION, "acoff");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ -12,7 +11,7 @@ public class AnticheatOnCommand extends CommandBase<AntiHack>
|
||||
{
|
||||
public AnticheatOnCommand(AntiHack plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "acon");
|
||||
super(plugin, AntiHack.ANTICHEAT_TOGGLE_COMMAND_PERMISSION, "acon");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ -12,7 +11,7 @@ public class DetailedMessagesCommand extends CommandBase<AntiHack>
|
||||
{
|
||||
public DetailedMessagesCommand(AntiHack plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "detailedmessages");
|
||||
super(plugin, AntiHack.DETAILED_MESSAGES_COMMAND_PERMISSION, "detailedmessages");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,7 +9,6 @@ import com.mineplex.anticheat.checks.CheckManager;
|
||||
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ -17,7 +16,7 @@ public class GetVlsCommand extends CommandBase<AntiHack>
|
||||
{
|
||||
public GetVlsCommand(AntiHack plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "getvls");
|
||||
super(plugin, AntiHack.GET_VLS_COMMAND_PERMISSION, "getvls");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antihack.animations.BanwaveAnimationSpin;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -17,7 +16,7 @@ public class TestBanCommand extends CommandBase<AntiHack>
|
||||
{
|
||||
public TestBanCommand(AntiHack plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "testban");
|
||||
super(plugin, AntiHack.TEST_BAN_COMMAND_PERMISSION, "testban");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,16 +1,9 @@
|
||||
package mineplex.core.antihack.guardians;
|
||||
|
||||
import com.mineplex.spigot.ChunkAddEntityEvent;
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguiseGuardian;
|
||||
import mineplex.core.event.StackerEvent;
|
||||
import net.minecraft.server.v1_8_R3.EntityArmorStand;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand;
|
||||
@ -23,9 +16,19 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import com.mineplex.spigot.ChunkAddEntityEvent;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguiseGuardian;
|
||||
import mineplex.core.event.StackerEvent;
|
||||
import net.minecraft.server.v1_8_R3.EntityArmorStand;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
|
||||
public class AntiHackGuardian implements Listener
|
||||
{
|
||||
@ -115,16 +118,10 @@ public class AntiHackGuardian implements Listener
|
||||
if (!hideForStaff) return true;
|
||||
|
||||
// Don't let Builder -> Admin see it
|
||||
Rank rank = clientManager.Get(player).GetRank();
|
||||
if (rank.has(Rank.MAPDEV))
|
||||
if (!clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(AntiHack.SEE_GUARDIANS_PERMISSION)))
|
||||
{
|
||||
if (!rank.has(Rank.ADMIN))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (rank == Rank.EVENT)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -1,14 +1,5 @@
|
||||
package mineplex.core.antihack.guardians;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.PlayerSelector;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilLambda;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -16,6 +7,18 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
|
||||
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.common.util.UtilLambda;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class GuardianManager extends MiniPlugin
|
||||
{
|
||||
@ -80,19 +83,18 @@ public class GuardianManager extends MiniPlugin
|
||||
UtilLambda.and(
|
||||
PlayerSelector.NOT_VANISHED,
|
||||
PlayerSelector.hasAnyRank(false,
|
||||
Rank.ALL,
|
||||
Rank.ULTRA,
|
||||
Rank.HERO,
|
||||
Rank.LEGEND,
|
||||
Rank.TITAN,
|
||||
Rank.TWITCH,
|
||||
Rank.YOUTUBE_SMALL,
|
||||
Rank.YOUTUBE,
|
||||
Rank.MEDIA,
|
||||
Rank.ADMIN,
|
||||
Rank.DEVELOPER,
|
||||
Rank.OWNER,
|
||||
Rank.LT
|
||||
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")
|
||||
),
|
||||
player -> !_stalking.contains(player.getUniqueId()),
|
||||
player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null
|
||||
|
@ -6,7 +6,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,20 +18,18 @@ import org.tukaani.xz.XZOutputStream;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mineplex.anticheat.api.PlayerViolationEvent;
|
||||
import com.mineplex.anticheat.checks.Check;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.account.permissions.PermissionManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antihack.ViolationLevels;
|
||||
import mineplex.core.antihack.logging.builtin.PartyInfoMetadata;
|
||||
import mineplex.core.antihack.logging.builtin.PlayerInfoMetadata;
|
||||
import mineplex.core.antihack.logging.builtin.ServerInfoMetadata;
|
||||
import mineplex.core.antihack.logging.builtin.ViolationInfoMetadata;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -42,6 +39,8 @@ public class AntihackLogger extends MiniPlugin
|
||||
{
|
||||
public static final Gson GSON = new Gson();
|
||||
|
||||
private static final String SAVE_METADATA_COMMAND_PERMISSION = "mineplex.core.antihack.savemetadatacommand";
|
||||
|
||||
private final CoreClientManager _clientManager = require(CoreClientManager.class);
|
||||
|
||||
private final Map<String, AnticheatMetadata> _metadata = new HashMap<>();
|
||||
@ -64,7 +63,9 @@ public class AntihackLogger extends MiniPlugin
|
||||
{
|
||||
if (UtilServer.isTestServer())
|
||||
{
|
||||
addCommand(new CommandBase<AntihackLogger>(this, Rank.SNR_MODERATOR, "savemetadata")
|
||||
PermissionManager pm = _clientManager.getPermissionManager();
|
||||
pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SAVE_METADATA_COMMAND_PERMISSION), true, true);
|
||||
addCommand(new CommandBase<AntihackLogger>(this, SAVE_METADATA_COMMAND_PERMISSION, "savemetadata")
|
||||
{
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
@ -139,9 +140,9 @@ public class AntihackLogger extends MiniPlugin
|
||||
|
||||
public void registerMetadata(AnticheatMetadata metadata)
|
||||
{
|
||||
if (!this._metadata.containsKey(metadata.getId()))
|
||||
if (!_metadata.containsKey(metadata.getId()))
|
||||
{
|
||||
this._metadata.put(metadata.getId(), metadata);
|
||||
_metadata.put(metadata.getId(), metadata);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,23 +1,27 @@
|
||||
package mineplex.core.aprilfools;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.account.permissions.PermissionManager;
|
||||
import mineplex.core.aprilfools.command.PirateSongCommand;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.twofactor.TwoFactorAuth;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AprilFoolsManager extends MiniPlugin
|
||||
{
|
||||
|
||||
/**
|
||||
* Manually can be toggled to enable or disable the April Fools activities.
|
||||
*/
|
||||
@ -76,13 +80,8 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
.put("developer", "firstmate")
|
||||
.put("admin", "firstmate")
|
||||
.build();
|
||||
private static final Map<Rank, String> RANK_REPLACEMENTS = ImmutableMap.<Rank, String>builder()
|
||||
.put(Rank.ETERNAL, "Captain")
|
||||
.put(Rank.TITAN, "FirstMate")
|
||||
.put(Rank.LEGEND, "Boatswain")
|
||||
.put(Rank.HERO, "Gunner")
|
||||
.put(Rank.ULTRA, "Parrot")
|
||||
.build();
|
||||
|
||||
public static final String PIRATE_SONG_COMMAND_PERMISSION = "mineplex.core.aprilfools.piratesong";
|
||||
|
||||
private static AprilFoolsManager _instance;
|
||||
private final AprilFoolsRepository _repository;
|
||||
@ -101,13 +100,13 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
setEnabled(true);
|
||||
_enabledTitle = UtilServer.isHubServer() || UtilServer.isTestServer();
|
||||
|
||||
if (_enabled)
|
||||
{
|
||||
for (Map.Entry<Rank, String> entry : RANK_REPLACEMENTS.entrySet())
|
||||
{
|
||||
entry.getKey().setName(entry.getValue());
|
||||
}
|
||||
}
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager();
|
||||
pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PIRATE_SONG_COMMAND_PERMISSION), true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,28 +1,28 @@
|
||||
package mineplex.core.aprilfools.command;
|
||||
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
|
||||
public class PirateSongCommand extends CommandBase<AprilFoolsManager>
|
||||
{
|
||||
|
||||
private static final String[] PIRATE_SONG = {
|
||||
"Are you ready kids?",
|
||||
"Aye aye captain!",
|
||||
"I can't hear you!",
|
||||
"AYE AYE CAPTAIN!",
|
||||
"OOOOOOOOOOOOH",
|
||||
"Who lives in a pineapple under the sea?",
|
||||
"Spongebob Squarepants!"
|
||||
private static final String[] PIRATE_SONG =
|
||||
{
|
||||
"Are you ready kids?",
|
||||
"Aye aye captain!",
|
||||
"I can't hear you!",
|
||||
"AYE AYE CAPTAIN!",
|
||||
"OOOOOOOOOOOOH",
|
||||
"Who lives in a pineapple under the sea?",
|
||||
"Spongebob Squarepants!"
|
||||
};
|
||||
|
||||
public PirateSongCommand(AprilFoolsManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "piratesong");
|
||||
super(plugin, AprilFoolsManager.PIRATE_SONG_COMMAND_PERMISSION, "piratesong");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,8 @@ import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.account.permissions.PermissionManager;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
||||
|
||||
public class BetaWhitelist extends MiniPlugin
|
||||
@ -40,6 +41,9 @@ public class BetaWhitelist extends MiniPlugin
|
||||
.add(UUID.fromString("6795643a-2b61-41bf-9429-c7549fd128a8")) // umGim
|
||||
.add(UUID.fromString("47ba454a-4999-42f4-a269-2f4114ceb3c7")) // falconviii
|
||||
.build();
|
||||
|
||||
private static final String BYPASS_WHITELIST_PERMISSION = "mineplex.core.beta.bypasswhitelist";
|
||||
|
||||
private final CoreClientManager _clientManager;
|
||||
private final PowerPlayClubRepository _powerPlayClubRepository;
|
||||
|
||||
@ -48,14 +52,22 @@ public class BetaWhitelist extends MiniPlugin
|
||||
super("Beta Whitelist");
|
||||
_clientManager = clientManager;
|
||||
_powerPlayClubRepository = powerPlayRepository;
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
PermissionManager pm = _clientManager.getPermissionManager();
|
||||
|
||||
pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(BYPASS_WHITELIST_PERMISSION), true, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Rank rank = _clientManager.Get(player).GetRank(true);
|
||||
if (rank.has(Rank.ULTRA) // If this player is Ultra+
|
||||
if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(BYPASS_WHITELIST_PERMISSION)) // If this player is Ultra+
|
||||
|| _powerPlayClubRepository.getCachedData(player).isSubscribed() // a PPC subscriber,
|
||||
|| EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted,
|
||||
{
|
||||
|
@ -36,6 +36,8 @@ import mineplex.core.account.CoreClient;
|
||||
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.PermissionManager;
|
||||
import mineplex.core.bonuses.animations.AnimationCarl;
|
||||
import mineplex.core.bonuses.commands.AnimationCommand;
|
||||
import mineplex.core.bonuses.commands.GuiCommand;
|
||||
@ -48,7 +50,6 @@ import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
|
||||
import mineplex.core.bonuses.redis.VoteHandler;
|
||||
import mineplex.core.bonuses.redis.VotifierCommand;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
@ -93,6 +94,18 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
private static long timeOffSet = 0;
|
||||
|
||||
public static final String ETERNAL_BONUS_PERMISSION = "mineplex.core.bonus.eternal";
|
||||
public static final String TITAN_BONUS_PERMISSION = "mineplex.core.bonus.titan";
|
||||
public static final String LEGEND_BONUS_PERMISSION = "mineplex.core.bonus.legend";
|
||||
public static final String HERO_BONUS_PERMISSION = "mineplex.core.bonus.hero";
|
||||
public static final String ULTRA_BONUS_PERMISSION = "mineplex.core.bonus.ultra";
|
||||
public static final String MONTHLY_BONUS_PERMISSION = "mineplex.core.bonus.monthly";
|
||||
public static final String ALLOW_COMMAND_PERMISSION = "mineplex.core.bonus.allowcommand";
|
||||
public static final String ANIMATION_COMMAND_PERMISSION = "mineplex.core.bonus.animation";
|
||||
public static final String GUI_COMMAND_PERMISSION = "mineplex.core.bonus.gui";
|
||||
public static final String POWER_PLAY_COMMAND_PERMISSION = "mineplex.core.bonus.powerplay";
|
||||
public static final String TICKET_COMMAND_PERMISSION = "mineplex.core.bonus.ticket";
|
||||
|
||||
private ArrayList<Object> _pendingExplosions = new ArrayList<>();
|
||||
private ArrayList<Player> _pendingExplosionsPlayers = new ArrayList<>();
|
||||
private final Map<UUID, Pair<String, Integer>> _homeServerMap = new ConcurrentHashMap<>();
|
||||
@ -186,6 +199,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_creeperName = "Carl";
|
||||
|
||||
updateOffSet();
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
public BonusManager(JavaPlugin plugin, Location carlLocation, PlayWireManager playWireManager, CoreClientManager clientManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager, String creeperName)
|
||||
@ -288,8 +303,26 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
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(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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
@ -746,29 +779,27 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
public BonusAmount getRankBonusAmount(Player player)
|
||||
{
|
||||
Rank rank = _clientManager.Get(player).GetRank();
|
||||
|
||||
BonusAmount data = new BonusAmount();
|
||||
|
||||
if (rank.has(Rank.ETERNAL))
|
||||
if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ETERNAL_BONUS_PERMISSION)))
|
||||
{
|
||||
data.setIlluminatedChests(2);
|
||||
data.setMythicalChests(2);
|
||||
data.setOmegaChests(1);
|
||||
}
|
||||
else if (rank.has(Rank.TITAN))
|
||||
else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TITAN_BONUS_PERMISSION)))
|
||||
{
|
||||
data.setMythicalChests(5);
|
||||
}
|
||||
else if (rank.has(Rank.LEGEND))
|
||||
else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(LEGEND_BONUS_PERMISSION)))
|
||||
{
|
||||
data.setMythicalChests(3);
|
||||
}
|
||||
else if (rank.has(Rank.HERO))
|
||||
else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(HERO_BONUS_PERMISSION)))
|
||||
{
|
||||
data.setMythicalChests(2);
|
||||
}
|
||||
else if (rank.has(Rank.ULTRA))
|
||||
else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ULTRA_BONUS_PERMISSION)))
|
||||
{
|
||||
data.setMythicalChests(1);
|
||||
}
|
||||
@ -984,16 +1015,15 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (canVote(player)) availableRewards++;
|
||||
if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++;
|
||||
if (_youtubeManager.canYoutube(player)) availableRewards++;
|
||||
if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++;
|
||||
if (canRank(player) && _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(MONTHLY_BONUS_PERMISSION)) && isPastAugust()) availableRewards++;
|
||||
if (canDaily(player)) availableRewards++;
|
||||
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
|
||||
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).getPrimaryGroup()) != null) availableRewards++;
|
||||
if (!_facebookManager.hasRedeemed(player)) availableRewards++;
|
||||
if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++;
|
||||
if (PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) availableRewards++;
|
||||
|
||||
Hologram hologram;
|
||||
|
||||
|
||||
if (client.getHologram() == null)
|
||||
{
|
||||
double yAdd = 2.3;
|
||||
@ -1090,7 +1120,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
final BonusClientData clientData = Get(event.getUniqueId());
|
||||
|
||||
if (clientData.getHologram() != null)
|
||||
{
|
||||
clientData.getHologram().stop();
|
||||
}
|
||||
|
||||
// Save streaks
|
||||
runAsync(() -> _repository.saveStreak(clientData.getAccountId(), clientData));
|
||||
@ -1143,12 +1175,14 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
|
||||
{
|
||||
if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
|
||||
if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(MONTHLY_BONUS_PERMISSION)) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
|
||||
{
|
||||
if (_showCarl.containsKey(player.getName()))
|
||||
{
|
||||
if (_plugin.getClass().getSimpleName().equalsIgnoreCase("Hub") || _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub"))
|
||||
{
|
||||
UtilPlayer.message(player, C.cDGreen + C.Bold + _creeperName + " the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,14 @@
|
||||
package mineplex.core.bonuses.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.command.ICommand;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Allows players to run rank-specific commands
|
||||
@ -18,12 +16,11 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class AllowCommand extends CommandBase<BonusManager>
|
||||
{
|
||||
|
||||
private BonusManager _plugin;
|
||||
|
||||
public AllowCommand(BonusManager plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "allowCommand", "allowCmd");
|
||||
super(plugin, BonusManager.ALLOW_COMMAND_PERMISSION, "allowCommand", "allowCmd");
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@ -42,9 +39,7 @@ public class AllowCommand extends CommandBase<BonusManager>
|
||||
return;
|
||||
}
|
||||
ICommand iCommand = commands.get(args[1]);
|
||||
Rank playerRank = _plugin.getClientManager().Get(caller).GetRank();
|
||||
if (playerRank.compareTo(iCommand.GetRequiredRank()) > 0
|
||||
&& Arrays.asList(iCommand.GetSpecificRanks()).contains(playerRank))
|
||||
if (!_plugin.getClientManager().getPermissionManager().hasPermission(caller, iCommand.getPermission()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Allow Command", "You're not allowed to use that command!"));
|
||||
return;
|
||||
@ -79,5 +74,4 @@ public class AllowCommand extends CommandBase<BonusManager>
|
||||
UtilPlayer.message(caller, F.main("Allow Command", "You allowed the player " + F.name(receiver.getName()) + " to use the command " + F.elem(args[1]) + "!"));
|
||||
UtilPlayer.message(receiver, F.main("Allow Command", "The player " + F.name(caller.getName()) + " allowed you to use the command " + F.elem(args[1]) + "!"));
|
||||
}
|
||||
|
||||
}
|
@ -3,10 +3,9 @@ package mineplex.core.bonuses.commands;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.reward.RewardType;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.reward.RewardType;
|
||||
|
||||
public class AnimationCommand extends CommandBase<BonusManager>{
|
||||
|
||||
@ -14,7 +13,7 @@ public class AnimationCommand extends CommandBase<BonusManager>{
|
||||
|
||||
public AnimationCommand(BonusManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "animation");
|
||||
super(plugin, BonusManager.ANIMATION_COMMAND_PERMISSION, "animation");
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@ -30,5 +29,4 @@ public class AnimationCommand extends CommandBase<BonusManager>{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -2,16 +2,15 @@ package mineplex.core.bonuses.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.gui.BonusGui;
|
||||
import mineplex.core.command.CommandBase;
|
||||
|
||||
public class GuiCommand extends CommandBase<BonusManager>
|
||||
{
|
||||
public GuiCommand(BonusManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "bonus");
|
||||
super(plugin, BonusManager.GUI_COMMAND_PERMISSION, "bonus");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -19,5 +18,4 @@ public class GuiCommand extends CommandBase<BonusManager>
|
||||
{
|
||||
new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getThankManager(), Plugin.getPlayWireManager()).openInventory();
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +1,25 @@
|
||||
package mineplex.core.bonuses.commands;
|
||||
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.powerplayclub.PowerPlayData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.powerplayclub.PowerPlayData;
|
||||
|
||||
public class PowerPlayCommand extends CommandBase<BonusManager>
|
||||
{
|
||||
|
||||
private BonusManager _bonusManager;
|
||||
|
||||
public PowerPlayCommand(BonusManager manager)
|
||||
{
|
||||
super(manager, Rank.JNR_DEV, "powerplay");
|
||||
super(manager, BonusManager.POWER_PLAY_COMMAND_PERMISSION, "powerplay");
|
||||
_bonusManager = manager;
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,18 @@
|
||||
package mineplex.core.bonuses.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TicketCommand extends CommandBase<BonusManager>
|
||||
{
|
||||
public TicketCommand(BonusManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "ticket");
|
||||
super(plugin, BonusManager.TICKET_COMMAND_PERMISSION, "ticket");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,15 @@ package mineplex.core.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.bonuses.BonusAmount;
|
||||
@ -19,14 +28,6 @@ import mineplex.core.poll.Poll;
|
||||
import mineplex.core.poll.PollManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PollButton extends SimpleGui implements GuiItem {
|
||||
|
||||
protected boolean _create;
|
||||
@ -56,7 +57,7 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
{
|
||||
if (_create)
|
||||
{
|
||||
this._poll = _pollManager.getNextPoll(_pollManager.Get(getPlayer()), _clientManager.Get(getPlayer()).GetRank());
|
||||
_poll = _pollManager.getNextPoll(_pollManager.Get(getPlayer()), _clientManager.Get(getPlayer()).getPrimaryGroup());
|
||||
|
||||
if (_poll != null)
|
||||
{
|
||||
@ -77,7 +78,7 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
List<String> lore = new ArrayList<>();
|
||||
if (_poll == null)
|
||||
{
|
||||
lore.add("");
|
||||
@ -128,14 +129,15 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
|
||||
public GuiItem getQuestionItem(String question)
|
||||
{
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
for (String string : wrap(question))
|
||||
{
|
||||
lore.add(C.cWhite + string);
|
||||
}
|
||||
lore.add("");
|
||||
int i = 1;
|
||||
for(String str : _poll.getAnswers())
|
||||
for (String str : _poll.getAnswers())
|
||||
{
|
||||
lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str);
|
||||
i++;
|
||||
@ -181,21 +183,20 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
|
||||
private class AnswerItem implements GuiItem
|
||||
{
|
||||
|
||||
private int num;
|
||||
private int _num;
|
||||
|
||||
private AnswerItem(Poll poll, int num)
|
||||
{
|
||||
this.num = num;
|
||||
_num = num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getObject()
|
||||
{
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
lore.add(C.cWhite + getPoll().getAnswers()[num]);
|
||||
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (num + 1), lore);
|
||||
lore.add(C.cWhite + getPoll().getAnswers()[_num]);
|
||||
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (_num + 1), lore);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -208,11 +209,11 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
|
||||
_create = true;
|
||||
|
||||
_pollManager.answerPoll(getPlayer(), _poll, num + 1);
|
||||
_pollManager.answerPoll(getPlayer(), _poll, _num + 1);
|
||||
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
|
||||
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.EMERALD_BLOCK, (byte) 0, 1, ChatColor.GREEN + "Your anwser:", wrap(getPoll().getAnswers()[num])), ChatColor.GREEN + "Moo", 6 * 9, 50, getMaster()).openInventory();
|
||||
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.EMERALD_BLOCK, (byte) 0, 1, ChatColor.GREEN + "Your anwser:", wrap(getPoll().getAnswers()[_num])), ChatColor.GREEN + "Moo", 6 * 9, 50, getMaster()).openInventory();
|
||||
_bonusManager.addPendingExplosion(getPlayer(), "POLL");
|
||||
getPlayer().closeInventory();
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public class RankBonusButton implements GuiItem, Listener {
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).GetRank().Name);
|
||||
lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).getPrimaryGroup().getDisplay(false, false, false, true));
|
||||
BonusAmount bonusAmount = _bonusManager.getRankBonusAmount(_player);
|
||||
bonusAmount.addLore(lore);
|
||||
}
|
||||
|
@ -1,7 +1,29 @@
|
||||
package mineplex.core.boosters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
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.PermissionManager;
|
||||
import mineplex.core.boosters.command.BoosterCommand;
|
||||
import mineplex.core.boosters.event.BoosterActivateEvent;
|
||||
import mineplex.core.boosters.event.BoosterExpireEvent;
|
||||
@ -21,18 +43,6 @@ import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* BoosterManager handles the majority of logic for creating and getting Boosters. Every BoosterManager stores a cache
|
||||
@ -59,6 +69,12 @@ public class BoosterManager extends MiniPlugin
|
||||
// Slot for the booster gui item
|
||||
public static final int INTERFACE_SLOT = 7;
|
||||
|
||||
public static final String ADD_BOOSTER_COMMAND_PERMISSION = "mineplex.core.booster.add";
|
||||
public static final String BOOSTER_COMMAND_PERMISSION = "mineplex.core.booster.command";
|
||||
public static final String BOOSTER_GUI_COMMAND_PERMISSION = "mineplex.core.booster.gui";
|
||||
public static final String RELOAD_BOOSTERS_COMMAND_PERMISSION = "mineplex.core.booster.reload";
|
||||
public static final String THANK_COMMAND_PERMISSION = "mineplex.core.booster.thank";
|
||||
|
||||
private BoosterRepository _repository;
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
@ -100,6 +116,19 @@ public class BoosterManager extends MiniPlugin
|
||||
_giveInterfaceItem = canActivateBoosters();
|
||||
|
||||
new BoosterUpdateRepository(plugin);
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,13 +1,14 @@
|
||||
package mineplex.core.boosters.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.boosters.BoosterApiResponse;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
@ -16,7 +17,7 @@ public class AddCommand extends CommandBase<BoosterManager>
|
||||
{
|
||||
public AddCommand(BoosterManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "add");
|
||||
super(plugin, BoosterManager.ADD_BOOSTER_COMMAND_PERMISSION, "add");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,6 +50,6 @@ public class AddCommand extends CommandBase<BoosterManager>
|
||||
|
||||
private void help(Player caller)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("amplifier add <servergroup>", "Add an amplifier to that server group", Rank.DEVELOPER));
|
||||
UtilPlayer.message(caller, F.help("amplifier add <servergroup>", "Add an amplifier to that server group", ChatColor.DARK_RED));
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package mineplex.core.boosters.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
@ -15,7 +15,7 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
||||
{
|
||||
public BoosterCommand(BoosterManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "amplifier");
|
||||
super(plugin, BoosterManager.BOOSTER_COMMAND_PERMISSION, "amplifier");
|
||||
|
||||
AddCommand(new AddCommand(plugin));
|
||||
AddCommand(new GuiCommand(plugin));
|
||||
@ -26,8 +26,8 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("amplifier add <group>", "Add an amplifier to that group", Rank.DEVELOPER));
|
||||
UtilPlayer.message(caller, F.help("amplifier gui", "Open Amplifier GUI", Rank.DEVELOPER));
|
||||
UtilPlayer.message(caller, F.help("amplifier thank <group>", "Thank an Amplifier for a specific Booster Group", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("amplifier add <group>", "Add an amplifier to that group", ChatColor.DARK_RED));
|
||||
UtilPlayer.message(caller, F.help("amplifier gui", "Open Amplifier GUI", ChatColor.DARK_RED));
|
||||
UtilPlayer.message(caller, F.help("amplifier thank <group>", "Thank an Amplifier for a specific Booster Group", ChatColor.WHITE));
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package mineplex.core.boosters.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
@ -12,7 +12,7 @@ public class GuiCommand extends CommandBase<BoosterManager>
|
||||
{
|
||||
public GuiCommand(BoosterManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "gui");
|
||||
super(plugin, BoosterManager.BOOSTER_GUI_COMMAND_PERMISSION, "gui");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,16 +1,11 @@
|
||||
package mineplex.core.boosters.command;
|
||||
|
||||
import mineplex.core.boosters.Booster;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
@ -19,13 +14,14 @@ public class ReloadCommand extends CommandBase<BoosterManager>
|
||||
{
|
||||
public ReloadCommand(BoosterManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "reload");
|
||||
super(plugin, BoosterManager.RELOAD_BOOSTERS_COMMAND_PERMISSION, "reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Plugin.getBoostersAsync(data -> {
|
||||
Plugin.getBoostersAsync(data ->
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Amplifier", "Amplifiers reloaded!"));
|
||||
|
@ -1,17 +1,17 @@
|
||||
package mineplex.core.boosters.command;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.boosters.Booster;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.boosters.tips.BoosterThankManager;
|
||||
import mineplex.core.boosters.tips.TipAddResult;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
@ -20,7 +20,7 @@ public class ThankCommand extends CommandBase<BoosterManager>
|
||||
{
|
||||
public ThankCommand(BoosterManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "thank");
|
||||
super(plugin, BoosterManager.THANK_COMMAND_PERMISSION, "thank");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,23 +11,31 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.account.permissions.PermissionManager;
|
||||
import mineplex.core.botspam.command.BotSpamCommand;
|
||||
import mineplex.core.botspam.repository.BotSpamRepository;
|
||||
import mineplex.core.message.PrivateMessageEvent;
|
||||
import mineplex.core.punish.Category;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.botspam.command.BotSpamCommand;
|
||||
import mineplex.core.botspam.repository.BotSpamRepository;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
public class BotSpamManager extends MiniPlugin
|
||||
{
|
||||
public static final String BYPASS_BOTSPAM_PERMISSION = "mineplex.core.botspam.bypass";
|
||||
public static final String BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.command";
|
||||
public static final String ADD_BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.add";
|
||||
public static final String TOGGLE_BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.toggle";
|
||||
public static final String UPDATE_BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.update";
|
||||
public static final String LIST_BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.list";
|
||||
|
||||
private Punish _punish;
|
||||
private CoreClientManager _clientManager;
|
||||
private BotSpamRepository _repository;
|
||||
|
||||
private volatile ArrayList<SpamText> _spam = new ArrayList<SpamText>();
|
||||
private volatile List<SpamText> _spam = new ArrayList<>();
|
||||
|
||||
public BotSpamManager(JavaPlugin plugin, CoreClientManager clientManager, Punish punish)
|
||||
{
|
||||
@ -39,6 +47,20 @@ public class BotSpamManager extends MiniPlugin
|
||||
_spam = _repository.getSpamText();
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType(ForceUpdateCommand.class, command -> runAsync(() -> _spam = _repository.getSpamText()));
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -46,11 +68,11 @@ public class BotSpamManager extends MiniPlugin
|
||||
{
|
||||
Player recipient = event.getRecipient();
|
||||
// Ignore messages sent to staff members
|
||||
if (_clientManager.hasRank(recipient, Rank.HELPER))
|
||||
if (_clientManager.getPermissionManager().hasPermission(recipient, GroupPermission.of(BYPASS_BOTSPAM_PERMISSION)))
|
||||
return;
|
||||
|
||||
// Ignore messages sent by staff members
|
||||
if (_clientManager.hasRank(event.getSender(), Rank.HELPER))
|
||||
if (_clientManager.getPermissionManager().hasPermission(event.getSender(), GroupPermission.of(BYPASS_BOTSPAM_PERMISSION)))
|
||||
return;
|
||||
|
||||
for (SpamText spamText : _spam)
|
||||
@ -68,7 +90,7 @@ public class BotSpamManager extends MiniPlugin
|
||||
public void onChat(final AsyncPlayerChatEvent event)
|
||||
{
|
||||
// Ignore messages sent by staff members
|
||||
if (_clientManager.hasRank(event.getPlayer(), Rank.HELPER))
|
||||
if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_BOTSPAM_PERMISSION)))
|
||||
return;
|
||||
|
||||
for (final SpamText spamText : _spam)
|
||||
@ -98,7 +120,9 @@ public class BotSpamManager extends MiniPlugin
|
||||
_spam = _repository.getSpamText();
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
runSync(callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -114,7 +138,9 @@ public class BotSpamManager extends MiniPlugin
|
||||
spamText.setEnabledBy(caller);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -131,7 +157,9 @@ public class BotSpamManager extends MiniPlugin
|
||||
spamText.setDisabledBy(caller);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -3,18 +3,17 @@ package mineplex.core.botspam.command;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
|
||||
public class BotSpamAddCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamAddCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "add");
|
||||
super(plugin, BotSpamManager.ADD_BOTSPAM_COMMAND_PERMISSION, "add");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ -12,7 +11,7 @@ public class BotSpamCommand extends MultiCommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "botban", "botspam");
|
||||
super(plugin, BotSpamManager.BOTSPAM_COMMAND_PERMISSION, "botban", "botspam");
|
||||
|
||||
AddCommand(new BotSpamAddCommand(Plugin));
|
||||
AddCommand(new BotSpamEnableCommand(Plugin));
|
||||
|
@ -2,10 +2,9 @@ package mineplex.core.botspam.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ -13,7 +12,7 @@ public class BotSpamDisableCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamDisableCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "disable");
|
||||
super(plugin, BotSpamManager.TOGGLE_BOTSPAM_COMMAND_PERMISSION, "disable");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,6 +58,5 @@ public class BotSpamDisableCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -2,10 +2,9 @@ package mineplex.core.botspam.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ -13,7 +12,7 @@ public class BotSpamEnableCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamEnableCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "enable");
|
||||
super(plugin, BotSpamManager.TOGGLE_BOTSPAM_COMMAND_PERMISSION, "enable");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,6 +58,5 @@ public class BotSpamEnableCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable <text id>"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -4,9 +4,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.botspam.ForceUpdateCommand;
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
@ -15,7 +13,7 @@ public class BotSpamGlobalUpdateCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamGlobalUpdateCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "globalupdate");
|
||||
super(plugin, BotSpamManager.UPDATE_BOTSPAM_COMMAND_PERMISSION, "globalupdate");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,28 +3,26 @@ package mineplex.core.botspam.command;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
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;
|
||||
|
||||
public class BotSpamListCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamListCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "list");
|
||||
super(plugin, BotSpamManager.LIST_BOTSPAM_COMMAND_PERMISSION, "list");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,25 +1,26 @@
|
||||
package mineplex.core.chat;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.antispam.AntiSpamManager;
|
||||
import mineplex.core.chat.command.BroadcastCommand;
|
||||
import mineplex.core.chat.command.ChatSlowCommand;
|
||||
import mineplex.core.chat.command.SilenceCommand;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.preferences.Preference;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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;
|
||||
@ -34,28 +35,40 @@ import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
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;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.account.permissions.PermissionManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.chat.command.BroadcastCommand;
|
||||
import mineplex.core.chat.command.ChatSlowCommand;
|
||||
import mineplex.core.chat.command.SilenceCommand;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.preferences.Preference;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class Chat extends MiniPlugin
|
||||
{
|
||||
public static final String ALLOW_CAPS_PERMISSION = "mineplex.core.chat.allowcaps";
|
||||
public static final String BYPASS_COOLDOWN_PERMISSION = "mineplex.core.chat.bypasscooldown";
|
||||
public static final String BYPASS_SLOW_PERMISSION = "mineplex.core.chat.bypasschatslow";
|
||||
public static final String BYPASS_SILENCE_PERMISSION = "mineplex.core.chat.bypasssilence";
|
||||
public static final String BYPASS_SIGNS_PERMISSION = "mineplex.core.chat.bypasssigns";
|
||||
public static final String ALLOW_HACKUSATE_PERMISSION = "mineplex.core.chat.allowhackusate";
|
||||
public static final String ALLOW_SIMILAR_PERMISSION = "mineplex.core.chat.allowsimilar";
|
||||
public static final String SILENCE_COMMAND_PERMISSION = "mineplex.core.chat.silence";
|
||||
public static final String SLOW_CHAT_COMMAND_PERMISSION = "mineplex.core.chat.chatslow";
|
||||
public static final String BROADCAST_COMMAND_PERMISSION = "mineplex.core.chat.broadcast";
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
private PreferencesManager _preferences;
|
||||
private AchievementManager _achievements;
|
||||
@ -73,7 +86,7 @@ public class Chat extends MiniPlugin
|
||||
private List<Function<AsyncPlayerChatEvent, Boolean>> _highPriorityFilters = new ArrayList<>();
|
||||
private List<Function<AsyncPlayerChatEvent, Boolean>> _lowPriorityFilters = new ArrayList<>();
|
||||
|
||||
private HashMap<UUID, MessageData> _playerLastMessage = new HashMap<UUID, MessageData>();
|
||||
private Map<UUID, MessageData> _playerLastMessage = new HashMap<>();
|
||||
|
||||
public Chat(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName)
|
||||
{
|
||||
@ -93,6 +106,23 @@ public class Chat extends MiniPlugin
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -190,7 +220,7 @@ public class Chat extends MiniPlugin
|
||||
if (_silenced == 0)
|
||||
return false;
|
||||
|
||||
if (_clientManager.Get(player).GetRank().has(player, Rank.MODERATOR, false))
|
||||
if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(BYPASS_SILENCE_PERMISSION)))
|
||||
return false;
|
||||
|
||||
if (_silenced == -1)
|
||||
@ -208,7 +238,10 @@ public class Chat extends MiniPlugin
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) return;
|
||||
if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_SIGNS_PERMISSION)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent silenced players from using signs
|
||||
if (SilenceCheck(event.getPlayer()))
|
||||
@ -343,13 +376,13 @@ public class Chat extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
|
||||
else if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(BYPASS_COOLDOWN_PERMISSION)) &&
|
||||
!Recharge.Instance.use(sender, "Chat Message", 400, false, false))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.HELPER) &&
|
||||
else if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(ALLOW_HACKUSATE_PERMISSION)) &&
|
||||
msgContainsHack(event.getMessage()))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat",
|
||||
@ -363,12 +396,12 @@ public class Chat extends MiniPlugin
|
||||
MessageData lastMessage = _playerLastMessage.get(sender.getUniqueId());
|
||||
long chatSlowTime = 1000L * _chatSlow;
|
||||
long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
|
||||
if (timeDiff < chatSlowTime && !_clientManager.Get(sender).GetRank().has(Rank.HELPER))
|
||||
if (timeDiff < chatSlowTime && !_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(BYPASS_SLOW_PERMISSION)))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat", "Chat slow enabled. Please wait " + F.time(UtilTime.convertString(chatSlowTime - timeDiff, 1, UtilTime.TimeUnit.FIT))));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
|
||||
else if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(ALLOW_SIMILAR_PERMISSION)) &&
|
||||
UtilText.isStringSimilar(event.getMessage(), lastMessage.getMessage(), 0.8f))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat", "This message is too similar to your previous message."));
|
||||
@ -379,7 +412,7 @@ public class Chat extends MiniPlugin
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
String oldMessage = event.getMessage();
|
||||
if (!_clientManager.Get(sender).GetRank().has(Rank.ADMIN))
|
||||
if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(ALLOW_CAPS_PERMISSION)))
|
||||
{
|
||||
int capsCount = 0;
|
||||
for (char c : oldMessage.toCharArray())
|
||||
@ -669,5 +702,4 @@ public class Chat extends MiniPlugin
|
||||
_lowPriorityFilters.add(restriction);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -13,7 +12,7 @@ public class BroadcastCommand extends CommandBase<Chat>
|
||||
{
|
||||
public BroadcastCommand(Chat plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "s");
|
||||
super(plugin, Chat.BROADCAST_COMMAND_PERMISSION, "s");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ -12,7 +11,7 @@ public class ChatSlowCommand extends CommandBase<Chat>
|
||||
{
|
||||
public ChatSlowCommand(Chat plugin)
|
||||
{
|
||||
super(plugin, Rank.SNR_MODERATOR, "chatslow");
|
||||
super(plugin, Chat.SLOW_CHAT_COMMAND_PERMISSION, "chatslow");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ -12,7 +11,7 @@ public class SilenceCommand extends CommandBase<Chat>
|
||||
{
|
||||
public SilenceCommand(Chat plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "silence");
|
||||
super(plugin, Chat.SILENCE_COMMAND_PERMISSION, "silence");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,6 +11,8 @@ 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.PermissionManager;
|
||||
import mineplex.core.chatsnap.command.ChatSnapCommand;
|
||||
import mineplex.core.message.PrivateMessageEvent;
|
||||
|
||||
@ -19,6 +21,8 @@ import mineplex.core.message.PrivateMessageEvent;
|
||||
*/
|
||||
public class SnapshotPlugin extends MiniPlugin
|
||||
{
|
||||
public static final String CHAT_SNAP_COMMAND_PERMISSION = "mineplex.core.chatsnap.command";
|
||||
|
||||
private final SnapshotManager _snapshotManager;
|
||||
private final CoreClientManager _clientManager;
|
||||
|
||||
@ -27,6 +31,15 @@ public class SnapshotPlugin extends MiniPlugin
|
||||
super("ChatSnap", plugin);
|
||||
_snapshotManager = snapshotManager;
|
||||
_clientManager = clientManager;
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
PermissionManager pm = _clientManager.getPermissionManager();
|
||||
|
||||
pm.setPermission(pm.getGroup("titan"), GroupPermission.of(CHAT_SNAP_COMMAND_PERMISSION), true, true);
|
||||
}
|
||||
|
||||
public SnapshotManager getSnapshotManager()
|
||||
|
@ -9,7 +9,6 @@ import mineplex.core.chatsnap.SnapshotMessage;
|
||||
import mineplex.core.chatsnap.SnapshotPlugin;
|
||||
import mineplex.core.chatsnap.SnapshotRepository;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -23,7 +22,7 @@ public class ChatSnapCommand extends CommandBase<SnapshotPlugin>
|
||||
{
|
||||
public ChatSnapCommand(SnapshotPlugin plugin)
|
||||
{
|
||||
super(plugin, Rank.TITAN, "chatsnap");
|
||||
super(plugin, SnapshotPlugin.CHAT_SNAP_COMMAND_PERMISSION, "chatsnap");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,34 +15,23 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.PlayerSelector;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.common.util.UtilLambda;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
public abstract class CommandBase<PluginType extends MiniPlugin> implements ICommand
|
||||
{
|
||||
private Rank _requiredRank;
|
||||
private Rank[] _specificRank;
|
||||
|
||||
private final GroupPermission _permission;
|
||||
private List<String> _aliases;
|
||||
|
||||
protected PluginType Plugin;
|
||||
protected String _aliasUsed;
|
||||
protected CommandCenter _commandCenter;
|
||||
|
||||
public CommandBase(PluginType plugin, Rank requiredRank, String... aliases)
|
||||
public CommandBase(PluginType plugin, String permission, String... aliases)
|
||||
{
|
||||
Plugin = plugin;
|
||||
_requiredRank = requiredRank;
|
||||
_aliases = Arrays.asList(aliases);
|
||||
}
|
||||
|
||||
public CommandBase(PluginType plugin, Rank requiredRank, Rank[] specificRank, String... aliases)
|
||||
{
|
||||
Plugin = plugin;
|
||||
_requiredRank = requiredRank;
|
||||
_specificRank = specificRank;
|
||||
|
||||
_permission = GroupPermission.of(permission);
|
||||
_aliases = Arrays.asList(aliases);
|
||||
}
|
||||
|
||||
@ -56,19 +45,9 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
|
||||
_aliasUsed = alias;
|
||||
}
|
||||
|
||||
public Rank GetRequiredRank()
|
||||
public GroupPermission getPermission()
|
||||
{
|
||||
return _requiredRank;
|
||||
}
|
||||
|
||||
public void setRequiredRank(Rank rank)
|
||||
{
|
||||
_requiredRank = rank;
|
||||
}
|
||||
|
||||
public Rank[] GetSpecificRanks()
|
||||
{
|
||||
return _specificRank;
|
||||
return _permission;
|
||||
}
|
||||
|
||||
public void SetCommandCenter(CommandCenter commandCenter)
|
||||
|
@ -1,17 +1,11 @@
|
||||
package mineplex.core.command;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
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;
|
||||
@ -22,15 +16,19 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilPlayerBase;
|
||||
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
|
||||
{
|
||||
@ -46,6 +44,8 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
|
||||
private static AtomicIntegerFieldUpdater<PlayerConnection> chatSpamField = null;
|
||||
|
||||
public static final String BLOCKED_COMMAND_PERMISSION = "mineplex.core.command.blockedexecute";
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
@ -83,6 +83,8 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
public void setClientManager(CoreClientManager clientManager)
|
||||
{
|
||||
ClientManager = clientManager;
|
||||
|
||||
clientManager.getPermissionManager().setPermission(clientManager.getPermissionManager().getGroup("dev"), GroupPermission.of(BLOCKED_COMMAND_PERMISSION), true, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -104,7 +106,7 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true)
|
||||
if (ClientManager.getPermissionManager().hasPermission(event.getPlayer(), command.getPermission())
|
||||
|| UtilPlayer.isCommandAllowed(event.getPlayer(), commandName.toLowerCase()))
|
||||
{
|
||||
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
|
||||
@ -122,10 +124,14 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
|
||||
command.Execute(event.getPlayer(), args);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayerBase.message(event.getPlayer(), C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER)))
|
||||
if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BLOCKED_COMMAND_PERMISSION))))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(MESSAGE);
|
||||
@ -199,7 +205,7 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
|
||||
if (command != null)
|
||||
{
|
||||
if (ClientManager.Get(packetInfo.getPlayer()).GetRank().has(packetInfo.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), false)
|
||||
if (ClientManager.getPermissionManager().hasPermission(packetInfo.getPlayer(), command.getPermission())
|
||||
|| UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase()))
|
||||
{
|
||||
List<String> tmpres = command.onTabComplete(packetInfo.getPlayer(), commandName.toLowerCase(), args);
|
||||
@ -216,7 +222,7 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
// System.out.println("Path 2");
|
||||
for (ICommand command : Commands.values())
|
||||
{
|
||||
if (ClientManager.Get(packetInfo.getPlayer()).GetRank().has(packetInfo.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), false)
|
||||
if (ClientManager.getPermissionManager().hasPermission(packetInfo.getPlayer(), command.getPermission())
|
||||
|| UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase()))
|
||||
{
|
||||
for (String alias : command.Aliases())
|
||||
|
@ -3,12 +3,12 @@ package mineplex.core.command;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
import mineplex.core.lifetimes.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.lifetimes.Component;
|
||||
|
||||
public interface ICommand extends Component
|
||||
{
|
||||
void SetCommandCenter(CommandCenter commandCenter);
|
||||
@ -18,8 +18,7 @@ public interface ICommand extends Component
|
||||
|
||||
void SetAliasUsed(String name);
|
||||
|
||||
Rank GetRequiredRank();
|
||||
Rank[] GetSpecificRanks();
|
||||
GroupPermission getPermission();
|
||||
|
||||
@Override
|
||||
default void activate()
|
||||
|
@ -7,11 +7,9 @@ package mineplex.core.command;
|
||||
*/
|
||||
public interface LoggedCommand
|
||||
{
|
||||
|
||||
default void execute(long time, String username, String command, String args)
|
||||
{
|
||||
LoggingServerCommand cmd = new LoggingServerCommand(time, username, command, args);
|
||||
cmd.publish();
|
||||
}
|
||||
|
||||
}
|
@ -9,23 +9,17 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayerBase;
|
||||
|
||||
public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends CommandBase<PluginType>
|
||||
{
|
||||
private NautHashMap<String, ICommand> Commands;
|
||||
|
||||
public MultiCommandBase(PluginType plugin, Rank rank, String... aliases)
|
||||
public MultiCommandBase(PluginType plugin, String permission, String... aliases)
|
||||
{
|
||||
super(plugin, rank, aliases);
|
||||
|
||||
Commands = new NautHashMap<>();
|
||||
}
|
||||
|
||||
public MultiCommandBase(PluginType plugin, Rank rank, Rank[] specificRanks, String... aliases)
|
||||
{
|
||||
super(plugin, rank, specificRanks, aliases);
|
||||
super(plugin, permission, aliases);
|
||||
|
||||
Commands = new NautHashMap<>();
|
||||
}
|
||||
@ -72,11 +66,18 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
|
||||
|
||||
ICommand command = Commands.get(commandName);
|
||||
|
||||
if (command != null && _commandCenter.ClientManager.Get(caller).GetRank().has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true))
|
||||
if (command != null)
|
||||
{
|
||||
command.SetAliasUsed(commandName);
|
||||
if (_commandCenter.ClientManager.getPermissionManager().hasPermission(caller, command.getPermission()))
|
||||
{
|
||||
command.SetAliasUsed(commandName);
|
||||
|
||||
command.Execute(caller, newArgs);
|
||||
command.Execute(caller, newArgs);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -105,7 +106,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
|
||||
Stream<ICommand> stream = Commands.values().stream();
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
stream = stream.filter(command -> _commandCenter.GetClientManager().Get((Player) sender).GetRank().has((Player) sender, command.GetRequiredRank(), command.GetSpecificRanks(), false));
|
||||
stream = stream.filter(command -> _commandCenter.GetClientManager().getPermissionManager().hasPermission((Player)sender, command.getPermission()));
|
||||
}
|
||||
return getMatches(args[0], stream.map(ICommand::Aliases).flatMap(Collection::stream));
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import mineplex.core.Managers;
|
||||
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.PermissionManager;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -71,6 +73,24 @@ import mineplex.serverdata.servers.ServerRepository;
|
||||
|
||||
public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
{
|
||||
public static final String OWN_COMMUNITY_PERMISSION = "mineplex.core.communities.own";
|
||||
public static final String COMMUNITY_CHAT_COMMAND_PERMISSION = "mineplex.core.communities.chat";
|
||||
public static final String COMMUNITY_COMMAND_PERMISSION = "mineplex.core.communities.command";
|
||||
public static final String COMMUNITY_DESCRIPTION_COMMAND_PERMISSION = "mineplex.core.communities.description";
|
||||
public static final String COMMUNITY_DESCRIPTION_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.description.staff";
|
||||
public static final String COMMUNITY_DISBAND_COMMAND_PERMISSION = "mineplex.core.communities.disband";
|
||||
public static final String COMMUNITY_DISBAND_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.disband.staff";
|
||||
public static final String COMMUNITY_INVITE_COMMAND_PERMISSION = "mineplex.core.communities.invite";
|
||||
public static final String COMMUNITY_INVITE_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.invite.staff";
|
||||
public static final String COMMUNITY_JOIN_COMMAND_PERMISSION = "mineplex.core.communities.join";
|
||||
public static final String COMMUNITY_MCS_COMMAND_PERMISSION = "mineplex.core.communities.mcs";
|
||||
public static final String COMMUNITY_MCS_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.mcs.staff";
|
||||
public static final String COMMUNITY_MENU_COMMAND_PERMISSION = "mineplex.core.communities.menu";
|
||||
public static final String COMMUNITY_RENAME_COMMAND_PERMISSION = "mineplex.core.communities.rename";
|
||||
public static final String COMMUNITY_RENAME_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.rename.staff";
|
||||
public static final String COMMUNITY_UNINVITE_COMMAND_PERMISSION = "mineplex.core.communities.uninvite";
|
||||
public static final String COMMUNITY_UNINVITE_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.uninvite.staff";
|
||||
|
||||
private final int UPDATE_CYCLE_SECONDS = 10; // The number of seconds between dirty communities refreshes
|
||||
private final int CACHE_INVALIDATION_SECONDS = 300; // The number of seconds between full communities refreshes
|
||||
public final Pattern ALPHA_NUMERIC_PATTERN = Pattern.compile("[^A-Za-z0-9]");
|
||||
@ -183,6 +203,31 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateMembership.class, new CommunityUpdateMembershipHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateName.class, new CommunityUpdateNameHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateSetting.class, new CommunityUpdateSettingHandler(this));
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public boolean ownsCommunity(UUID uuid)
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -14,7 +13,7 @@ public class CommunityChatCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityChatCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "chat");
|
||||
super(plugin, CommunityManager.COMMUNITY_CHAT_COMMAND_PERMISSION, "chat");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -22,7 +21,7 @@ public class CommunityChatCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com chat <community>", "Selects which community you chat to", Rank.ALL, ChatColor.AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com chat <community>", "Selects which community you chat to", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -16,7 +15,7 @@ public class CommunityCommand extends MultiCommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "community", "communities", "com");
|
||||
super(plugin, CommunityManager.COMMUNITY_COMMAND_PERMISSION, "community", "communities", "com");
|
||||
|
||||
AddCommand(new CommunityChatCommand(plugin));
|
||||
AddCommand(new CommunityCreateCommand(plugin));
|
||||
@ -38,17 +37,16 @@ public class CommunityCommand extends MultiCommandBase<CommunityManager>
|
||||
if (args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Community Commands:"));
|
||||
UtilPlayer.message(caller, F.help("/com <community>", "Opens a community's menu", Rank.ALL, ChatColor.DARK_AQUA));
|
||||
//UtilPlayer.message(caller, F.help("/com menu", "Opens your community menu", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/com invite <player> <community>", "Invites a player to a community you manage", Rank.ALL, ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com uninvite <player> <community>", "Revokes a player's invitation to a community you manage", Rank.ALL, ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com join <community>", "Joins a community that is open or you have been invited to", Rank.ALL, ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com chat <community>", "Selects which community you chat to", Rank.ALL, ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com create <name>", "Creates a new community", Rank.ETERNAL, ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com rename <community> <name>", "Changes the name of a community you own", Rank.ETERNAL, ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com mcs <community>", "Opens the Mineplex Community Server of a community you manage", Rank.ALL, ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com description <community> <description>", "Sets the description of a community you manage", Rank.ALL, ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", Rank.ETERNAL, ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com <community>", "Opens a community's menu", ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com invite <player> <community>", "Invites a player to a community you manage", ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com uninvite <player> <community>", "Revokes a player's invitation to a community you manage", ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com join <community>", "Joins a community that is open or you have been invited to", ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com chat <community>", "Selects which community you chat to", ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com create <name>", "Creates a new community", ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com rename <community> <name>", "Changes the name of a community you own", ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com mcs <community>", "Opens the Mineplex Community Server of a community you manage", ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com description <community> <description>", "Sets the description of a community you manage", ChatColor.DARK_AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
Community community = Plugin.getLoadedCommunity(args[0]);
|
||||
|
@ -9,7 +9,6 @@ import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -19,7 +18,7 @@ public class CommunityCreateCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityCreateCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ETERNAL, "create");
|
||||
super(plugin, CommunityManager.OWN_COMMUNITY_PERMISSION, "create");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,7 +26,7 @@ public class CommunityCreateCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com create <name>", "Creates a new community", Rank.ETERNAL, ChatColor.AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com create <name>", "Creates a new community", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
|
@ -5,9 +5,9 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -20,7 +20,7 @@ public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityDescriptionCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "description");
|
||||
super(plugin, CommunityManager.COMMUNITY_DESCRIPTION_COMMAND_PERMISSION, "description");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -28,7 +28,7 @@ public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com description <community> <description>", "Sets the description of a community you manage", Rank.ALL, ChatColor.AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com description <community> <description>", "Sets the description of a community you manage", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
@ -44,7 +44,7 @@ public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_DESCRIPTION_STAFF_COMMAND_PERMISSION)))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
|
@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -18,7 +18,7 @@ public class CommunityDisbandCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityDisbandCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ETERNAL, "disband");
|
||||
super(plugin, CommunityManager.COMMUNITY_DISBAND_COMMAND_PERMISSION, "disband");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,7 +26,7 @@ public class CommunityDisbandCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", Rank.ETERNAL, ChatColor.AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
@ -37,7 +37,7 @@ public class CommunityDisbandCommand extends CommandBase<CommunityManager>
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER)
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_DISBAND_STAFF_COMMAND_PERMISSION)))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
|
@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -18,7 +18,7 @@ public class CommunityInviteCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityInviteCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "invite");
|
||||
super(plugin, CommunityManager.COMMUNITY_INVITE_COMMAND_PERMISSION, "invite");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,7 +26,7 @@ public class CommunityInviteCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com invite <player> <community>", "Invites a player to a community you manage", Rank.ALL, ChatColor.AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com invite <player> <community>", "Invites a player to a community you manage", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
String player = args[0];
|
||||
@ -38,7 +38,7 @@ public class CommunityInviteCommand extends CommandBase<CommunityManager>
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_INVITE_STAFF_COMMAND_PERMISSION)))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -15,7 +14,7 @@ public class CommunityJoinCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityJoinCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "join");
|
||||
super(plugin, CommunityManager.COMMUNITY_JOIN_COMMAND_PERMISSION, "join");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -23,7 +22,7 @@ public class CommunityJoinCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com join <community>", "Joins a community that is open or you have been invited to", Rank.ALL, ChatColor.AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com join <community>", "Joins a community that is open or you have been invited to", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
|
@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -19,7 +19,7 @@ public class CommunityMCSCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityMCSCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "mcs");
|
||||
super(plugin, CommunityManager.COMMUNITY_MCS_COMMAND_PERMISSION, "mcs");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,7 +27,7 @@ public class CommunityMCSCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com mcs <community>", "Opens the Mineplex Community Server of a community you manage", Rank.ALL, ChatColor.AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com mcs <community>", "Opens the Mineplex Community Server of a community you manage", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
@ -38,7 +38,7 @@ public class CommunityMCSCommand extends CommandBase<CommunityManager>
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_MCS_STAFF_COMMAND_PERMISSION)))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
|
@ -3,7 +3,6 @@ package mineplex.core.communities.commands;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.communities.gui.overview.CommunityOverviewPage;
|
||||
|
||||
@ -11,7 +10,7 @@ public class CommunityMenuCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityMenuCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "menu");
|
||||
super(plugin, CommunityManager.COMMUNITY_MENU_COMMAND_PERMISSION, "menu");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,9 +7,9 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -21,7 +21,7 @@ public class CommunityRenameCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityRenameCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ETERNAL, "rename");
|
||||
super(plugin, CommunityManager.COMMUNITY_RENAME_COMMAND_PERMISSION, "rename");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -29,7 +29,7 @@ public class CommunityRenameCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com rename <community> <name>", "Changes the name of a community you own", Rank.ETERNAL, ChatColor.AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com rename <community> <name>", "Changes the name of a community you own", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
@ -41,7 +41,7 @@ public class CommunityRenameCommand extends CommandBase<CommunityManager>
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER)
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_RENAME_STAFF_COMMAND_PERMISSION)))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
|
@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
@ -18,7 +18,7 @@ public class CommunityUnInviteCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityUnInviteCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "uninvite");
|
||||
super(plugin, CommunityManager.COMMUNITY_UNINVITE_COMMAND_PERMISSION, "uninvite");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,7 +26,7 @@ public class CommunityUnInviteCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com uninvite <player> <community>", "Revokes a player's invitation to a community you manage", Rank.ALL, ChatColor.AQUA));
|
||||
UtilPlayer.message(caller, F.help("/com uninvite <player> <community>", "Revokes a player's invitation to a community you manage", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
String player = args[0];
|
||||
@ -38,7 +38,7 @@ public class CommunityUnInviteCommand extends CommandBase<CommunityManager>
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_UNINVITE_STAFF_COMMAND_PERMISSION)))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
|
@ -5,10 +5,11 @@ import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.communities.CommunityMemberInfo;
|
||||
import mineplex.core.communities.CommunityRole;
|
||||
import mineplex.core.communities.gui.CommunitiesGUIButton;
|
||||
@ -18,6 +19,7 @@ public class CommunityMemberButton extends CommunitiesGUIButton
|
||||
private Player _viewer;
|
||||
private Community _community;
|
||||
private CommunityMemberInfo _info;
|
||||
private boolean _fetching = false;
|
||||
|
||||
public CommunityMemberButton(Player viewer, Community community, CommunityMemberInfo info)
|
||||
{
|
||||
@ -37,6 +39,10 @@ public class CommunityMemberButton extends CommunitiesGUIButton
|
||||
@Override
|
||||
public void handleClick(ClickType type)
|
||||
{
|
||||
if (_fetching)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (type == ClickType.SHIFT_RIGHT)
|
||||
{
|
||||
if (getCommunityManager().Get(_viewer).getRoleIn(_community) != null && getCommunityManager().Get(_viewer).getRoleIn(_community).ordinal() < _info.Role.ordinal())
|
||||
@ -59,13 +65,25 @@ public class CommunityMemberButton extends CommunitiesGUIButton
|
||||
UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), F.name(_info.Name) + " can only own one community at a time!"));
|
||||
return;
|
||||
}
|
||||
if (!Rank.valueOf(Managers.get(CoreClientManager.class).loadOfflineClient(_info.UUID).Rank).has(Rank.ETERNAL))
|
||||
CoreClientManager clientManager = Managers.get(CoreClientManager.class);
|
||||
_fetching = true;
|
||||
clientManager.fetchGroups(_info.AccountId, pair ->
|
||||
{
|
||||
if (clientManager.getPermissionManager().hasPermission(pair, GroupPermission.of(CommunityManager.OWN_COMMUNITY_PERMISSION)))
|
||||
{
|
||||
getCommunityManager().handleRoleUpdate(_viewer, _community, _info, CommunityRole.LEADER);
|
||||
getCommunityManager().handleRoleUpdate(_viewer, _community, _community.getMembers().get(_viewer.getUniqueId()), CommunityRole.COLEADER);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), "Only Eternal rank and above can own a community!"));
|
||||
}
|
||||
_fetching = false;
|
||||
}, () ->
|
||||
{
|
||||
UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), "Only Eternal rank and above can own a community!"));
|
||||
return;
|
||||
}
|
||||
getCommunityManager().handleRoleUpdate(_viewer, _community, _info, CommunityRole.LEADER);
|
||||
getCommunityManager().handleRoleUpdate(_viewer, _community, _community.getMembers().get(_viewer.getUniqueId()), CommunityRole.COLEADER);
|
||||
_fetching = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package mineplex.core.cosmetic.ui.page;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -12,12 +11,10 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
|
||||
public class WinEffectPage extends GadgetPage
|
||||
{
|
||||
|
||||
public WinEffectPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name,
|
||||
Player player)
|
||||
{
|
||||
@ -34,7 +31,7 @@ public class WinEffectPage extends GadgetPage
|
||||
if (gadget instanceof WinEffectRankBased)
|
||||
{
|
||||
WinEffectRankBased rankBased = (WinEffectRankBased) gadget;
|
||||
if (getClientManager().Get(getPlayer()).GetRank().has(rankBased.getRank()))
|
||||
if (getClientManager().getPermissionManager().hasPermission(getPlayer(), rankBased.getUnlockPermission()))
|
||||
{
|
||||
addGadget(gadget, slot);
|
||||
}
|
||||
@ -61,13 +58,9 @@ public class WinEffectPage extends GadgetPage
|
||||
}
|
||||
}
|
||||
|
||||
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
|
||||
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) ->
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
|
||||
}
|
||||
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -4,22 +4,14 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.creature.command.MobCommand;
|
||||
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -31,14 +23,43 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.GroupPermission;
|
||||
import mineplex.core.account.permissions.PermissionManager;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.creature.command.MobCommand;
|
||||
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class Creature extends MiniPlugin
|
||||
{
|
||||
public static final String MOB_COMMAND_PERMISSION = "mineplex.core.mob.command";
|
||||
public static final String KILL_MOB_COMMAND_PERMISSION = "mineplex.core.mob.kill";
|
||||
|
||||
private boolean _spawnForce = false;
|
||||
private boolean _disableCustom = false;
|
||||
|
||||
public Creature(JavaPlugin plugin)
|
||||
{
|
||||
super("Creature", plugin);
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,26 +0,0 @@
|
||||
package mineplex.core.creature.command;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.creature.Creature;
|
||||
|
||||
public class HelpCommand extends CommandBase<Creature>
|
||||
{
|
||||
public HelpCommand(Creature plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "help");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Commands List;"));
|
||||
UtilPlayer.message(caller, F.help("/mob", "List Entities", Rank.MODERATOR));
|
||||
UtilPlayer.message(caller, F.help("/mob kill <Type>", "Remove Entities of Type", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/mob <Type> (# baby lock angry s# <Prof>)", "Create", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.desc("Professions", "Butcher, Blacksmith, Farmer, Librarian, Priest"));
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -21,7 +20,7 @@ public class KillCommand extends CommandBase<Creature>
|
||||
{
|
||||
public KillCommand(Creature plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "kill", "k");
|
||||
super(plugin, Creature.KILL_MOB_COMMAND_PERMISSION, "kill", "k");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.creature.command;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -21,7 +22,6 @@ import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Zombie;
|
||||
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -32,7 +32,7 @@ public class MobCommand extends MultiCommandBase<Creature>
|
||||
{
|
||||
public MobCommand(Creature plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "mob");
|
||||
super(plugin, Creature.MOB_COMMAND_PERMISSION, "mob");
|
||||
|
||||
AddCommand(new KillCommand(Plugin));
|
||||
}
|
||||
@ -42,7 +42,7 @@ public class MobCommand extends MultiCommandBase<Creature>
|
||||
{
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
HashMap<EntityType, Integer> entMap = new HashMap<EntityType, Integer>();
|
||||
Map<EntityType, Integer> entMap = new HashMap<>();
|
||||
|
||||
int count = 0;
|
||||
for (World world : UtilServer.getServer().getWorlds())
|
||||
@ -75,7 +75,7 @@ public class MobCommand extends MultiCommandBase<Creature>
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Spawning Creature(s);"));
|
||||
|
||||
//Store Args
|
||||
HashSet<String> argSet = new HashSet<String>();
|
||||
Set<String> argSet = new HashSet<>();
|
||||
for (int i = 1 ; i < args.length ; i++)
|
||||
if (args[i].length() > 0)
|
||||
argSet.add(args[i]);
|
||||
@ -83,7 +83,7 @@ public class MobCommand extends MultiCommandBase<Creature>
|
||||
|
||||
//Search Count
|
||||
int count = 1;
|
||||
HashSet<String> argHandle = new HashSet<String>();
|
||||
Set<String> argHandle = new HashSet<>();
|
||||
for (String arg : argSet)
|
||||
{
|
||||
try
|
||||
@ -110,7 +110,7 @@ public class MobCommand extends MultiCommandBase<Creature>
|
||||
argSet.remove(arg);
|
||||
|
||||
//Spawn
|
||||
HashSet<Entity> entSet = new HashSet<Entity>();
|
||||
Set<Entity> entSet = new HashSet<>();
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{
|
||||
entSet.add(Plugin.SpawnEntity(caller.getTargetBlock((Set<Material>) null, 150).getLocation().add(0.5, 1, 0.5), type));
|
||||
|
@ -1,11 +1,11 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import mineplex.core.common.*;
|
||||
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
||||
|
||||
public abstract class DisguiseInsentient extends DisguiseLiving
|
||||
{
|
||||
private boolean _showArmor;
|
||||
@ -23,13 +23,13 @@ public abstract class DisguiseInsentient extends DisguiseLiving
|
||||
setName(name, null);
|
||||
}
|
||||
|
||||
public void setName(String name, Rank rank)
|
||||
public void setName(String name, PermissionGroup group)
|
||||
{
|
||||
if (rank != null)
|
||||
if (group != null)
|
||||
{
|
||||
if (rank.has(Rank.ULTRA))
|
||||
if (!group.getDisplay(false, false, false, false).isEmpty())
|
||||
{
|
||||
name = rank.getTag(true, true) + " " + ChatColor.RESET + name;
|
||||
name = group.getDisplay(true, true, true, false) + " " + ChatColor.RESET + name;
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user