Merge remote-tracking branch 'refs/remotes/origin/develop' into update/moba-cosmetics
This commit is contained in:
commit
cd99700eda
@ -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 org.bukkit.ChatColor;
|
||||||
|
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.currency.Currency;
|
import mineplex.core.common.currency.Currency;
|
||||||
|
|
||||||
public class F
|
public class F
|
||||||
@ -103,23 +102,10 @@ public class F
|
|||||||
{
|
{
|
||||||
return C.wFrame + "[" + C.wField + field + C.wFrame + "] " + C.mBody + data + " ";
|
return C.wFrame + "[" + C.wField + field + C.wFrame + "] " + C.mBody + data + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String help(String cmd, String body, Rank rank)
|
|
||||||
{
|
|
||||||
return rank.getColor() + cmd + " " + C.mBody + body + " " + rank(rank);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String help(String cmd, String body, Rank rank, ChatColor displayColor)
|
public static String help(String cmd, String body, ChatColor displayColor)
|
||||||
{
|
{
|
||||||
return displayColor + cmd + " " + C.mBody + body + " " + rank(rank);
|
return displayColor + cmd + " " + C.mBody + body;
|
||||||
}
|
|
||||||
|
|
||||||
public static String rank(Rank rank)
|
|
||||||
{
|
|
||||||
if (rank == Rank.ALL)
|
|
||||||
return rank.getColor() + "Player";
|
|
||||||
|
|
||||||
return rank.getTag(false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String value(String variable, int value)
|
public static String value(String variable, int value)
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package mineplex.core.common.util;
|
package mineplex.core.common.util;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityTameableAnimal;
|
import net.minecraft.server.v1_8_R3.EntityTameableAnimal;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.libs.com.google.common.base.Optional;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftTameableAnimal;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftTameableAnimal;
|
||||||
import org.bukkit.entity.AnimalTamer;
|
import org.bukkit.entity.AnimalTamer;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
package mineplex.core;
|
package mineplex.core;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
import java.util.List;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import mineplex.core.common.Rank;
|
import java.util.function.Predicate;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import java.util.stream.Collectors;
|
||||||
import mineplex.core.incognito.IncognitoManager;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import mineplex.core.account.CoreClient;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import java.util.function.Predicate;
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import java.util.stream.Collectors;
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.incognito.IncognitoManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper for selecting arbitrary players given a set of conditions
|
* 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;
|
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 useDisguisedRank Whether to use the disguised rank of the player should they be disguised
|
||||||
* @param ranks The ranks to check
|
* @param ranks The ranks to check
|
||||||
* @return The resulting criterion
|
* @return The resulting criterion
|
||||||
*/
|
*/
|
||||||
public static Predicate<Player> hasAnyRank(boolean useDisguisedRank, Rank... ranks)
|
public static Predicate<Player> hasAnyRank(boolean useDisguisedRank, PermissionGroup... groups)
|
||||||
{
|
{
|
||||||
return player ->
|
return player ->
|
||||||
{
|
{
|
||||||
@ -90,11 +91,11 @@ public class PlayerSelector
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CoreClient client = coreClientManager.Get(player);
|
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 == requiredGroup)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -119,4 +120,4 @@ public class PlayerSelector
|
|||||||
{
|
{
|
||||||
return player -> UtilMath.offset(player.getLocation(), center) <= radius;
|
return player -> UtilMath.offset(player.getLocation(), center) <= radius;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +1,15 @@
|
|||||||
package mineplex.core.account;
|
package mineplex.core.account;
|
||||||
|
|
||||||
import mineplex.core.account.event.OnlineRankUpdateEvent;
|
import java.util.HashSet;
|
||||||
import mineplex.core.common.Rank;
|
import java.util.Set;
|
||||||
import mineplex.core.common.util.C;
|
import java.util.UUID;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import java.util.stream.Collectors;
|
||||||
import mineplex.serverdata.Utility;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
import mineplex.serverdata.Utility;
|
||||||
|
|
||||||
public class CoreClient
|
public class CoreClient
|
||||||
{
|
{
|
||||||
@ -18,8 +18,8 @@ public class CoreClient
|
|||||||
private String _name;
|
private String _name;
|
||||||
private UUID _uuid;
|
private UUID _uuid;
|
||||||
private Player _player;
|
private Player _player;
|
||||||
private Rank _rank, _lastRank;
|
private PermissionGroup _primary;
|
||||||
private Rank _tempRank, _lastTemp;
|
private Set<PermissionGroup> _extra = new HashSet<>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disguise info
|
* Disguise info
|
||||||
@ -27,7 +27,7 @@ public class CoreClient
|
|||||||
private String _disguisedName;
|
private String _disguisedName;
|
||||||
private String _disguisedSkin;
|
private String _disguisedSkin;
|
||||||
private UUID _disguisedUUID;
|
private UUID _disguisedUUID;
|
||||||
private Rank _disguisedRank;
|
private PermissionGroup _disguisedPrimary;
|
||||||
|
|
||||||
public CoreClient(Player player)
|
public CoreClient(Player player)
|
||||||
{
|
{
|
||||||
@ -72,60 +72,64 @@ public class CoreClient
|
|||||||
{
|
{
|
||||||
_accountId = accountId;
|
_accountId = accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank GetRank()
|
protected PermissionGroup getRawPrimaryGroup()
|
||||||
{
|
{
|
||||||
return GetRank(false);
|
return _primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank GetRank(boolean bypass)
|
public PermissionGroup getPrimaryGroup()
|
||||||
{
|
{
|
||||||
if (_rank == null)
|
if (_primary == null)
|
||||||
_rank = Rank.ALL;
|
{
|
||||||
|
_primary = PermissionGroup.PLAYER;
|
||||||
|
}
|
||||||
|
|
||||||
if (bypass || _tempRank == null)
|
return _primary;
|
||||||
return _rank;
|
}
|
||||||
else
|
|
||||||
return _tempRank;
|
public Set<PermissionGroup> getAdditionalGroups()
|
||||||
|
{
|
||||||
|
return _extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank GetLastRank(boolean temp)
|
public boolean inheritsFrom(PermissionGroup group)
|
||||||
{
|
{
|
||||||
if (temp)
|
return _primary.inheritsFrom(group) || _extra.stream().anyMatch(memberGroup -> memberGroup.inheritsFrom(group));
|
||||||
{
|
|
||||||
if ((_lastTemp == null) && (_tempRank == null))
|
|
||||||
{
|
|
||||||
return _rank;
|
|
||||||
}
|
|
||||||
else if (_lastTemp == null)
|
|
||||||
{
|
|
||||||
return _tempRank;
|
|
||||||
}
|
|
||||||
return _lastTemp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_lastRank == null) return _rank;
|
|
||||||
return _lastRank;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRank(Rank rank, boolean temp)
|
public boolean hasPermission(Permission permission)
|
||||||
{
|
{
|
||||||
if (temp)
|
return _primary.hasPermission(permission) || _extra.stream().anyMatch(memberGroup -> memberGroup.hasPermission(permission));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMemberOf(PermissionGroup group)
|
||||||
|
{
|
||||||
|
return group == _primary || _extra.contains(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrimaryGroup(PermissionGroup group)
|
||||||
|
{
|
||||||
|
if (group != null && !group.canBePrimary())
|
||||||
{
|
{
|
||||||
if (_lastTemp == null) _lastTemp = rank;
|
return;
|
||||||
else _lastTemp = _tempRank;
|
|
||||||
_lastRank = _rank;
|
|
||||||
_tempRank = rank;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
_primary = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAdditionalGroup(PermissionGroup group)
|
||||||
|
{
|
||||||
|
if (!isMemberOf(group))
|
||||||
{
|
{
|
||||||
if (_rank != null) _lastRank = _rank;
|
_extra.add(group);
|
||||||
else _lastRank = rank;
|
|
||||||
_rank = rank;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeAdditionalGroup(PermissionGroup group)
|
||||||
|
{
|
||||||
|
_extra.remove(group);
|
||||||
|
}
|
||||||
|
|
||||||
public long getNetworkSessionLoginTime()
|
public long getNetworkSessionLoginTime()
|
||||||
{
|
{
|
||||||
@ -136,7 +140,7 @@ public class CoreClient
|
|||||||
{
|
{
|
||||||
_disguisedName = null;
|
_disguisedName = null;
|
||||||
_disguisedSkin = null;
|
_disguisedSkin = null;
|
||||||
_disguisedRank = null;
|
_disguisedPrimary = null;
|
||||||
_disguisedUUID = null;
|
_disguisedUUID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,9 +154,9 @@ public class CoreClient
|
|||||||
return _disguisedSkin;
|
return _disguisedSkin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank getDisguisedRank()
|
public PermissionGroup getDisguisedPrimaryGroup()
|
||||||
{
|
{
|
||||||
return _disguisedRank;
|
return _disguisedPrimary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDisguisedAsUUID()
|
public UUID getDisguisedAsUUID()
|
||||||
@ -169,20 +173,20 @@ public class CoreClient
|
|||||||
return !_name.equalsIgnoreCase(_disguisedName);
|
return !_name.equalsIgnoreCase(_disguisedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disguise(String name, UUID uuid, Rank rank)
|
public void disguise(String name, UUID uuid, PermissionGroup group)
|
||||||
{
|
{
|
||||||
_disguisedName = name;
|
_disguisedName = name;
|
||||||
_disguisedUUID = uuid;
|
_disguisedUUID = uuid;
|
||||||
_disguisedRank = rank;
|
_disguisedPrimary = 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)
|
public void setNetworkSessionLoginTime(long loginTime)
|
||||||
@ -190,22 +194,12 @@ public class CoreClient
|
|||||||
_networkSessionLoginTime = loginTime;
|
_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()
|
public String getRealOrDisguisedName()
|
||||||
{
|
{
|
||||||
if (getDisguisedAs() != null)
|
if (getDisguisedAs() != null)
|
||||||
|
{
|
||||||
return getDisguisedAs();
|
return getDisguisedAs();
|
||||||
|
}
|
||||||
return getName();
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +211,8 @@ public class CoreClient
|
|||||||
", _name='" + _name + '\'' +
|
", _name='" + _name + '\'' +
|
||||||
", _uuid=" + _uuid +
|
", _uuid=" + _uuid +
|
||||||
", _player=" + _player +
|
", _player=" + _player +
|
||||||
", _rank=" + _rank +
|
", _primary=" + _primary +
|
||||||
|
", _extra=[" + _extra.stream().map(PermissionGroup::toString).collect(Collectors.joining(", ")) + "]" +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,13 +10,15 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -33,14 +35,24 @@ import com.google.gson.Gson;
|
|||||||
import mineplex.cache.player.PlayerCache;
|
import mineplex.cache.player.PlayerCache;
|
||||||
import mineplex.cache.player.PlayerInfo;
|
import mineplex.cache.player.PlayerInfo;
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.command.TestRank;
|
import mineplex.core.account.command.RanksCommand;
|
||||||
import mineplex.core.account.command.UpdateRank;
|
|
||||||
import mineplex.core.account.event.ClientUnloadEvent;
|
import mineplex.core.account.event.ClientUnloadEvent;
|
||||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||||
import mineplex.core.account.event.RankSaveEvent;
|
import mineplex.core.account.event.OnlinePrimaryGroupUpdateEvent;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroupHelper;
|
||||||
|
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.AccountRepository;
|
||||||
import mineplex.core.account.repository.token.ClientToken;
|
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.timing.TimingManager;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
@ -51,15 +63,28 @@ import mineplex.core.updater.UpdateType;
|
|||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.utils.UtilGameProfile;
|
import mineplex.core.utils.UtilGameProfile;
|
||||||
import mineplex.core.utils.UtilScheduler;
|
import mineplex.core.utils.UtilScheduler;
|
||||||
|
import mineplex.serverdata.commands.ServerCommandManager;
|
||||||
|
|
||||||
public class CoreClientManager extends MiniPlugin
|
public class CoreClientManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
JOIN_FULL,
|
||||||
|
RANK_COMMAND,
|
||||||
|
ADD_RANK_COMMAND,
|
||||||
|
RANK_INFO_COMMAND,
|
||||||
|
LIST_RANKS_COMMAND,
|
||||||
|
REMOVE_RANK_COMMAND,
|
||||||
|
RESET_PLAYER_COMMAND,
|
||||||
|
SET_RANK_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<String, Object> CLIENT_LOGIN_LOCKS = new ConcurrentHashMap<>();
|
private static final Map<String, Object> CLIENT_LOGIN_LOCKS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private JavaPlugin _plugin;
|
private JavaPlugin _plugin;
|
||||||
private AccountRepository _repository;
|
private AccountRepository _repository;
|
||||||
private Map<UUID, CoreClient> _clientList = new HashMap<>();
|
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<>();
|
private List<ILoginProcessor> _loginProcessors = new ArrayList<>();
|
||||||
|
|
||||||
@ -68,30 +93,44 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
|
private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
|
||||||
private static AtomicInteger _clientsProcessing = new AtomicInteger(0);
|
private static AtomicInteger _clientsProcessing = new AtomicInteger(0);
|
||||||
|
|
||||||
private final Rank WHITELIST_BYPASS;
|
|
||||||
|
|
||||||
private final Set<UUID> _reservedSlots = Sets.newConcurrentHashSet();
|
private final Set<UUID> _reservedSlots = Sets.newConcurrentHashSet();
|
||||||
|
|
||||||
public CoreClientManager(JavaPlugin plugin)
|
public CoreClientManager(JavaPlugin plugin)
|
||||||
{
|
|
||||||
this(plugin, Rank.MODERATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreClientManager(JavaPlugin plugin, Rank whitelistBypass)
|
|
||||||
{
|
{
|
||||||
super("Client Manager", plugin);
|
super("Client Manager", plugin);
|
||||||
|
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
_repository = new AccountRepository();
|
_repository = new AccountRepository();
|
||||||
WHITELIST_BYPASS = whitelistBypass;
|
|
||||||
|
|
||||||
UtilScheduler.runEvery(UpdateType.TICK, this::checkForIllegalAccounts);
|
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 generatePermissions()
|
||||||
|
{
|
||||||
|
PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.RANK_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.ADD_RANK_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.RANK_INFO_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.LIST_RANKS_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.REMOVE_RANK_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.RESET_PLAYER_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.SET_RANK_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForIllegalAccounts() {
|
private void checkForIllegalAccounts()
|
||||||
|
{
|
||||||
// Use getOnlinePlayers because in the future, I might change UtilServer.getPlayers to account for vanish
|
// Use getOnlinePlayers because in the future, I might change UtilServer.getPlayers to account for vanish
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
if (Get(player).getAccountId() == -1) {
|
{
|
||||||
|
if (Get(player).getAccountId() == -1)
|
||||||
|
{
|
||||||
// ew ew getim outta here
|
// ew ew getim outta here
|
||||||
player.kickPlayer("There was a problem logging you in");
|
player.kickPlayer("There was a problem logging you in");
|
||||||
}
|
}
|
||||||
@ -102,12 +141,11 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
return _repository;
|
return _repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCommands()
|
public void addCommands()
|
||||||
{
|
{
|
||||||
addCommand(new UpdateRank(this));
|
addCommand(new RanksCommand(this));
|
||||||
addCommand(new TestRank(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreClient Add(String name, UUID uuid)
|
public CoreClient Add(String name, UUID uuid)
|
||||||
@ -209,7 +247,9 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
_clientsProcessing.incrementAndGet();
|
_clientsProcessing.incrementAndGet();
|
||||||
|
|
||||||
if (!LoadClient(Add(event.getName(), event.getUniqueId()), event.getUniqueId(), event.getAddress().getHostAddress()))
|
if (!LoadClient(Add(event.getName(), event.getUniqueId()), event.getUniqueId(), event.getAddress().getHostAddress()))
|
||||||
|
{
|
||||||
event.disallow(Result.KICK_OTHER, "There was a problem logging you in.");
|
event.disallow(Result.KICK_OTHER, "There was a problem logging you in.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -220,19 +260,6 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
_clientsProcessing.decrementAndGet();
|
_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
|
finally
|
||||||
{
|
{
|
||||||
@ -280,8 +307,23 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoreClient client = Add(token.Name, uuid);
|
CoreClient client = Add(token.Name, uuid);
|
||||||
client.SetRank(Rank.valueOf(token.Rank), false);
|
Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> result = _repository.login(_loginProcessors, uuid, client.getName());
|
||||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName()));
|
|
||||||
|
client.setAccountId(result.getLeft());
|
||||||
|
if (result.getRight().getLeft() == null)
|
||||||
|
{
|
||||||
|
PermissionGroup newGroup = PermissionGroupHelper.getGroupFromLegacy(token.Rank);
|
||||||
|
client.setPrimaryGroup(newGroup);
|
||||||
|
_repository.setPrimaryGroup(client.getAccountId(), newGroup, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.setPrimaryGroup(result.getRight().getLeft());
|
||||||
|
}
|
||||||
|
for (PermissionGroup group : result.getRight().getRight())
|
||||||
|
{
|
||||||
|
client.addAdditionalGroup(group);
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
|
|
||||||
@ -323,9 +365,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
|
|
||||||
if (uuid == null)
|
if (uuid == null)
|
||||||
{
|
{
|
||||||
uuid = UtilGameProfile.getProfileByName(playerName, false, profile ->
|
uuid = UtilGameProfile.getProfileByName(playerName, false, profile -> {}).get().getId();
|
||||||
{
|
|
||||||
}).get().getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String response = "";
|
String response = "";
|
||||||
@ -342,8 +382,23 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
token = gson.fromJson(response, ClientToken.class);
|
token = gson.fromJson(response, ClientToken.class);
|
||||||
|
|
||||||
CoreClient client = Add(playerName, uuid);
|
CoreClient client = Add(playerName, uuid);
|
||||||
client.SetRank(Rank.valueOf(token.Rank), false);
|
Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> result = _repository.login(_loginProcessors, uuid, client.getName());
|
||||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName()));
|
|
||||||
|
client.setAccountId(result.getLeft());
|
||||||
|
if (result.getRight().getLeft() == null)
|
||||||
|
{
|
||||||
|
PermissionGroup newGroup = PermissionGroupHelper.getGroupFromLegacy(token.Rank);
|
||||||
|
client.setPrimaryGroup(newGroup);
|
||||||
|
_repository.setPrimaryGroup(client.getAccountId(), newGroup, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.setPrimaryGroup(result.getRight().getLeft());
|
||||||
|
}
|
||||||
|
for (PermissionGroup group : result.getRight().getRight())
|
||||||
|
{
|
||||||
|
client.addAdditionalGroup(group);
|
||||||
|
}
|
||||||
|
|
||||||
// JSON sql response
|
// JSON sql response
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
@ -402,8 +457,23 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
token = gson.fromJson(response, ClientToken.class);
|
token = gson.fromJson(response, ClientToken.class);
|
||||||
|
|
||||||
CoreClient client = Add(playerName, uuid);
|
CoreClient client = Add(playerName, uuid);
|
||||||
client.SetRank(Rank.valueOf(token.Rank), false);
|
Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> result = _repository.login(_loginProcessors, uuid, client.getName());
|
||||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName()));
|
|
||||||
|
client.setAccountId(result.getLeft());
|
||||||
|
if (result.getRight().getLeft() == null)
|
||||||
|
{
|
||||||
|
PermissionGroup newGroup = PermissionGroupHelper.getGroupFromLegacy(token.Rank);
|
||||||
|
client.setPrimaryGroup(newGroup);
|
||||||
|
_repository.setPrimaryGroup(client.getAccountId(), newGroup, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.setPrimaryGroup(result.getRight().getLeft());
|
||||||
|
}
|
||||||
|
for (PermissionGroup group : result.getRight().getRight())
|
||||||
|
{
|
||||||
|
client.addAdditionalGroup(group);
|
||||||
|
}
|
||||||
|
|
||||||
// JSON sql response
|
// JSON sql response
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
@ -436,42 +506,38 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
long timeStart = System.currentTimeMillis();
|
long timeStart = System.currentTimeMillis();
|
||||||
|
|
||||||
CLIENT_LOGIN_LOCKS.put(client.getName(), new Object());
|
CLIENT_LOGIN_LOCKS.put(client.getName(), new Object());
|
||||||
ClientToken token = null;
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
runAsync(new Runnable()
|
runAsync(() ->
|
||||||
{
|
{
|
||||||
@Override
|
try
|
||||||
public void run()
|
|
||||||
{
|
{
|
||||||
try
|
Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> result = _repository.login(_loginProcessors, uuid, client.getName());
|
||||||
|
client.setAccountId(result.getLeft());
|
||||||
|
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
|
client.setPrimaryGroup(result.getRight().getLeft());
|
||||||
e.printStackTrace();
|
}
|
||||||
|
for (PermissionGroup group : result.getRight().getRight())
|
||||||
|
{
|
||||||
|
client.addAdditionalGroup(group);
|
||||||
}
|
}
|
||||||
CLIENT_LOGIN_LOCKS.remove(client.getName());
|
|
||||||
}
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
CLIENT_LOGIN_LOCKS.remove(client.getName());
|
||||||
});
|
});
|
||||||
|
|
||||||
TimingManager.start(client.getName() + " GetClient.");
|
TimingManager.start(client.getName() + " GetClient.");
|
||||||
String response = _repository.GetClient(client.getName(), uuid, ipAddress);
|
String response = _repository.GetClient(client.getName(), uuid, ipAddress);
|
||||||
TimingManager.stop(client.getName() + " GetClient.");
|
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));
|
|
||||||
TimingManager.stop(client.getName() + " Event.");
|
|
||||||
|
|
||||||
TimingManager.start(client.getName() + " While Loop.");
|
TimingManager.start(client.getName() + " While Loop.");
|
||||||
while (CLIENT_LOGIN_LOCKS.containsKey(client.getName()) && System.currentTimeMillis() - timeStart < 15000)
|
while (CLIENT_LOGIN_LOCKS.containsKey(client.getName()) && System.currentTimeMillis() - timeStart < 15000)
|
||||||
{
|
{
|
||||||
@ -490,6 +556,21 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
System.out.println("MYSQL TOO LONG TO LOGIN....");
|
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 = PermissionGroupHelper.getGroupFromLegacy(mssqlRank);
|
||||||
|
client.setPrimaryGroup(newGroup);
|
||||||
|
_repository.setPrimaryGroup(client.getAccountId(), newGroup, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
TimingManager.start(client.getName() + " Event.");
|
||||||
|
// JSON sql response
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||||
|
TimingManager.stop(client.getName() + " Event.");
|
||||||
|
|
||||||
TimingManager.stop(client.getName() + " LoadClient Total.");
|
TimingManager.stop(client.getName() + " LoadClient Total.");
|
||||||
|
|
||||||
@ -520,7 +601,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
|
|
||||||
CoreClient client = Get(event.getPlayer().getUniqueId());
|
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.");
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect.");
|
||||||
return;
|
return;
|
||||||
@ -533,7 +614,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
// Reserved Slot Check
|
// Reserved Slot Check
|
||||||
if (Bukkit.getOnlinePlayers().size() + _reservedSlots.size() >= Bukkit.getServer().getMaxPlayers())
|
if (Bukkit.getOnlinePlayers().size() + _reservedSlots.size() >= Bukkit.getServer().getMaxPlayers())
|
||||||
{
|
{
|
||||||
if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false))
|
if (client.hasPermission(Perm.JOIN_FULL))
|
||||||
{
|
{
|
||||||
event.allow();
|
event.allow();
|
||||||
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||||
@ -546,7 +627,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
|
|
||||||
public void reserveFor(UUID player)
|
public void reserveFor(UUID player)
|
||||||
{
|
{
|
||||||
this._reservedSlots.add(player);
|
_reservedSlots.add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unreserve(UUID uuid)
|
public void unreserve(UUID uuid)
|
||||||
@ -560,14 +641,14 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
if (event.getReason().contains("You logged in from another location"))
|
if (event.getReason().contains("You logged in from another location"))
|
||||||
{
|
{
|
||||||
_duplicateLoginGlitchPreventionList.add(event.getPlayer().getUniqueId());
|
_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;
|
return;
|
||||||
Player p = _clientList.get(event.getPlayer().getUniqueId()).GetPlayer();
|
|
||||||
p.kickPlayer("You're already logged in.");
|
|
||||||
}
|
}
|
||||||
|
Player p = _clientList.get(event.getPlayer().getUniqueId()).GetPlayer();
|
||||||
|
p.kickPlayer("You're already logged in.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -589,108 +670,170 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
_duplicateLoginGlitchPreventionList.remove(event.getPlayer().getUniqueId());
|
_duplicateLoginGlitchPreventionList.remove(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
after.run();
|
||||||
{
|
|
||||||
CoreClient client = Get(name);
|
|
||||||
|
|
||||||
client.SetRank(newRank, false);
|
|
||||||
}
|
|
||||||
UtilServer.CallEvent(new RankSaveEvent(uuid, newRank));
|
|
||||||
}
|
}
|
||||||
}, name, uuid, rank, perm);
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrimaryGroup(final int accountId, final PermissionGroup group, Runnable after)
|
||||||
|
{
|
||||||
|
_repository.setPrimaryGroup(accountId, group, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveRank(final Callback<Rank> callback, final String name, final UUID uuid, Rank rank, boolean perm)
|
public void addAdditionalGroup(final int accountId, final PermissionGroup group, Consumer<Boolean> successCallback)
|
||||||
{
|
{
|
||||||
_repository.saveRank(new Callback<Rank>()
|
_repository.addAdditionalGroup(accountId, group, success ->
|
||||||
{
|
{
|
||||||
public void run(Rank newRank)
|
if (successCallback != null)
|
||||||
{
|
{
|
||||||
if (_plugin.getServer().getPlayer(name) != null)
|
successCallback.accept(success);
|
||||||
{
|
|
||||||
CoreClient client = Get(name);
|
|
||||||
|
|
||||||
client.SetRank(newRank, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callback != null)
|
|
||||||
callback.run(newRank);
|
|
||||||
|
|
||||||
UtilServer.CallEvent(new RankSaveEvent(uuid, newRank));
|
|
||||||
}
|
}
|
||||||
}, name, uuid, rank, perm);
|
if (!success)
|
||||||
|
{
|
||||||
|
System.out.println("Error adding additional group " + group + " to account " + accountId + "!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAdditionalGroup(final int accountId, final PermissionGroup group, Consumer<Boolean> successCallback)
|
||||||
|
{
|
||||||
|
_repository.removeAdditionalGroup(accountId, group, success ->
|
||||||
|
{
|
||||||
|
if (successCallback != null)
|
||||||
|
{
|
||||||
|
successCallback.accept(success);
|
||||||
|
}
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
System.out.println("Error removing additional group " + group + " from account " + accountId + "!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearGroups(final int accountId, Consumer<Boolean> successCallback)
|
||||||
|
{
|
||||||
|
_repository.clearGroups(accountId, success ->
|
||||||
|
{
|
||||||
|
if (successCallback != null)
|
||||||
|
{
|
||||||
|
successCallback.accept(success);
|
||||||
|
}
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
System.out.println("Error clearing groups from account " + accountId + "!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fetchGroups(final int accountId, BiConsumer<PermissionGroup, Set<PermissionGroup>> resultCallback, Runnable onError)
|
||||||
|
{
|
||||||
|
_repository.fetchGroups(accountId, (primaryGroup, additionalGroups) ->
|
||||||
|
{
|
||||||
|
if (primaryGroup == null)
|
||||||
|
{
|
||||||
|
UtilServer.runSync(() -> resultCallback.accept(primaryGroup, additionalGroups));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID uuid;
|
||||||
|
if ((uuid = _repository.getClientUUID(accountId)) != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PermissionGroup legacyPrimary = CompletableFuture.supplyAsync(() ->
|
||||||
|
{
|
||||||
|
String legacy = loadOfflineClient(uuid).Rank;
|
||||||
|
PermissionGroup defaultGroup = PermissionGroup.PLAYER;
|
||||||
|
PermissionGroup loaded = PermissionGroupHelper.getGroupFromLegacy(legacy);
|
||||||
|
|
||||||
|
return loaded == null ? defaultGroup : loaded;
|
||||||
|
}).get(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
UtilServer.runSync(() -> resultCallback.accept(legacyPrimary, additionalGroups));
|
||||||
|
return;
|
||||||
|
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error fetching groups of account " + accountId + "!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilServer.runSync(() -> resultCallback.accept(PermissionGroup.PLAYER, additionalGroups));
|
||||||
|
}, () ->
|
||||||
|
{
|
||||||
|
if (onError != null)
|
||||||
|
{
|
||||||
|
onError.run();
|
||||||
|
}
|
||||||
|
System.out.println("Error fetching groups of account " + accountId + "!");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
|
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);
|
}, playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPlayerName(final Player caller, final String playerName, final Callback<String> callback)
|
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;
|
if (match.equalsIgnoreCase(playerName))
|
||||||
|
|
||||||
for (String match : matches)
|
|
||||||
{
|
{
|
||||||
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);
|
}, playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -726,29 +869,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)
|
public void addStoredProcedureLoginProcessor(ILoginProcessor processor)
|
||||||
{
|
{
|
||||||
_loginProcessors.add(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,102 @@
|
|||||||
|
package mineplex.core.account.command;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
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.Perm.ADD_RANK_COMMAND, "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];
|
||||||
|
Optional<PermissionGroup> maybeGroup = PermissionGroup.getGroup(args[1]);
|
||||||
|
if (!maybeGroup.isPresent())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PermissionGroup group = maybeGroup.get();
|
||||||
|
Plugin.runAsync(() ->
|
||||||
|
{
|
||||||
|
UUID uuid = Plugin.loadUUIDFromDB(target);
|
||||||
|
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(), maybeGroup.get(), success ->
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
client.addAdditionalGroup(maybeGroup.get());
|
||||||
|
UtilServer.CallEvent(new OnlineGroupAddEvent(Bukkit.getPlayer(uuid), group));
|
||||||
|
UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "You have gained sub-rank " + F.elem(group.name().toLowerCase()) + "!"));
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have added sub-rank " + F.elem(group.name().toLowerCase()) + " to " + F.elem(target) + "!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while adding sub-rank " + F.elem(group.name().toLowerCase()) + " to " + F.elem(target) + "! They may already have it."));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.loadAccountIdFromUUID(uuid, id ->
|
||||||
|
{
|
||||||
|
Plugin.runSync(() ->
|
||||||
|
{
|
||||||
|
if (id == -1)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.addAdditionalGroup(id, group, success ->
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have added sub-rank " + F.elem(group.name().toLowerCase()) + " to " + F.elem(target) + "!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while adding sub-rank " + F.elem(group.name().toLowerCase()) + " 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.Perm.RANK_INFO_COMMAND, "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(), (primaryGroup, additionalGroups) ->
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":"));
|
||||||
|
UtilPlayer.message(caller, C.cBlue + "Primary: " + C.cGray + primaryGroup.name().toLowerCase());
|
||||||
|
UtilPlayer.message(caller, C.cBlue + "Additional (" + additionalGroups.size() + "):");
|
||||||
|
for (PermissionGroup group : additionalGroups)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.name().toLowerCase());
|
||||||
|
}
|
||||||
|
}, () ->
|
||||||
|
{
|
||||||
|
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 == -1)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.fetchGroups(id, (primaryGroup, additionalGroups) ->
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":"));
|
||||||
|
UtilPlayer.message(caller, C.cBlue + "Primary: " + C.cGray + primaryGroup.name().toLowerCase());
|
||||||
|
UtilPlayer.message(caller, C.cBlue + "Additional (" + additionalGroups.size() + "):");
|
||||||
|
for (PermissionGroup group : additionalGroups)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.name().toLowerCase());
|
||||||
|
}
|
||||||
|
}, () ->
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while listing " + F.elem(target) + "'s ranks!"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package mineplex.core.account.command;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
|
public class ListRanksCommand extends CommandBase<CoreClientManager>
|
||||||
|
{
|
||||||
|
public ListRanksCommand(CoreClientManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, CoreClientManager.Perm.LIST_RANKS_COMMAND, "list");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Available Ranks: " + Stream.of(PermissionGroup.values()).map(group -> C.cYellow + group.name().toLowerCase()).sorted().collect(Collectors.joining(C.cGray + ", "))));
|
||||||
|
}
|
||||||
|
}
|
@ -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.Perm.RANK_COMMAND, "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,102 @@
|
|||||||
|
package mineplex.core.account.command;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
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.Perm.REMOVE_RANK_COMMAND, "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];
|
||||||
|
Optional<PermissionGroup> maybeGroup = PermissionGroup.getGroup(args[1]);
|
||||||
|
if (!maybeGroup.isPresent())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PermissionGroup group = maybeGroup.get();
|
||||||
|
Plugin.runAsync(() ->
|
||||||
|
{
|
||||||
|
UUID uuid = Plugin.loadUUIDFromDB(target);
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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.name().toLowerCase()) + "!"));
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have removed sub-rank " + F.elem(group.name().toLowerCase()) + " from " + F.elem(target) + "!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while removing sub-rank " + F.elem(group.name().toLowerCase()) + " from " + F.elem(target) + "! They may not have it."));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.loadAccountIdFromUUID(uuid, id ->
|
||||||
|
{
|
||||||
|
Plugin.runSync(() ->
|
||||||
|
{
|
||||||
|
if (id == -1)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.removeAdditionalGroup(id, group, success ->
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have removed sub-rank " + F.elem(group.name().toLowerCase()) + " from " + F.elem(target) + "!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while removing sub-rank " + F.elem(group.name().toLowerCase()) + " 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.Perm.RESET_PLAYER_COMMAND, "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)
|
||||||
|
{
|
||||||
|
PermissionGroup old = client.getPrimaryGroup();
|
||||||
|
client.setPrimaryGroup(PermissionGroup.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,94 @@
|
|||||||
|
package mineplex.core.account.command;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
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.Perm.SET_RANK_COMMAND, "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];
|
||||||
|
Optional<PermissionGroup> maybeGroup = PermissionGroup.getGroup(args[1]);
|
||||||
|
if (!maybeGroup.isPresent())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PermissionGroup group = maybeGroup.get();
|
||||||
|
if (!group.canBePrimary())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "That rank cannot be primary!"));
|
||||||
|
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.name().toLowerCase()) + "!"));
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have updated " + F.elem(target + "'s") + " rank to " + F.elem(group.name().toLowerCase()) + "!"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.loadAccountIdFromUUID(uuid, id ->
|
||||||
|
{
|
||||||
|
Plugin.runSync(() ->
|
||||||
|
{
|
||||||
|
if (id == -1)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.setPrimaryGroup(id, group, () ->
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have updated " + F.elem(target + "'s") + " rank to " + F.elem(group.name().toLowerCase()) + "!"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -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,40 @@
|
|||||||
|
package mineplex.core.account.event;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
|
||||||
|
public class GroupAddEvent extends Event
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private int _accountId;
|
||||||
|
private PermissionGroup _group;
|
||||||
|
|
||||||
|
public GroupAddEvent(int accountId, PermissionGroup group)
|
||||||
|
{
|
||||||
|
_accountId = accountId;
|
||||||
|
_group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAccountId()
|
||||||
|
{
|
||||||
|
return _accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionGroup getGroup()
|
||||||
|
{
|
||||||
|
return _group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package mineplex.core.account.event;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
|
||||||
|
public class GroupRemoveEvent extends Event
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private int _accountId;
|
||||||
|
private PermissionGroup _group;
|
||||||
|
|
||||||
|
public GroupRemoveEvent(int accountId, PermissionGroup group)
|
||||||
|
{
|
||||||
|
_accountId = accountId;
|
||||||
|
_group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAccountId()
|
||||||
|
{
|
||||||
|
return _accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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;
|
package mineplex.core.account.event;
|
||||||
|
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
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 static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Player _player;
|
private Player _player;
|
||||||
private Rank _from, _to;
|
private PermissionGroup _from, _to;
|
||||||
private boolean _temp;
|
|
||||||
|
|
||||||
public OnlineRankUpdateEvent(Player player, Rank from, Rank to, boolean temp)
|
public OnlinePrimaryGroupUpdateEvent(Player player, PermissionGroup from, PermissionGroup to)
|
||||||
{
|
{
|
||||||
_player = player;
|
_player = player;
|
||||||
_from = from;
|
_from = from;
|
||||||
_to = to;
|
_to = to;
|
||||||
_temp = temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer()
|
public Player getPlayer()
|
||||||
@ -27,21 +25,16 @@ public class OnlineRankUpdateEvent extends Event
|
|||||||
return _player;
|
return _player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank getFrom()
|
public PermissionGroup getFrom()
|
||||||
{
|
{
|
||||||
return _from;
|
return _from;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank getTo()
|
public PermissionGroup getTo()
|
||||||
{
|
{
|
||||||
return _to;
|
return _to;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTemporary()
|
|
||||||
{
|
|
||||||
return _temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers()
|
||||||
{
|
{
|
||||||
return handlers;
|
return handlers;
|
||||||
@ -51,5 +44,4 @@ public class OnlineRankUpdateEvent extends Event
|
|||||||
{
|
{
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -0,0 +1,40 @@
|
|||||||
|
package mineplex.core.account.event;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
|
||||||
|
public class PrimaryGroupUpdateEvent extends Event
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private int _accountId;
|
||||||
|
private PermissionGroup _group;
|
||||||
|
|
||||||
|
public PrimaryGroupUpdateEvent(int accountId, PermissionGroup group)
|
||||||
|
{
|
||||||
|
_accountId = accountId;
|
||||||
|
_group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAccountId()
|
||||||
|
{
|
||||||
|
return _accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionGroup getGroup()
|
||||||
|
{
|
||||||
|
return _group;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,27 @@
|
|||||||
|
package mineplex.core.account.permissions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Permission that can be assigned to {@link PermissionGroup}s
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* This interface is intended to be paired with enum data types, as only
|
||||||
|
* enum-based permissions are accepted by {@link PermissionGroup#setPermission(Enum, boolean, boolean)}
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Example usage:
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* enum ExamplePerm implements Permission { EXAMPLE_ONE, EXAMPLE_TWO }
|
||||||
|
*
|
||||||
|
* PermissionGroup.PLAYER.setPermission(ExamplePerm.EXAMPLE_ONE, true, true);
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Permissions can either be inheritable (passed on to child groups) or group-specific. Group-specific permissions
|
||||||
|
* override inherited permissions, but still allow the inherited permission to be propagated to children.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* In the case that two parents share the same inheritable permission, the values will be merged with logical OR
|
||||||
|
*/
|
||||||
|
public interface Permission {}
|
@ -0,0 +1,226 @@
|
|||||||
|
package mineplex.core.account.permissions;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.graph.GraphBuilder;
|
||||||
|
import com.google.common.graph.ImmutableGraph;
|
||||||
|
import com.google.common.graph.MutableGraph;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
|
||||||
|
public enum PermissionGroup
|
||||||
|
{
|
||||||
|
//PLAYER
|
||||||
|
PLAYER("player", "", "", ChatColor.WHITE, -1, true),
|
||||||
|
ULTRA("ultra", "Ultra", "A first step into the stories of the mist. \nOnly those brave enough may enter. \n\nThe first purchasable rank at Mineplex.com/shop", ChatColor.AQUA, 12, true, PermissionGroup.PLAYER),
|
||||||
|
HERO("hero", "Hero", "There are many stories of a \nvaliant Hero who was brave enough to \ntame the most fearsome dragon in the land. \n\nThe second purchasable rank at Mineplex.com/shop", ChatColor.LIGHT_PURPLE, 13, true, PermissionGroup.ULTRA),
|
||||||
|
LEGEND("legend", "Legend", "Years they have told stories of this rank, \nonly for the legends to be true. \n\nThe third purchasable rank at Mineplex.com/shop", ChatColor.GREEN, 14, true, PermissionGroup.HERO),
|
||||||
|
TITAN("titan", "Titan", "Ancient myths spoke of a gigantic being \nwith immense power... \n\nThe fourth purchasable rank at Mineplex.com/shop", ChatColor.RED, 15, true, PermissionGroup.LEGEND),
|
||||||
|
ETERNAL("eternal", "Eternal", "Fantastic and magical, no one \nexcept the time lords truly understand \nthe power of this rank.\n\nThe fifth purchasable rank at Mineplex.com/shop", ChatColor.DARK_AQUA, 18, true, PermissionGroup.TITAN),
|
||||||
|
|
||||||
|
//CONTENT
|
||||||
|
CONTENT("content", "", "", ChatColor.WHITE, -1, false, PermissionGroup.ETERNAL),
|
||||||
|
TWITCH("twitch", "Twitch", "A Twitch streamer who often features \nMineplex in their streams.", ChatColor.DARK_PURPLE, 21, true, PermissionGroup.CONTENT),
|
||||||
|
YT("yt", "YT", "A YouTuber who creates content for \nor related to Mineplex. \n\nThey have fewer subscribers than full YouTubers.", ChatColor.DARK_PURPLE, 20, true, PermissionGroup.CONTENT),
|
||||||
|
YOUTUBE("youtube", "YouTube", "A YouTuber who creates content for \nor related to Mineplex.", ChatColor.RED, 22, true, PermissionGroup.CONTENT),
|
||||||
|
|
||||||
|
BUILDER("builder", "Builder", "These creative staff members help \nbuild maps for your favorite games!", ChatColor.BLUE, 26, true, PermissionGroup.ETERNAL),
|
||||||
|
MAPPER("mapper", "Mapper", "These senior staff members work closely with \nthe development and design teams to build new \nmaps for new and old content!", ChatColor.BLUE, 100, true, PermissionGroup.BUILDER),
|
||||||
|
MAPLEAD("maplead", "MapLead", "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", ChatColor.BLUE, 25, true, PermissionGroup.MAPPER),
|
||||||
|
TRAINEE("trainee", "Trainee", "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", ChatColor.GOLD, 24, true, PermissionGroup.MAPLEAD),
|
||||||
|
MOD("mod", "Mod", "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", ChatColor.GOLD, 32, true, PermissionGroup.TRAINEE),
|
||||||
|
SRMOD("srmod", "Sr.Mod", "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", ChatColor.GOLD, 44, true, PermissionGroup.MOD),
|
||||||
|
SUPPORT("support", "Support", "Support agents handle tickets and \nprovide customer service.", ChatColor.BLUE, 47, true, PermissionGroup.SRMOD),
|
||||||
|
ADMIN("admin", "Admin", "An Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it.", ChatColor.DARK_RED, 10, true, PermissionGroup.SUPPORT, PermissionGroup.CONTENT),
|
||||||
|
DEV("dev", "Dev", "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", ChatColor.DARK_RED, 5, true, PermissionGroup.ADMIN),
|
||||||
|
LT("lt", "Leader", "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team.", ChatColor.DARK_RED, 11, true, PermissionGroup.DEV),
|
||||||
|
OWNER("owner", "Owner", "Owners are the core managers of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation.", ChatColor.DARK_RED, 55, true, PermissionGroup.LT),
|
||||||
|
|
||||||
|
//SUB-GROUPS
|
||||||
|
QA("qa", "", "Members of the Quality Assurance team.", ChatColor.WHITE, 50, false),
|
||||||
|
QAM("qam", "", "Managers of the Quality Assurance team.", ChatColor.WHITE, 50, false, PermissionGroup.QA),
|
||||||
|
CMOD("cmod", "", "Members of the Clans Management team.", ChatColor.WHITE, 32, false),
|
||||||
|
TM("tm", "", "Members of the Trainee Management team.", ChatColor.WHITE, 52, false),
|
||||||
|
MC("mc", "", "Members of the Moderator Coordination team.", ChatColor.WHITE, 49, false),
|
||||||
|
EVENTMOD("eventmod", "", "Members of the Event Management team.", ChatColor.WHITE, -1, false),
|
||||||
|
CMA("cma", "", "Members of the Clans Management Assistance team.", ChatColor.WHITE, -1, false),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
MutableGraph<PermissionGroup> _builder = GraphBuilder.directed().build();
|
||||||
|
|
||||||
|
// Add each group as a node, and add edges between parent (inherited) and child nodes
|
||||||
|
Stream.of(PermissionGroup.values()).peek(_builder::addNode).forEach(group ->
|
||||||
|
group._parentGroups.forEach(parent -> _builder.putEdge(parent, group)));
|
||||||
|
|
||||||
|
_groupHierarchy = ImmutableGraph.copyOf(_builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We want a graph so we can walk the hierarchy downward and recalculate permissions when needed
|
||||||
|
private static final ImmutableGraph<PermissionGroup> _groupHierarchy;
|
||||||
|
private static final Object PERMS_LOCK = new Object();
|
||||||
|
|
||||||
|
private final String _id, _display, _description;
|
||||||
|
private final ChatColor _color;
|
||||||
|
private final int _forumId;
|
||||||
|
private final boolean _canBePrimary;
|
||||||
|
private final Set<PermissionGroup> _parentGroups;
|
||||||
|
|
||||||
|
private Map<Permission, Boolean> _specificPerms = new IdentityHashMap<>();
|
||||||
|
private Map<Permission, Boolean> _inheritablePerms = new IdentityHashMap<>();
|
||||||
|
|
||||||
|
private Map<Permission, Boolean> _bakedPerms = ImmutableMap.of();
|
||||||
|
|
||||||
|
PermissionGroup(String identifier, String display, String description, ChatColor color, int forumId, boolean canBePrimary, PermissionGroup... parentGroups)
|
||||||
|
{
|
||||||
|
_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;
|
||||||
|
_parentGroups = ImmutableSet.copyOf(Arrays.asList(parentGroups));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note the constraints on T: this ensures we'll have reference equality on permissions, so we can put them in `IdentityHashMap`s
|
||||||
|
public <T extends Enum<T> & Permission> void setPermission(T permission, boolean inheritable, boolean value)
|
||||||
|
{
|
||||||
|
synchronized(PERMS_LOCK)
|
||||||
|
{
|
||||||
|
(inheritable ? _inheritablePerms : _specificPerms).put(permission, value); // Add new permission under the correct category
|
||||||
|
(inheritable ? _specificPerms : _inheritablePerms).remove(permission); // Remove permission from the other category, if present
|
||||||
|
|
||||||
|
bakePermissions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void revokePermission(Permission permission)
|
||||||
|
{
|
||||||
|
synchronized(PERMS_LOCK)
|
||||||
|
{
|
||||||
|
_specificPerms.remove(permission);
|
||||||
|
_inheritablePerms.remove(permission);
|
||||||
|
|
||||||
|
bakePermissions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(Permission permission)
|
||||||
|
{
|
||||||
|
synchronized(PERMS_LOCK)
|
||||||
|
{
|
||||||
|
return _bakedPerms.getOrDefault(permission, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inheritsFrom(PermissionGroup group)
|
||||||
|
{
|
||||||
|
for (PermissionGroup parent : _parentGroups)
|
||||||
|
{
|
||||||
|
if (parent == group || parent.inheritsFrom(group))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this == group;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bakePermissions()
|
||||||
|
{
|
||||||
|
// Calculate inherited permissions
|
||||||
|
Map<Permission, Boolean> inherited = calculateInheritable();
|
||||||
|
|
||||||
|
// Now: walk down the group hierarchy and bake permissions
|
||||||
|
bakeForward(inherited);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bakeForward(Map<Permission, Boolean> inherited)
|
||||||
|
{
|
||||||
|
_bakedPerms = new IdentityHashMap<>();
|
||||||
|
_bakedPerms.putAll(inherited);
|
||||||
|
_bakedPerms.putAll(_specificPerms); // Specific permissions override inheritable ones
|
||||||
|
|
||||||
|
_groupHierarchy.successors(this).forEach(successor ->
|
||||||
|
{
|
||||||
|
Map<Permission, Boolean> newInherited = new IdentityHashMap<>(inherited);
|
||||||
|
newInherited.putAll(successor._inheritablePerms);
|
||||||
|
successor.bakeForward(newInherited);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate inheritable permissions from parent nodes and this node
|
||||||
|
private Map<Permission, Boolean> calculateInheritable()
|
||||||
|
{
|
||||||
|
Map<Permission, Boolean> inheritable = _groupHierarchy.predecessors(this).stream() // For each predecessor,
|
||||||
|
.map(PermissionGroup::calculateInheritable) // calculate their inheritable permissions
|
||||||
|
.flatMap(perms -> perms.entrySet().stream()) // and merge with logical OR
|
||||||
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, Boolean::logicalOr, IdentityHashMap::new));
|
||||||
|
|
||||||
|
inheritable.putAll(_inheritablePerms); // Add our own inheritable permissions
|
||||||
|
return inheritable;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 static Optional<PermissionGroup> getGroup(String name)
|
||||||
|
{
|
||||||
|
return Stream.of(values()).filter(group -> group.name().equalsIgnoreCase(name)).findFirst();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package mineplex.core.account.permissions;
|
||||||
|
|
||||||
|
public class PermissionGroupHelper
|
||||||
|
{
|
||||||
|
public static PermissionGroup getGroupFromLegacy(String legacyValue)
|
||||||
|
{
|
||||||
|
if (legacyValue == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String legacy = legacyValue.toLowerCase();
|
||||||
|
final PermissionGroup current;
|
||||||
|
|
||||||
|
switch (legacy)
|
||||||
|
{
|
||||||
|
case "developer":
|
||||||
|
current = PermissionGroup.DEV;
|
||||||
|
break;
|
||||||
|
case "jnr_dev":
|
||||||
|
current = PermissionGroup.PLAYER;
|
||||||
|
break;
|
||||||
|
case "event_moderator":
|
||||||
|
current = PermissionGroup.EVENTMOD;
|
||||||
|
break;
|
||||||
|
case "snr_moderator":
|
||||||
|
current = PermissionGroup.SRMOD;
|
||||||
|
break;
|
||||||
|
case "moderator":
|
||||||
|
current = PermissionGroup.MOD;
|
||||||
|
break;
|
||||||
|
case "helper":
|
||||||
|
current = PermissionGroup.TRAINEE;
|
||||||
|
break;
|
||||||
|
case "mapdev":
|
||||||
|
current = PermissionGroup.BUILDER;
|
||||||
|
break;
|
||||||
|
case "media":
|
||||||
|
current = PermissionGroup.PLAYER;
|
||||||
|
break;
|
||||||
|
case "youtube_small":
|
||||||
|
current = PermissionGroup.YT;
|
||||||
|
break;
|
||||||
|
case "all":
|
||||||
|
current = PermissionGroup.PLAYER;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
current = PermissionGroup.getGroup(legacy).get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
}
|
@ -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,38 @@
|
|||||||
|
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 = PermissionGroup.valueOf(command.getGroupIdentifier());
|
||||||
|
_clientManager.Get(opt.get()).addAdditionalGroup(group);
|
||||||
|
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "You have gained sub-rank " + F.elem(group.name().toLowerCase()) + "!"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -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<? extends Player> opt = Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.getAccountId(player) == command.getAccountId()).findAny();
|
||||||
|
|
||||||
|
if (opt.isPresent())
|
||||||
|
{
|
||||||
|
PermissionGroup group = PermissionGroup.PLAYER;
|
||||||
|
_clientManager.Get(opt.get()).setPrimaryGroup(group);
|
||||||
|
_clientManager.Get(opt.get()).getAdditionalGroups().clear();
|
||||||
|
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "Your ranks have been cleared!"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -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,38 @@
|
|||||||
|
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 = PermissionGroup.valueOf(command.getGroupIdentifier());
|
||||||
|
_clientManager.Get(opt.get()).setPrimaryGroup(group);
|
||||||
|
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "Your rank has been updated to " + F.elem(group.name().toLowerCase()) + "!"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -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,38 @@
|
|||||||
|
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 = PermissionGroup.valueOf(command.getGroupIdentifier());
|
||||||
|
_clientManager.Get(opt.get()).removeAdditionalGroup(group);
|
||||||
|
UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "You have lost sub-rank " + F.elem(group.name().toLowerCase()) + "!"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -5,8 +5,14 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -16,27 +22,33 @@ import com.google.gson.reflect.TypeToken;
|
|||||||
|
|
||||||
import mineplex.cache.player.PlayerCache;
|
import mineplex.cache.player.PlayerCache;
|
||||||
import mineplex.core.account.ILoginProcessor;
|
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.permissions.PermissionGroup;
|
||||||
import mineplex.core.account.repository.token.LoginToken;
|
import mineplex.core.account.repository.token.LoginToken;
|
||||||
import mineplex.core.account.repository.token.RankUpdateToken;
|
import mineplex.core.common.Pair;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.database.MinecraftRepository;
|
import mineplex.core.database.MinecraftRepository;
|
||||||
import mineplex.serverdata.database.DBPool;
|
import mineplex.serverdata.database.DBPool;
|
||||||
import mineplex.serverdata.database.ResultSetCallable;
|
import mineplex.serverdata.database.column.ColumnInt;
|
||||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||||
|
|
||||||
public class AccountRepository extends MinecraftRepository
|
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 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 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_ACCOUNT_RANK_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;";
|
private static String UPDATE_PRIMARY_RANK = "UPDATE accountRanks SET rankIdentifier=? WHERE accountId=? AND primaryGroup=true;";
|
||||||
private static String UPDATE_ACCOUNT_RANK_DONOR_PERM = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=true WHERE uuid = ?;";
|
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_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=?;";
|
||||||
private static String SELECT_ACCOUNT_ID_BY_UUID = "SELECT id FROM accounts WHERE accounts.uuid = ? LIMIT 1";
|
private static String SELECT_ACCOUNT_ID_BY_UUID = "SELECT id FROM accounts WHERE accounts.uuid = ? LIMIT 1";
|
||||||
|
|
||||||
public AccountRepository()
|
public AccountRepository()
|
||||||
@ -44,10 +56,12 @@ public class AccountRepository extends MinecraftRepository
|
|||||||
super(DBPool.getAccount());
|
super(DBPool.getAccount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name) throws SQLException
|
public Pair<Integer, Pair<PermissionGroup, Set<PermissionGroup>>> login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name) throws SQLException
|
||||||
{
|
{
|
||||||
// First we try to grab the account id from cache - this saves an extra trip to database
|
// First we try to grab the account id from cache - this saves an extra trip to database
|
||||||
int accountId = PlayerCache.getInstance().getAccountId(uuid);
|
int accountId = PlayerCache.getInstance().getAccountId(uuid);
|
||||||
|
PermissionGroup primaryRank = null;
|
||||||
|
Set<PermissionGroup> extraRanks = new HashSet<>();
|
||||||
|
|
||||||
System.out.println("LOGIN... IDLE: " + ((BasicDataSource) DBPool.getAccount()).getNumIdle() + " ACTIVE: " + ((BasicDataSource) DBPool.getAccount()).getNumActive());
|
System.out.println("LOGIN... IDLE: " + ((BasicDataSource) DBPool.getAccount()).getNumIdle() + " ACTIVE: " + ((BasicDataSource) DBPool.getAccount()).getNumActive());
|
||||||
try (Connection connection = getConnection(); Statement statement = connection.createStatement())
|
try (Connection connection = getConnection(); Statement statement = connection.createStatement())
|
||||||
@ -65,19 +79,15 @@ public class AccountRepository extends MinecraftRepository
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Player doesn't exist in our database, add them to the accounts table
|
// 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
|
while (rs.next())
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
{
|
||||||
while (resultSet.next())
|
tempList.add(rs.getInt(1));
|
||||||
{
|
|
||||||
tempList.add(resultSet.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);
|
accountId = tempList.get(0);
|
||||||
}
|
}
|
||||||
@ -87,6 +97,32 @@ public class AccountRepository extends MinecraftRepository
|
|||||||
System.out.println(name + " Loaded Account ID From Cache [" + name + " - " + accountId + "]");
|
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;
|
||||||
|
PermissionGroup group = PermissionGroup.valueOf(rankSet.getString("rankIdentifier"));
|
||||||
|
boolean primary = rankSet.getBoolean("primaryGroup");
|
||||||
|
|
||||||
|
if (primary)
|
||||||
|
{
|
||||||
|
primaryRank = group;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extraRanks.add(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!anyRows)
|
||||||
|
{
|
||||||
|
statement.execute(UPDATE_PRIMARY_RANK.replace("?", "" + accountId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final int finalId = accountId;
|
final int finalId = accountId;
|
||||||
final String uuidString = uuid.toString();
|
final String uuidString = uuid.toString();
|
||||||
|
|
||||||
@ -120,7 +156,7 @@ public class AccountRepository extends MinecraftRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return accountId;
|
return Pair.create(accountId, Pair.create(primaryRank, extraRanks));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAccountId(UUID uuid, Callback<Integer> callback)
|
public void getAccountId(UUID uuid, Callback<Integer> callback)
|
||||||
@ -150,67 +186,259 @@ public class AccountRepository extends MinecraftRepository
|
|||||||
|
|
||||||
public UUID getClientUUID(String name)
|
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
|
while (resultSet.next())
|
||||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
|
||||||
{
|
{
|
||||||
while (resultSet.next())
|
uuids.add(UUID.fromString(resultSet.getString(1)));
|
||||||
{
|
|
||||||
uuids.add(UUID.fromString(resultSet.getString(1)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, new ColumnVarChar("name", 100, name));
|
}, new ColumnVarChar("name", 100, name));
|
||||||
|
|
||||||
if (uuids.size() > 0)
|
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)
|
|
||||||
{
|
|
||||||
final RankUpdateToken token = new RankUpdateToken();
|
|
||||||
token.Name = name;
|
|
||||||
token.Rank = rank.toString();
|
|
||||||
token.Perm = perm;
|
|
||||||
|
|
||||||
final Consumer<Rank> extraCallback = response ->
|
|
||||||
{
|
{
|
||||||
if (rank == Rank.ULTRA || rank == Rank.HERO || rank == Rank.LEGEND || rank == Rank.TITAN)
|
return uuids.get(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getClientUUID(final int accountId)
|
||||||
|
{
|
||||||
|
StringBuilder uuidBuilder = new StringBuilder();
|
||||||
|
executeQuery(SELECT_ACCOUNT_UUID_BY_ID, resultSet ->
|
||||||
|
{
|
||||||
|
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 PermissionGroup group, 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)
|
if (!rs.next() || rs.getInt(1) == 0)
|
||||||
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
|
s.execute(ADD_PRIMARY_RANK.replace("?", "" + accountId));
|
||||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
}
|
||||||
}
|
}
|
||||||
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()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (perm)
|
|
||||||
executeUpdate(UPDATE_ACCOUNT_RANK_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
|
||||||
else
|
|
||||||
executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
UtilServer.runSync(() ->
|
|
||||||
{
|
|
||||||
if (callback != null)
|
|
||||||
callback.run(response);
|
|
||||||
|
|
||||||
UtilServer.CallEvent(new RankSaveEvent(uuid, rank));
|
executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnVarChar("rankIdentifier", 255, group.name()), new ColumnInt("accountId", accountId));
|
||||||
});
|
|
||||||
};
|
UtilServer.runSync(() ->
|
||||||
|
{
|
||||||
|
if (after != null)
|
||||||
|
{
|
||||||
|
after.run();
|
||||||
|
}
|
||||||
|
UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, group));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAdditionalGroup(final int accountId, final PermissionGroup group, 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, group));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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", 255, group.name()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAdditionalGroup(final int accountId, final PermissionGroup group, 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", 255, group.name()));
|
||||||
|
|
||||||
|
if (!callbackRun.get())
|
||||||
|
{
|
||||||
|
if (updated > 0)
|
||||||
|
{
|
||||||
|
UtilServer.runSync(() ->
|
||||||
|
{
|
||||||
|
if (successCallback != null)
|
||||||
|
{
|
||||||
|
successCallback.accept(Boolean.TRUE);
|
||||||
|
}
|
||||||
|
UtilServer.CallEvent(new GroupRemoveEvent(accountId, group));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearGroups(final int accountId, Consumer<Boolean> successCallback)
|
||||||
|
{
|
||||||
|
UtilServer.runAsync(() ->
|
||||||
|
{
|
||||||
|
AtomicBoolean success = new AtomicBoolean(true);
|
||||||
|
Set<PermissionGroup> 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(PermissionGroup.valueOf(rs.getString("rankIdentifier")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handleMSSQLCall("PlayerAccount/RankUpdate", String.format("Error saving %s's rank: ", token.Name), token, Rank.class, extraCallback);
|
executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnVarChar("rankIdentifier", "player".length(), "player"), new ColumnInt("accountId", accountId));
|
||||||
|
executeUpdate(c, REMOVE_ADDITIONAL_RANKS, () -> success.set(false), new ColumnInt("accountId", accountId));
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
success.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (successCallback != null || success.get())
|
||||||
|
{
|
||||||
|
UtilServer.runSync(() ->
|
||||||
|
{
|
||||||
|
if (successCallback != null)
|
||||||
|
{
|
||||||
|
successCallback.accept(success.get());
|
||||||
|
}
|
||||||
|
UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, PermissionGroup.PLAYER));
|
||||||
|
for (PermissionGroup group : removed)
|
||||||
|
{
|
||||||
|
UtilServer.CallEvent(new GroupRemoveEvent(accountId, group));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fetchGroups(final int accountId, BiConsumer<PermissionGroup, Set<PermissionGroup>> resultCallback, Runnable onError)
|
||||||
|
{
|
||||||
|
fetchGroups(accountId, resultCallback, onError, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fetchGroups(final int accountId, BiConsumer<PermissionGroup, Set<PermissionGroup>> resultCallback, Runnable onError, boolean runAsync)
|
||||||
|
{
|
||||||
|
Runnable r = () ->
|
||||||
|
{
|
||||||
|
AtomicBoolean errored = new AtomicBoolean();
|
||||||
|
AtomicReference<PermissionGroup> primary = new AtomicReference<>();
|
||||||
|
Set<PermissionGroup> additional = new HashSet<>();
|
||||||
|
|
||||||
|
executeQuery("SELECT * FROM accountRanks WHERE accountId=?;", rs ->
|
||||||
|
{
|
||||||
|
while (rs.next())
|
||||||
|
{
|
||||||
|
if (rs.getBoolean("primaryGroup"))
|
||||||
|
{
|
||||||
|
primary.set(PermissionGroup.valueOf(rs.getString("rankIdentifier")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
additional.add(PermissionGroup.valueOf(rs.getString("rankIdentifier")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, () ->
|
||||||
|
{
|
||||||
|
if (onError != null)
|
||||||
|
{
|
||||||
|
errored.set(true);
|
||||||
|
UtilServer.runSync(onError);
|
||||||
|
}
|
||||||
|
}, new ColumnInt("accountId", accountId));
|
||||||
|
|
||||||
|
if (!errored.get())
|
||||||
|
{
|
||||||
|
if (resultCallback != null)
|
||||||
|
{
|
||||||
|
resultCallback.accept(primary.get(), additional);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (runAsync)
|
||||||
|
{
|
||||||
|
UtilServer.runAsync(r);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void matchPlayerName(final Callback<List<String>> callback, final String userName)
|
public void matchPlayerName(final Callback<List<String>> callback, final String userName)
|
||||||
@ -222,4 +450,4 @@ public class AccountRepository extends MinecraftRepository
|
|||||||
{
|
{
|
||||||
return handleSyncMSSQLCallStream("PlayerAccount/GetAccount", playerName);
|
return handleSyncMSSQLCallStream("PlayerAccount/GetAccount", playerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,4 +5,4 @@ public class Rank
|
|||||||
public int RankId;
|
public int RankId;
|
||||||
|
|
||||||
public String Name;
|
public String Name;
|
||||||
}
|
}
|
@ -7,7 +7,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.game.GameDisplay;
|
import mineplex.core.game.GameDisplay;
|
||||||
@ -332,7 +331,7 @@ public enum AchievementCategory
|
|||||||
String displayName = _statDisplays[i].getDisplayName();
|
String displayName = _statDisplays[i].getDisplayName();
|
||||||
|
|
||||||
// Skip showing Losses, Kills, Deaths for other players
|
// 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.Get(player).hasPermission(AchievementManager.Perm.SEE_FULL_STATS) && !player.getName().equals(targetName) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double statNumber = 0;
|
double statNumber = 0;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package mineplex.core.achievement;
|
package mineplex.core.achievement;
|
||||||
|
|
||||||
import mineplex.core.stats.PlayerStats;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -8,24 +9,29 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.achievement.command.StatsCommand;
|
import mineplex.core.achievement.command.StatsCommand;
|
||||||
import mineplex.core.achievement.ui.AchievementShop;
|
import mineplex.core.achievement.ui.AchievementShop;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.elo.EloManager;
|
import mineplex.core.elo.EloManager;
|
||||||
import mineplex.core.incognito.IncognitoManager;
|
import mineplex.core.incognito.IncognitoManager;
|
||||||
|
import mineplex.core.stats.PlayerStats;
|
||||||
import mineplex.core.stats.StatsManager;
|
import mineplex.core.stats.StatsManager;
|
||||||
import mineplex.core.stats.event.StatChangeEvent;
|
import mineplex.core.stats.event.StatChangeEvent;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class AchievementManager extends MiniPlugin
|
public class AchievementManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
private static final List<String> NO_FAKE_LEVELS = Arrays.asList("samczsun");
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
FAKE_LEVEL_50,
|
||||||
|
FAKE_LEVEL_30,
|
||||||
|
FAKE_LEVEL_15,
|
||||||
|
FAKE_LEVEL_5,
|
||||||
|
SEE_FULL_STATS,
|
||||||
|
STATS_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
private IncognitoManager _incognitoManager;
|
private IncognitoManager _incognitoManager;
|
||||||
@ -49,6 +55,18 @@ public class AchievementManager extends MiniPlugin
|
|||||||
_eloManager = eloManager;
|
_eloManager = eloManager;
|
||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
|
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
PermissionGroup.MOD.setPermission(Perm.SEE_FULL_STATS, true, true);
|
||||||
|
PermissionGroup.MOD.setPermission(Perm.FAKE_LEVEL_5, true, true);
|
||||||
|
PermissionGroup.SRMOD.setPermission(Perm.FAKE_LEVEL_15, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.FAKE_LEVEL_30, true, true);
|
||||||
|
PermissionGroup.LT.setPermission(Perm.FAKE_LEVEL_50, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.STATS_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AchievementData get(Player player, Achievement type)
|
public AchievementData get(Player player, Achievement type)
|
||||||
@ -199,32 +217,30 @@ public class AchievementManager extends MiniPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMineplexLevelNumber(Player sender, Rank rank)
|
public int getMineplexLevelNumber(Player sender)
|
||||||
{
|
{
|
||||||
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
|
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
|
||||||
|
|
||||||
if (NO_FAKE_LEVELS.contains(sender.getName()))
|
if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_50))
|
||||||
{
|
{
|
||||||
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());
|
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||||
|
} else if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_30))
|
||||||
|
{
|
||||||
|
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||||
|
} else if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_15))
|
||||||
|
{
|
||||||
|
level = Math.max(level, 15);
|
||||||
|
} else if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_5))
|
||||||
|
{
|
||||||
|
level = Math.max(level, 5);
|
||||||
|
}
|
||||||
|
|
||||||
return level;
|
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()
|
public CoreClientManager getClientManager()
|
||||||
@ -246,4 +262,4 @@ public class AchievementManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
return _statsManager;
|
return _statsManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,23 +1,18 @@
|
|||||||
package mineplex.core.achievement.command;
|
package mineplex.core.achievement.command;
|
||||||
|
|
||||||
import mineplex.core.stats.PlayerStats;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.achievement.AchievementManager;
|
import mineplex.core.achievement.AchievementManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class StatsCommand extends CommandBase<AchievementManager>
|
public class StatsCommand extends CommandBase<AchievementManager>
|
||||||
{
|
{
|
||||||
public StatsCommand(AchievementManager plugin)
|
public StatsCommand(AchievementManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "stats");
|
super(plugin, AchievementManager.Perm.STATS_COMMAND, "stats");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,7 +28,8 @@ public class StatsCommand extends CommandBase<AchievementManager>
|
|||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
if (Plugin.getClientManager().hasRank(caller, Rank.MODERATOR)) attemptOffline(caller, args);
|
if (Plugin.getClientManager().Get(caller).hasPermission(AchievementManager.Perm.SEE_FULL_STATS))
|
||||||
|
attemptOffline(caller, args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,4 +69,4 @@ public class StatsCommand extends CommandBase<AchievementManager>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,6 +39,7 @@ import com.mineplex.anticheat.api.MineplexLink;
|
|||||||
import com.mineplex.anticheat.api.PlayerViolationEvent;
|
import com.mineplex.anticheat.api.PlayerViolationEvent;
|
||||||
import com.mineplex.anticheat.checks.Check;
|
import com.mineplex.anticheat.checks.Check;
|
||||||
import com.mineplex.anticheat.checks.CheckManager;
|
import com.mineplex.anticheat.checks.CheckManager;
|
||||||
|
import com.mineplex.anticheat.checks.combat.FastBow;
|
||||||
import com.mineplex.anticheat.checks.combat.KillauraTypeA;
|
import com.mineplex.anticheat.checks.combat.KillauraTypeA;
|
||||||
import com.mineplex.anticheat.checks.combat.KillauraTypeB;
|
import com.mineplex.anticheat.checks.combat.KillauraTypeB;
|
||||||
import com.mineplex.anticheat.checks.combat.KillauraTypeC;
|
import com.mineplex.anticheat.checks.combat.KillauraTypeC;
|
||||||
@ -56,6 +57,8 @@ import mineplex.core.MiniPlugin;
|
|||||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.antihack.actions.AntiHackAction;
|
import mineplex.core.antihack.actions.AntiHackAction;
|
||||||
import mineplex.core.antihack.actions.BanwaveAction;
|
import mineplex.core.antihack.actions.BanwaveAction;
|
||||||
import mineplex.core.antihack.actions.GEPBanAction;
|
import mineplex.core.antihack.actions.GEPBanAction;
|
||||||
@ -73,7 +76,6 @@ import mineplex.core.antihack.gep.GwenExtremePrejudice;
|
|||||||
import mineplex.core.antihack.guardians.GuardianManager;
|
import mineplex.core.antihack.guardians.GuardianManager;
|
||||||
import mineplex.core.antihack.logging.AntihackLogger;
|
import mineplex.core.antihack.logging.AntihackLogger;
|
||||||
import mineplex.core.antihack.redisnotifications.GwenBanNotification;
|
import mineplex.core.antihack.redisnotifications.GwenBanNotification;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -103,6 +105,7 @@ public class AntiHack extends MiniPlugin
|
|||||||
.put(HeadRoll.class, new CheckThresholds("Illegal Movement", 0, 0, 1000))
|
.put(HeadRoll.class, new CheckThresholds("Illegal Movement", 0, 0, 1000))
|
||||||
.put(Toggle.class, new CheckThresholds("AutoSneak", 100, 200, 300))
|
.put(Toggle.class, new CheckThresholds("AutoSneak", 100, 200, 300))
|
||||||
.put(Timer.class, new CheckThresholds("Timer", 1000, 2000, 3000))
|
.put(Timer.class, new CheckThresholds("Timer", 1000, 2000, 3000))
|
||||||
|
.put(FastBow.class, new CheckThresholds("FastBow", 10, 20, 30))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
@ -128,6 +131,17 @@ public class AntiHack extends MiniPlugin
|
|||||||
|
|
||||||
public static final int ID_LENGTH = 5;
|
public static final int ID_LENGTH = 5;
|
||||||
|
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
SEE_GUARDIANS,
|
||||||
|
SEE_ALERTS,
|
||||||
|
SILENTLY_BANNED,
|
||||||
|
ANTICHEAT_TOGGLE_COMMAND,
|
||||||
|
DETAILED_MESSAGES_COMMAND,
|
||||||
|
GET_VLS_COMMAND,
|
||||||
|
TEST_BAN_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private final Cache<String, Integer> _cooldown = CacheBuilder.newBuilder()
|
private final Cache<String, Integer> _cooldown = CacheBuilder.newBuilder()
|
||||||
.concurrencyLevel(1)
|
.concurrencyLevel(1)
|
||||||
.expireAfterWrite(30, TimeUnit.SECONDS)
|
.expireAfterWrite(30, TimeUnit.SECONDS)
|
||||||
@ -174,7 +188,7 @@ public class AntiHack extends MiniPlugin
|
|||||||
{
|
{
|
||||||
player.spigot().sendMessage(detailed);
|
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.Get(player).hasPermission(Perm.SEE_ALERTS) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS)))
|
||||||
{
|
{
|
||||||
player.spigot().sendMessage(minimal);
|
player.spigot().sendMessage(minimal);
|
||||||
}
|
}
|
||||||
@ -182,6 +196,30 @@ public class AntiHack extends MiniPlugin
|
|||||||
});
|
});
|
||||||
|
|
||||||
new GwenExtremePrejudice(UtilServer.getPlugin());
|
new GwenExtremePrejudice(UtilServer.getPlugin());
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.SEE_GUARDIANS, true, true);
|
||||||
|
PermissionGroup.BUILDER.setPermission(Perm.SEE_GUARDIANS, true, false);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.SEE_GUARDIANS, true, true);
|
||||||
|
|
||||||
|
PermissionGroup.CONTENT.setPermission(Perm.SILENTLY_BANNED, true, true);
|
||||||
|
PermissionGroup.TRAINEE.setPermission(Perm.SILENTLY_BANNED, true, true);
|
||||||
|
|
||||||
|
PermissionGroup.TRAINEE.setPermission(Perm.SEE_ALERTS, true, true);
|
||||||
|
|
||||||
|
if (UtilServer.isTestServer())
|
||||||
|
{
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.ANTICHEAT_TOGGLE_COMMAND, true, true);
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.TEST_BAN_COMMAND, true, true);
|
||||||
|
}
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.DETAILED_MESSAGES_COMMAND, true, true);
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.GET_VLS_COMMAND, true, true);
|
||||||
|
PermissionGroup.QA.setPermission(Perm.DETAILED_MESSAGES_COMMAND, true, true);
|
||||||
|
PermissionGroup.QA.setPermission(Perm.GET_VLS_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -231,9 +269,7 @@ public class AntiHack extends MiniPlugin
|
|||||||
Consumer<Consumer<PunishmentResponse>> doPunish = after ->
|
Consumer<Consumer<PunishmentResponse>> doPunish = after ->
|
||||||
{
|
{
|
||||||
runAsync(() ->
|
runAsync(() ->
|
||||||
{
|
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.getPrimaryGroup().name().toLowerCase(), CheckManager.getCheckSimpleName(cause), id, gep).publish());
|
||||||
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish();
|
|
||||||
});
|
|
||||||
|
|
||||||
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after);
|
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after);
|
||||||
if (UtilServer.getGroup().equals("Clans"))
|
if (UtilServer.getGroup().equals("Clans"))
|
||||||
@ -245,15 +281,14 @@ public class AntiHack extends MiniPlugin
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (coreClient.GetRank().has(Rank.TWITCH))
|
if (_clientManager.Get(player).hasPermission(Perm.SILENTLY_BANNED))
|
||||||
{
|
{
|
||||||
doPunish.accept(result ->
|
doPunish.accept(result ->
|
||||||
{
|
{
|
||||||
_pendingBan.remove(player);
|
_pendingBan.remove(player);
|
||||||
_banned.add(player.getUniqueId());
|
_banned.add(player.getUniqueId());
|
||||||
});
|
});
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
runBanAnimation(player, () ->
|
runBanAnimation(player, () ->
|
||||||
{
|
{
|
||||||
@ -294,11 +329,11 @@ public class AntiHack extends MiniPlugin
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (coreClient.GetRank().has(Rank.TWITCH))
|
if (_clientManager.Get(player).hasPermission(Perm.SILENTLY_BANNED))
|
||||||
{
|
{
|
||||||
doPunish.accept(response -> {});
|
doPunish.accept(response -> {
|
||||||
}
|
});
|
||||||
else
|
} else
|
||||||
{
|
{
|
||||||
runBanAnimation(player, () ->
|
runBanAnimation(player, () ->
|
||||||
{
|
{
|
||||||
|
@ -65,9 +65,7 @@ public class BanWaveManager extends MiniPlugin
|
|||||||
if (_repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server))
|
if (_repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server))
|
||||||
{
|
{
|
||||||
runAsync(() ->
|
runAsync(() ->
|
||||||
{
|
new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), client.getPrimaryGroup().name().toLowerCase(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan).publish());
|
||||||
new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), client.GetRank().name(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan).publish();
|
|
||||||
});
|
|
||||||
|
|
||||||
JsonObject custom = new JsonObject();
|
JsonObject custom = new JsonObject();
|
||||||
custom.addProperty("is-banwave", true);
|
custom.addProperty("is-banwave", true);
|
||||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ public class AnticheatOffCommand extends CommandBase<AntiHack>
|
|||||||
{
|
{
|
||||||
public AnticheatOffCommand(AntiHack plugin)
|
public AnticheatOffCommand(AntiHack plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "acoff");
|
super(plugin, AntiHack.Perm.ANTICHEAT_TOGGLE_COMMAND, "acoff");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -21,4 +20,4 @@ public class AnticheatOffCommand extends CommandBase<AntiHack>
|
|||||||
Plugin.disableAnticheat();
|
Plugin.disableAnticheat();
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Disabled anticheat"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Disabled anticheat"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ public class AnticheatOnCommand extends CommandBase<AntiHack>
|
|||||||
{
|
{
|
||||||
public AnticheatOnCommand(AntiHack plugin)
|
public AnticheatOnCommand(AntiHack plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "acon");
|
super(plugin, AntiHack.Perm.ANTICHEAT_TOGGLE_COMMAND, "acon");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -21,4 +20,4 @@ public class AnticheatOnCommand extends CommandBase<AntiHack>
|
|||||||
Plugin.enableAnticheat();
|
Plugin.enableAnticheat();
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Enabled anticheat"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Enabled anticheat"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ public class DetailedMessagesCommand extends CommandBase<AntiHack>
|
|||||||
{
|
{
|
||||||
public DetailedMessagesCommand(AntiHack plugin)
|
public DetailedMessagesCommand(AntiHack plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "detailedmessages");
|
super(plugin, AntiHack.Perm.DETAILED_MESSAGES_COMMAND, "detailedmessages");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,4 +26,4 @@ public class DetailedMessagesCommand extends CommandBase<AntiHack>
|
|||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Detailed messages disabled"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Detailed messages disabled"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,6 @@ import com.mineplex.anticheat.checks.CheckManager;
|
|||||||
|
|
||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
@ -17,7 +16,7 @@ public class GetVlsCommand extends CommandBase<AntiHack>
|
|||||||
{
|
{
|
||||||
public GetVlsCommand(AntiHack plugin)
|
public GetVlsCommand(AntiHack plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "getvls");
|
super(plugin, AntiHack.Perm.GET_VLS_COMMAND, "getvls");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,4 +43,4 @@ public class GetVlsCommand extends CommandBase<AntiHack>
|
|||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "No player specified"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "No player specified"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
|
|||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
import mineplex.core.antihack.animations.BanwaveAnimationSpin;
|
import mineplex.core.antihack.animations.BanwaveAnimationSpin;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -17,7 +16,7 @@ public class TestBanCommand extends CommandBase<AntiHack>
|
|||||||
{
|
{
|
||||||
public TestBanCommand(AntiHack plugin)
|
public TestBanCommand(AntiHack plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "testban");
|
super(plugin, AntiHack.Perm.TEST_BAN_COMMAND, "testban");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,4 +47,4 @@ public class TestBanCommand extends CommandBase<AntiHack>
|
|||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "No player specified"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "No player specified"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,12 @@
|
|||||||
package mineplex.core.antihack.guardians;
|
package mineplex.core.antihack.guardians;
|
||||||
|
|
||||||
import com.mineplex.spigot.ChunkAddEntityEvent;
|
import java.util.Random;
|
||||||
import mineplex.core.Managers;
|
import java.util.UUID;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import java.util.function.Function;
|
||||||
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.EntityArmorStand;
|
||||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand;
|
||||||
@ -23,9 +19,16 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.Random;
|
import com.mineplex.spigot.ChunkAddEntityEvent;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.Function;
|
import mineplex.core.Managers;
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
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;
|
||||||
|
|
||||||
public class AntiHackGuardian implements Listener
|
public class AntiHackGuardian implements Listener
|
||||||
{
|
{
|
||||||
@ -115,16 +118,10 @@ public class AntiHackGuardian implements Listener
|
|||||||
if (!hideForStaff) return true;
|
if (!hideForStaff) return true;
|
||||||
|
|
||||||
// Don't let Builder -> Admin see it
|
// Don't let Builder -> Admin see it
|
||||||
Rank rank = clientManager.Get(player).GetRank();
|
if (!clientManager.Get(player).hasPermission(AntiHack.Perm.SEE_GUARDIANS))
|
||||||
if (rank.has(Rank.MAPDEV))
|
|
||||||
{
|
{
|
||||||
if (!rank.has(Rank.ADMIN))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rank == Rank.EVENT)
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
package mineplex.core.antihack.guardians;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -16,6 +7,17 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Function;
|
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.MiniPlugin;
|
||||||
|
import mineplex.core.PlayerSelector;
|
||||||
|
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
import mineplex.core.common.util.UtilLambda;
|
||||||
|
|
||||||
@ReflectivelyCreateMiniPlugin
|
@ReflectivelyCreateMiniPlugin
|
||||||
public class GuardianManager extends MiniPlugin
|
public class GuardianManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
@ -80,19 +82,18 @@ public class GuardianManager extends MiniPlugin
|
|||||||
UtilLambda.and(
|
UtilLambda.and(
|
||||||
PlayerSelector.NOT_VANISHED,
|
PlayerSelector.NOT_VANISHED,
|
||||||
PlayerSelector.hasAnyRank(false,
|
PlayerSelector.hasAnyRank(false,
|
||||||
Rank.ALL,
|
PermissionGroup.PLAYER,
|
||||||
Rank.ULTRA,
|
PermissionGroup.ULTRA,
|
||||||
Rank.HERO,
|
PermissionGroup.HERO,
|
||||||
Rank.LEGEND,
|
PermissionGroup.LEGEND,
|
||||||
Rank.TITAN,
|
PermissionGroup.TITAN,
|
||||||
Rank.TWITCH,
|
PermissionGroup.TWITCH,
|
||||||
Rank.YOUTUBE_SMALL,
|
PermissionGroup.YT,
|
||||||
Rank.YOUTUBE,
|
PermissionGroup.YOUTUBE,
|
||||||
Rank.MEDIA,
|
PermissionGroup.ADMIN,
|
||||||
Rank.ADMIN,
|
PermissionGroup.DEV,
|
||||||
Rank.DEVELOPER,
|
PermissionGroup.LT,
|
||||||
Rank.OWNER,
|
PermissionGroup.OWNER
|
||||||
Rank.LT
|
|
||||||
),
|
),
|
||||||
player -> !_stalking.contains(player.getUniqueId()),
|
player -> !_stalking.contains(player.getUniqueId()),
|
||||||
player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null
|
player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null
|
||||||
@ -126,4 +127,4 @@ public class GuardianManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
_guardians.add(guardian);
|
_guardians.add(guardian);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,6 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -19,20 +18,18 @@ import org.tukaani.xz.XZOutputStream;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonNull;
|
import com.google.gson.JsonNull;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.mineplex.anticheat.api.PlayerViolationEvent;
|
|
||||||
import com.mineplex.anticheat.checks.Check;
|
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
import mineplex.core.antihack.ViolationLevels;
|
|
||||||
import mineplex.core.antihack.logging.builtin.PartyInfoMetadata;
|
import mineplex.core.antihack.logging.builtin.PartyInfoMetadata;
|
||||||
import mineplex.core.antihack.logging.builtin.PlayerInfoMetadata;
|
import mineplex.core.antihack.logging.builtin.PlayerInfoMetadata;
|
||||||
import mineplex.core.antihack.logging.builtin.ServerInfoMetadata;
|
import mineplex.core.antihack.logging.builtin.ServerInfoMetadata;
|
||||||
import mineplex.core.antihack.logging.builtin.ViolationInfoMetadata;
|
import mineplex.core.antihack.logging.builtin.ViolationInfoMetadata;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -42,6 +39,11 @@ public class AntihackLogger extends MiniPlugin
|
|||||||
{
|
{
|
||||||
public static final Gson GSON = new Gson();
|
public static final Gson GSON = new Gson();
|
||||||
|
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
SAVE_METADATA_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private final CoreClientManager _clientManager = require(CoreClientManager.class);
|
private final CoreClientManager _clientManager = require(CoreClientManager.class);
|
||||||
|
|
||||||
private final Map<String, AnticheatMetadata> _metadata = new HashMap<>();
|
private final Map<String, AnticheatMetadata> _metadata = new HashMap<>();
|
||||||
@ -58,13 +60,24 @@ public class AntihackLogger extends MiniPlugin
|
|||||||
registerMetadata(new ViolationInfoMetadata());
|
registerMetadata(new ViolationInfoMetadata());
|
||||||
registerMetadata(new PartyInfoMetadata());
|
registerMetadata(new PartyInfoMetadata());
|
||||||
registerMetadata(new PlayerInfoMetadata());
|
registerMetadata(new PlayerInfoMetadata());
|
||||||
|
|
||||||
|
if (UtilServer.isTestServer())
|
||||||
|
{
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.SAVE_METADATA_COMMAND, true, true);
|
||||||
|
PermissionGroup.QA.setPermission(Perm.SAVE_METADATA_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCommands()
|
public void addCommands()
|
||||||
{
|
{
|
||||||
if (UtilServer.isTestServer())
|
if (UtilServer.isTestServer())
|
||||||
{
|
{
|
||||||
addCommand(new CommandBase<AntihackLogger>(this, Rank.SNR_MODERATOR, "savemetadata")
|
addCommand(new CommandBase<AntihackLogger>(this, Perm.SAVE_METADATA_COMMAND, "savemetadata")
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Execute(Player caller, String[] args)
|
||||||
@ -139,13 +152,13 @@ public class AntihackLogger extends MiniPlugin
|
|||||||
|
|
||||||
public void registerMetadata(AnticheatMetadata metadata)
|
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
|
else
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Attempting to register: " + metadata.getId());
|
throw new IllegalArgumentException("Attempting to register: " + metadata.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,23 +1,25 @@
|
|||||||
package mineplex.core.aprilfools;
|
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 com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.aprilfools.command.PirateSongCommand;
|
import mineplex.core.aprilfools.command.PirateSongCommand;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTextMiddle;
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
import mineplex.core.twofactor.TwoFactorAuth;
|
import mineplex.core.twofactor.TwoFactorAuth;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
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
|
public class AprilFoolsManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manually can be toggled to enable or disable the April Fools activities.
|
* Manually can be toggled to enable or disable the April Fools activities.
|
||||||
*/
|
*/
|
||||||
@ -76,13 +78,11 @@ public class AprilFoolsManager extends MiniPlugin
|
|||||||
.put("developer", "firstmate")
|
.put("developer", "firstmate")
|
||||||
.put("admin", "firstmate")
|
.put("admin", "firstmate")
|
||||||
.build();
|
.build();
|
||||||
private static final Map<Rank, String> RANK_REPLACEMENTS = ImmutableMap.<Rank, String>builder()
|
|
||||||
.put(Rank.ETERNAL, "Captain")
|
public enum Perm implements Permission
|
||||||
.put(Rank.TITAN, "FirstMate")
|
{
|
||||||
.put(Rank.LEGEND, "Boatswain")
|
PIRATE_SONG_COMMAND,
|
||||||
.put(Rank.HERO, "Gunner")
|
}
|
||||||
.put(Rank.ULTRA, "Parrot")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
private static AprilFoolsManager _instance;
|
private static AprilFoolsManager _instance;
|
||||||
private final AprilFoolsRepository _repository;
|
private final AprilFoolsRepository _repository;
|
||||||
@ -100,14 +100,13 @@ public class AprilFoolsManager extends MiniPlugin
|
|||||||
_twoFA = require(TwoFactorAuth.class);
|
_twoFA = require(TwoFactorAuth.class);
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
_enabledTitle = UtilServer.isHubServer() || UtilServer.isTestServer();
|
_enabledTitle = UtilServer.isHubServer() || UtilServer.isTestServer();
|
||||||
|
|
||||||
if (_enabled)
|
generatePermissions();
|
||||||
{
|
}
|
||||||
for (Map.Entry<Rank, String> entry : RANK_REPLACEMENTS.entrySet())
|
|
||||||
{
|
private void generatePermissions()
|
||||||
entry.getKey().setName(entry.getValue());
|
{
|
||||||
}
|
PermissionGroup.ADMIN.setPermission(Perm.PIRATE_SONG_COMMAND, true, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -251,4 +250,4 @@ public class AprilFoolsManager extends MiniPlugin
|
|||||||
|
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,28 +1,28 @@
|
|||||||
package mineplex.core.aprilfools.command;
|
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.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
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>
|
public class PirateSongCommand extends CommandBase<AprilFoolsManager>
|
||||||
{
|
{
|
||||||
|
private static final String[] PIRATE_SONG =
|
||||||
private static final String[] PIRATE_SONG = {
|
{
|
||||||
"Are you ready kids?",
|
"Are you ready kids?",
|
||||||
"Aye aye captain!",
|
"Aye aye captain!",
|
||||||
"I can't hear you!",
|
"I can't hear you!",
|
||||||
"AYE AYE CAPTAIN!",
|
"AYE AYE CAPTAIN!",
|
||||||
"OOOOOOOOOOOOH",
|
"OOOOOOOOOOOOH",
|
||||||
"Who lives in a pineapple under the sea?",
|
"Who lives in a pineapple under the sea?",
|
||||||
"Spongebob Squarepants!"
|
"Spongebob Squarepants!"
|
||||||
};
|
};
|
||||||
|
|
||||||
public PirateSongCommand(AprilFoolsManager plugin)
|
public PirateSongCommand(AprilFoolsManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "piratesong");
|
super(plugin, AprilFoolsManager.Perm.PIRATE_SONG_COMMAND, "piratesong");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -45,4 +45,4 @@ public class PirateSongCommand extends CommandBase<AprilFoolsManager>
|
|||||||
}
|
}
|
||||||
}, 20, 100);
|
}, 20, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,8 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
||||||
|
|
||||||
public class BetaWhitelist extends MiniPlugin
|
public class BetaWhitelist extends MiniPlugin
|
||||||
@ -40,6 +41,12 @@ public class BetaWhitelist extends MiniPlugin
|
|||||||
.add(UUID.fromString("6795643a-2b61-41bf-9429-c7549fd128a8")) // umGim
|
.add(UUID.fromString("6795643a-2b61-41bf-9429-c7549fd128a8")) // umGim
|
||||||
.add(UUID.fromString("47ba454a-4999-42f4-a269-2f4114ceb3c7")) // falconviii
|
.add(UUID.fromString("47ba454a-4999-42f4-a269-2f4114ceb3c7")) // falconviii
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
BYPASS_WHITELIST,
|
||||||
|
}
|
||||||
|
|
||||||
private final CoreClientManager _clientManager;
|
private final CoreClientManager _clientManager;
|
||||||
private final PowerPlayClubRepository _powerPlayClubRepository;
|
private final PowerPlayClubRepository _powerPlayClubRepository;
|
||||||
|
|
||||||
@ -48,16 +55,23 @@ public class BetaWhitelist extends MiniPlugin
|
|||||||
super("Beta Whitelist");
|
super("Beta Whitelist");
|
||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
_powerPlayClubRepository = powerPlayRepository;
|
_powerPlayClubRepository = powerPlayRepository;
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
|
||||||
|
PermissionGroup.ULTRA.setPermission(Perm.BYPASS_WHITELIST, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent event)
|
public void onJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Rank rank = _clientManager.Get(player).GetRank(true);
|
if (_clientManager.Get(player).hasPermission(Perm.BYPASS_WHITELIST) // If this player is Ultra+
|
||||||
if (rank.has(Rank.ULTRA) // If this player is Ultra+
|
|| _powerPlayClubRepository.getCachedData(player).isSubscribed() // a PPC subscriber,
|
||||||
|| _powerPlayClubRepository.getCachedData(player).isSubscribed() // a PPC subscriber,
|
|| EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted,
|
||||||
|| EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted,
|
|
||||||
{
|
{
|
||||||
return; // allow them in
|
return; // allow them in
|
||||||
}
|
}
|
||||||
@ -65,4 +79,4 @@ public class BetaWhitelist extends MiniPlugin
|
|||||||
// Otherwise, kick them out
|
// Otherwise, kick them out
|
||||||
event.getPlayer().kickPlayer("Sorry, you aren't whitelisted on this beta server.\n\nSubscribe to " + ChatColor.GOLD + "Power Play Club " + ChatColor.WHITE + "at " + ChatColor.GREEN + "mineplex.com/shop" + ChatColor.WHITE + "!");
|
event.getPlayer().kickPlayer("Sorry, you aren't whitelisted on this beta server.\n\nSubscribe to " + ChatColor.GOLD + "Power Play Club " + ChatColor.WHITE + "at " + ChatColor.GREEN + "mineplex.com/shop" + ChatColor.WHITE + "!");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,13 +8,16 @@ import java.util.ArrayList;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R3.DataWatcher;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityCreeper;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -36,6 +39,8 @@ import mineplex.core.account.CoreClient;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.ILoginProcessor;
|
import mineplex.core.account.ILoginProcessor;
|
||||||
import mineplex.core.account.event.ClientUnloadEvent;
|
import mineplex.core.account.event.ClientUnloadEvent;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.bonuses.animations.AnimationCarl;
|
import mineplex.core.bonuses.animations.AnimationCarl;
|
||||||
import mineplex.core.bonuses.commands.AnimationCommand;
|
import mineplex.core.bonuses.commands.AnimationCommand;
|
||||||
import mineplex.core.bonuses.commands.GuiCommand;
|
import mineplex.core.bonuses.commands.GuiCommand;
|
||||||
@ -48,7 +53,6 @@ import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
|
|||||||
import mineplex.core.bonuses.redis.VoteHandler;
|
import mineplex.core.bonuses.redis.VoteHandler;
|
||||||
import mineplex.core.bonuses.redis.VotifierCommand;
|
import mineplex.core.bonuses.redis.VotifierCommand;
|
||||||
import mineplex.core.common.Pair;
|
import mineplex.core.common.Pair;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.currency.GlobalCurrency;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
@ -83,15 +87,27 @@ import mineplex.database.Tables;
|
|||||||
import mineplex.database.tables.records.BonusRecord;
|
import mineplex.database.tables.records.BonusRecord;
|
||||||
import mineplex.serverdata.commands.ServerCommandManager;
|
import mineplex.serverdata.commands.ServerCommandManager;
|
||||||
import mineplex.serverdata.database.DBPool;
|
import mineplex.serverdata.database.DBPool;
|
||||||
import net.minecraft.server.v1_8_R3.DataWatcher;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityCreeper;
|
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
|
||||||
|
|
||||||
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
|
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
|
||||||
{
|
{
|
||||||
public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC");
|
public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC");
|
||||||
|
|
||||||
private static long timeOffSet = 0;
|
private static long timeOffSet = 0;
|
||||||
|
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
ETERNAL_BONUS,
|
||||||
|
TITAN_BONUS,
|
||||||
|
LEGEND_BONUS,
|
||||||
|
HERO_BONUS,
|
||||||
|
ULTRA_BONUS,
|
||||||
|
MONTHLY_BONUS,
|
||||||
|
ALLOW_COMMAND,
|
||||||
|
ANIMATION_COMMAND,
|
||||||
|
GUI_COMMAND,
|
||||||
|
POWER_PLAY_COMMAND,
|
||||||
|
TICKET_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private ArrayList<Object> _pendingExplosions = new ArrayList<>();
|
private ArrayList<Object> _pendingExplosions = new ArrayList<>();
|
||||||
private ArrayList<Player> _pendingExplosionsPlayers = new ArrayList<>();
|
private ArrayList<Player> _pendingExplosionsPlayers = new ArrayList<>();
|
||||||
@ -186,6 +202,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
_creeperName = "Carl";
|
_creeperName = "Carl";
|
||||||
|
|
||||||
updateOffSet();
|
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)
|
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 +306,25 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
PermissionGroup.ULTRA.setPermission(Perm.MONTHLY_BONUS, true, true);
|
||||||
|
PermissionGroup.ULTRA.setPermission(Perm.ULTRA_BONUS, true, true);
|
||||||
|
PermissionGroup.HERO.setPermission(Perm.HERO_BONUS, true, true);
|
||||||
|
PermissionGroup.LEGEND.setPermission(Perm.LEGEND_BONUS, true, true);
|
||||||
|
PermissionGroup.TITAN.setPermission(Perm.TITAN_BONUS, true, true);
|
||||||
|
PermissionGroup.ETERNAL.setPermission(Perm.ETERNAL_BONUS, true, true);
|
||||||
|
|
||||||
|
//pm.setPermission(pm.getGroup("mod"), Perm.ALLOW_COMMAND, true, true);
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.ANIMATION_COMMAND, true, true);
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.GUI_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.POWER_PLAY_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.TICKET_COMMAND, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCommands()
|
public void addCommands()
|
||||||
@ -746,29 +781,23 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
|
|
||||||
public BonusAmount getRankBonusAmount(Player player)
|
public BonusAmount getRankBonusAmount(Player player)
|
||||||
{
|
{
|
||||||
Rank rank = _clientManager.Get(player).GetRank();
|
|
||||||
|
|
||||||
BonusAmount data = new BonusAmount();
|
BonusAmount data = new BonusAmount();
|
||||||
|
|
||||||
if (rank.has(Rank.ETERNAL))
|
if (_clientManager.Get(player).hasPermission(Perm.ETERNAL_BONUS))
|
||||||
{
|
{
|
||||||
data.setIlluminatedChests(2);
|
data.setIlluminatedChests(2);
|
||||||
data.setMythicalChests(2);
|
data.setMythicalChests(2);
|
||||||
data.setOmegaChests(1);
|
data.setOmegaChests(1);
|
||||||
}
|
} else if (_clientManager.Get(player).hasPermission(Perm.TITAN_BONUS))
|
||||||
else if (rank.has(Rank.TITAN))
|
|
||||||
{
|
{
|
||||||
data.setMythicalChests(5);
|
data.setMythicalChests(5);
|
||||||
}
|
} else if (_clientManager.Get(player).hasPermission(Perm.LEGEND_BONUS))
|
||||||
else if (rank.has(Rank.LEGEND))
|
|
||||||
{
|
{
|
||||||
data.setMythicalChests(3);
|
data.setMythicalChests(3);
|
||||||
}
|
} else if (_clientManager.Get(player).hasPermission(Perm.HERO_BONUS))
|
||||||
else if (rank.has(Rank.HERO))
|
|
||||||
{
|
{
|
||||||
data.setMythicalChests(2);
|
data.setMythicalChests(2);
|
||||||
}
|
} else if (_clientManager.Get(player).hasPermission(Perm.ULTRA_BONUS))
|
||||||
else if (rank.has(Rank.ULTRA))
|
|
||||||
{
|
{
|
||||||
data.setMythicalChests(1);
|
data.setMythicalChests(1);
|
||||||
}
|
}
|
||||||
@ -984,16 +1013,15 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
if (canVote(player)) availableRewards++;
|
if (canVote(player)) availableRewards++;
|
||||||
if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++;
|
if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++;
|
||||||
if (_youtubeManager.canYoutube(player)) availableRewards++;
|
if (_youtubeManager.canYoutube(player)) availableRewards++;
|
||||||
if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++;
|
if (canRank(player) && _clientManager.Get(player).hasPermission(Perm.MONTHLY_BONUS) && isPastAugust()) availableRewards++;
|
||||||
if (canDaily(player)) 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 (!_facebookManager.hasRedeemed(player)) availableRewards++;
|
||||||
if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++;
|
if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++;
|
||||||
if (PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) availableRewards++;
|
if (PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) availableRewards++;
|
||||||
|
|
||||||
Hologram hologram;
|
Hologram hologram;
|
||||||
|
|
||||||
|
|
||||||
if (client.getHologram() == null)
|
if (client.getHologram() == null)
|
||||||
{
|
{
|
||||||
double yAdd = 2.3;
|
double yAdd = 2.3;
|
||||||
@ -1090,7 +1118,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
final BonusClientData clientData = Get(event.getUniqueId());
|
final BonusClientData clientData = Get(event.getUniqueId());
|
||||||
|
|
||||||
if (clientData.getHologram() != null)
|
if (clientData.getHologram() != null)
|
||||||
|
{
|
||||||
clientData.getHologram().stop();
|
clientData.getHologram().stop();
|
||||||
|
}
|
||||||
|
|
||||||
// Save streaks
|
// Save streaks
|
||||||
runAsync(() -> _repository.saveStreak(clientData.getAccountId(), clientData));
|
runAsync(() -> _repository.saveStreak(clientData.getAccountId(), clientData));
|
||||||
@ -1143,12 +1173,14 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
{
|
{
|
||||||
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
|
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.Get(player).hasPermission(Perm.MONTHLY_BONUS) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
|
||||||
{
|
{
|
||||||
if (_showCarl.containsKey(player.getName()))
|
if (_showCarl.containsKey(player.getName()))
|
||||||
{
|
{
|
||||||
if (_plugin.getClass().getSimpleName().equalsIgnoreCase("Hub") || _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub"))
|
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!");
|
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!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1232,4 +1264,4 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
{
|
{
|
||||||
return _carlNpc;
|
return _carlNpc;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,14 @@
|
|||||||
package mineplex.core.bonuses.commands;
|
package mineplex.core.bonuses.commands;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.bonuses.BonusManager;
|
import mineplex.core.bonuses.BonusManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.command.CommandCenter;
|
import mineplex.core.command.CommandCenter;
|
||||||
import mineplex.core.command.ICommand;
|
import mineplex.core.command.ICommand;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows players to run rank-specific commands
|
* Allows players to run rank-specific commands
|
||||||
@ -18,12 +16,11 @@ import org.bukkit.entity.Player;
|
|||||||
*/
|
*/
|
||||||
public class AllowCommand extends CommandBase<BonusManager>
|
public class AllowCommand extends CommandBase<BonusManager>
|
||||||
{
|
{
|
||||||
|
|
||||||
private BonusManager _plugin;
|
private BonusManager _plugin;
|
||||||
|
|
||||||
public AllowCommand(BonusManager plugin)
|
public AllowCommand(BonusManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.MODERATOR, "allowCommand", "allowCmd");
|
super(plugin, BonusManager.Perm.ALLOW_COMMAND, "allowCommand", "allowCmd");
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,9 +39,7 @@ public class AllowCommand extends CommandBase<BonusManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ICommand iCommand = commands.get(args[1]);
|
ICommand iCommand = commands.get(args[1]);
|
||||||
Rank playerRank = _plugin.getClientManager().Get(caller).GetRank();
|
if (!_plugin.getClientManager().Get(caller).hasPermission(iCommand.getPermission()))
|
||||||
if (playerRank.compareTo(iCommand.GetRequiredRank()) > 0
|
|
||||||
&& Arrays.asList(iCommand.GetSpecificRanks()).contains(playerRank))
|
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Allow Command", "You're not allowed to use that command!"));
|
UtilPlayer.message(caller, F.main("Allow Command", "You're not allowed to use that command!"));
|
||||||
return;
|
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(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]) + "!"));
|
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.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
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.bonuses.BonusManager;
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.reward.RewardType;
|
||||||
|
|
||||||
public class AnimationCommand extends CommandBase<BonusManager>{
|
public class AnimationCommand extends CommandBase<BonusManager>{
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ public class AnimationCommand extends CommandBase<BonusManager>{
|
|||||||
|
|
||||||
public AnimationCommand(BonusManager plugin)
|
public AnimationCommand(BonusManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "animation");
|
super(plugin, BonusManager.Perm.ANIMATION_COMMAND, "animation");
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,5 +29,4 @@ public class AnimationCommand extends CommandBase<BonusManager>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,22 +2,20 @@ package mineplex.core.bonuses.commands;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.bonuses.BonusManager;
|
import mineplex.core.bonuses.BonusManager;
|
||||||
import mineplex.core.bonuses.gui.BonusGui;
|
import mineplex.core.bonuses.gui.BonusGui;
|
||||||
|
import mineplex.core.command.CommandBase;
|
||||||
|
|
||||||
public class GuiCommand extends CommandBase<BonusManager>
|
public class GuiCommand extends CommandBase<BonusManager>
|
||||||
{
|
{
|
||||||
public GuiCommand(BonusManager plugin)
|
public GuiCommand(BonusManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "bonus");
|
super(plugin, BonusManager.Perm.GUI_COMMAND, "bonus");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Execute(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getThankManager(), Plugin.getPlayWireManager()).openInventory();
|
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;
|
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.LocalDate;
|
||||||
import java.time.YearMonth;
|
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>
|
public class PowerPlayCommand extends CommandBase<BonusManager>
|
||||||
{
|
{
|
||||||
|
|
||||||
private BonusManager _bonusManager;
|
private BonusManager _bonusManager;
|
||||||
|
|
||||||
public PowerPlayCommand(BonusManager manager)
|
public PowerPlayCommand(BonusManager manager)
|
||||||
{
|
{
|
||||||
super(manager, Rank.JNR_DEV, "powerplay");
|
super(manager, BonusManager.Perm.POWER_PLAY_COMMAND, "powerplay");
|
||||||
_bonusManager = manager;
|
_bonusManager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,4 +44,4 @@ public class PowerPlayCommand extends CommandBase<BonusManager>
|
|||||||
|
|
||||||
caller.sendMessage(ChatColor.GREEN + "Gave a month's subscription to " + player.getName());
|
caller.sendMessage(ChatColor.GREEN + "Gave a month's subscription to " + player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,19 +1,18 @@
|
|||||||
package mineplex.core.bonuses.commands;
|
package mineplex.core.bonuses.commands;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.bonuses.BonusManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.bonuses.BonusManager;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class TicketCommand extends CommandBase<BonusManager>
|
public class TicketCommand extends CommandBase<BonusManager>
|
||||||
{
|
{
|
||||||
public TicketCommand(BonusManager plugin)
|
public TicketCommand(BonusManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "ticket");
|
super(plugin, BonusManager.Perm.TICKET_COMMAND, "ticket");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -65,4 +64,4 @@ public class TicketCommand extends CommandBase<BonusManager>
|
|||||||
UtilPlayer.message(caller, F.main("Carl", "Invalid Ticket Amount"));
|
UtilPlayer.message(caller, F.main("Carl", "Invalid Ticket Amount"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,15 @@ package mineplex.core.bonuses.gui.buttons;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
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.account.CoreClientManager;
|
||||||
import mineplex.core.bonuses.BonusAmount;
|
import mineplex.core.bonuses.BonusAmount;
|
||||||
@ -19,14 +28,6 @@ import mineplex.core.poll.Poll;
|
|||||||
import mineplex.core.poll.PollManager;
|
import mineplex.core.poll.PollManager;
|
||||||
import mineplex.core.recharge.Recharge;
|
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 {
|
public class PollButton extends SimpleGui implements GuiItem {
|
||||||
|
|
||||||
protected boolean _create;
|
protected boolean _create;
|
||||||
@ -56,7 +57,7 @@ public class PollButton extends SimpleGui implements GuiItem {
|
|||||||
{
|
{
|
||||||
if (_create)
|
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)
|
if (_poll != null)
|
||||||
{
|
{
|
||||||
@ -77,7 +78,7 @@ public class PollButton extends SimpleGui implements GuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getObject()
|
public ItemStack getObject()
|
||||||
{
|
{
|
||||||
ArrayList<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
if (_poll == null)
|
if (_poll == null)
|
||||||
{
|
{
|
||||||
lore.add("");
|
lore.add("");
|
||||||
@ -128,14 +129,15 @@ public class PollButton extends SimpleGui implements GuiItem {
|
|||||||
|
|
||||||
public GuiItem getQuestionItem(String question)
|
public GuiItem getQuestionItem(String question)
|
||||||
{
|
{
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
ArrayList<String> lore = new ArrayList<>();
|
|
||||||
lore.add("");
|
lore.add("");
|
||||||
for (String string : wrap(question))
|
for (String string : wrap(question))
|
||||||
|
{
|
||||||
lore.add(C.cWhite + string);
|
lore.add(C.cWhite + string);
|
||||||
|
}
|
||||||
lore.add("");
|
lore.add("");
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for(String str : _poll.getAnswers())
|
for (String str : _poll.getAnswers())
|
||||||
{
|
{
|
||||||
lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str);
|
lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str);
|
||||||
i++;
|
i++;
|
||||||
@ -181,21 +183,20 @@ public class PollButton extends SimpleGui implements GuiItem {
|
|||||||
|
|
||||||
private class AnswerItem implements GuiItem
|
private class AnswerItem implements GuiItem
|
||||||
{
|
{
|
||||||
|
private int _num;
|
||||||
private int num;
|
|
||||||
|
|
||||||
private AnswerItem(Poll poll, int num)
|
private AnswerItem(Poll poll, int num)
|
||||||
{
|
{
|
||||||
this.num = num;
|
_num = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getObject()
|
public ItemStack getObject()
|
||||||
{
|
{
|
||||||
ArrayList<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add(C.cWhite + getPoll().getAnswers()[num]);
|
lore.add(C.cWhite + getPoll().getAnswers()[_num]);
|
||||||
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (num + 1), lore);
|
return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (_num + 1), lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -208,11 +209,11 @@ public class PollButton extends SimpleGui implements GuiItem {
|
|||||||
|
|
||||||
_create = true;
|
_create = true;
|
||||||
|
|
||||||
_pollManager.answerPoll(getPlayer(), _poll, num + 1);
|
_pollManager.answerPoll(getPlayer(), _poll, _num + 1);
|
||||||
|
|
||||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
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");
|
_bonusManager.addPendingExplosion(getPlayer(), "POLL");
|
||||||
getPlayer().closeInventory();
|
getPlayer().closeInventory();
|
||||||
}
|
}
|
||||||
@ -227,4 +228,4 @@ public class PollButton extends SimpleGui implements GuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {}
|
public void close() {}
|
||||||
}
|
}
|
@ -187,7 +187,7 @@ public class RankBonusButton implements GuiItem, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lore.add(" ");
|
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 bonusAmount = _bonusManager.getRankBonusAmount(_player);
|
||||||
bonusAmount.addLore(lore);
|
bonusAmount.addLore(lore);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,29 @@
|
|||||||
package mineplex.core.boosters;
|
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.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.boosters.command.BoosterCommand;
|
import mineplex.core.boosters.command.BoosterCommand;
|
||||||
import mineplex.core.boosters.event.BoosterActivateEvent;
|
import mineplex.core.boosters.event.BoosterActivateEvent;
|
||||||
import mineplex.core.boosters.event.BoosterExpireEvent;
|
import mineplex.core.boosters.event.BoosterExpireEvent;
|
||||||
@ -21,18 +43,6 @@ import mineplex.core.itemstack.ItemStackFactory;
|
|||||||
import mineplex.core.thank.ThankManager;
|
import mineplex.core.thank.ThankManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
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
|
* BoosterManager handles the majority of logic for creating and getting Boosters. Every BoosterManager stores a cache
|
||||||
@ -59,6 +69,15 @@ public class BoosterManager extends MiniPlugin
|
|||||||
// Slot for the booster gui item
|
// Slot for the booster gui item
|
||||||
public static final int INTERFACE_SLOT = 7;
|
public static final int INTERFACE_SLOT = 7;
|
||||||
|
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
ADD_BOOSTER_COMMAND,
|
||||||
|
BOOSTER_COMMAND,
|
||||||
|
BOOSTER_GUI_COMMAND,
|
||||||
|
RELOAD_BOOSTERS_COMMAND,
|
||||||
|
THANK_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private BoosterRepository _repository;
|
private BoosterRepository _repository;
|
||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
private DonationManager _donationManager;
|
private DonationManager _donationManager;
|
||||||
@ -100,6 +119,17 @@ public class BoosterManager extends MiniPlugin
|
|||||||
_giveInterfaceItem = canActivateBoosters();
|
_giveInterfaceItem = canActivateBoosters();
|
||||||
|
|
||||||
new BoosterUpdateRepository(plugin);
|
new BoosterUpdateRepository(plugin);
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.BOOSTER_COMMAND, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.THANK_COMMAND, true, true);
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.ADD_BOOSTER_COMMAND, true, true);
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.RELOAD_BOOSTERS_COMMAND, true, true);
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.BOOSTER_GUI_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -397,4 +427,4 @@ public class BoosterManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
runSync(() -> getPluginManager().callEvent(event));
|
runSync(() -> getPluginManager().callEvent(event));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,14 @@
|
|||||||
package mineplex.core.boosters.command;
|
package mineplex.core.boosters.command;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.boosters.BoosterApiResponse;
|
import mineplex.core.boosters.BoosterApiResponse;
|
||||||
import mineplex.core.boosters.BoosterManager;
|
import mineplex.core.boosters.BoosterManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
@ -16,7 +17,7 @@ public class AddCommand extends CommandBase<BoosterManager>
|
|||||||
{
|
{
|
||||||
public AddCommand(BoosterManager plugin)
|
public AddCommand(BoosterManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "add");
|
super(plugin, BoosterManager.Perm.ADD_BOOSTER_COMMAND, "add");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,6 +50,6 @@ public class AddCommand extends CommandBase<BoosterManager>
|
|||||||
|
|
||||||
private void help(Player caller)
|
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;
|
package mineplex.core.boosters.command;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.boosters.BoosterManager;
|
import mineplex.core.boosters.BoosterManager;
|
||||||
import mineplex.core.command.CommandBase;
|
|
||||||
import mineplex.core.command.MultiCommandBase;
|
import mineplex.core.command.MultiCommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
@ -15,7 +15,7 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
|||||||
{
|
{
|
||||||
public BoosterCommand(BoosterManager plugin)
|
public BoosterCommand(BoosterManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "amplifier");
|
super(plugin, BoosterManager.Perm.BOOSTER_COMMAND, "amplifier");
|
||||||
|
|
||||||
AddCommand(new AddCommand(plugin));
|
AddCommand(new AddCommand(plugin));
|
||||||
AddCommand(new GuiCommand(plugin));
|
AddCommand(new GuiCommand(plugin));
|
||||||
@ -26,8 +26,8 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
|||||||
@Override
|
@Override
|
||||||
protected void Help(Player caller, String[] args)
|
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 add <group>", "Add an amplifier to that group", ChatColor.DARK_RED));
|
||||||
UtilPlayer.message(caller, F.help("amplifier gui", "Open Amplifier GUI", Rank.DEVELOPER));
|
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", Rank.ALL));
|
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;
|
package mineplex.core.boosters.command;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.boosters.BoosterManager;
|
import mineplex.core.boosters.BoosterManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
@ -12,7 +12,7 @@ public class GuiCommand extends CommandBase<BoosterManager>
|
|||||||
{
|
{
|
||||||
public GuiCommand(BoosterManager plugin)
|
public GuiCommand(BoosterManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "gui");
|
super(plugin, BoosterManager.Perm.BOOSTER_GUI_COMMAND, "gui");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -20,4 +20,4 @@ public class GuiCommand extends CommandBase<BoosterManager>
|
|||||||
{
|
{
|
||||||
Plugin.openShop(caller);
|
Plugin.openShop(caller);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,11 @@
|
|||||||
package mineplex.core.boosters.command;
|
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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import mineplex.core.boosters.BoosterManager;
|
||||||
import java.util.Map;
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
@ -19,17 +14,18 @@ public class ReloadCommand extends CommandBase<BoosterManager>
|
|||||||
{
|
{
|
||||||
public ReloadCommand(BoosterManager plugin)
|
public ReloadCommand(BoosterManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, "reload");
|
super(plugin, BoosterManager.Perm.RELOAD_BOOSTERS_COMMAND, "reload");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Execute(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
Plugin.getBoostersAsync(data -> {
|
Plugin.getBoostersAsync(data ->
|
||||||
|
{
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Amplifier", "Amplifiers reloaded!"));
|
UtilPlayer.message(caller, F.main("Amplifier", "Amplifiers reloaded!"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,17 @@
|
|||||||
package mineplex.core.boosters.command;
|
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.Booster;
|
||||||
import mineplex.core.boosters.BoosterManager;
|
import mineplex.core.boosters.BoosterManager;
|
||||||
import mineplex.core.boosters.tips.BoosterThankManager;
|
import mineplex.core.boosters.tips.BoosterThankManager;
|
||||||
import mineplex.core.boosters.tips.TipAddResult;
|
import mineplex.core.boosters.tips.TipAddResult;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.currency.GlobalCurrency;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
@ -20,7 +20,7 @@ public class ThankCommand extends CommandBase<BoosterManager>
|
|||||||
{
|
{
|
||||||
public ThankCommand(BoosterManager plugin)
|
public ThankCommand(BoosterManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "thank");
|
super(plugin, BoosterManager.Perm.THANK_COMMAND, "thank");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,4 +71,4 @@ public class ThankCommand extends CommandBase<BoosterManager>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,23 +11,34 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
import mineplex.core.botspam.command.BotSpamCommand;
|
||||||
|
import mineplex.core.botspam.repository.BotSpamRepository;
|
||||||
import mineplex.core.message.PrivateMessageEvent;
|
import mineplex.core.message.PrivateMessageEvent;
|
||||||
import mineplex.core.punish.Category;
|
import mineplex.core.punish.Category;
|
||||||
import mineplex.core.punish.Punish;
|
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.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.serverdata.commands.ServerCommandManager;
|
import mineplex.serverdata.commands.ServerCommandManager;
|
||||||
|
|
||||||
public class BotSpamManager extends MiniPlugin
|
public class BotSpamManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
BYPASS_BOTSPAM,
|
||||||
|
BOTSPAM_COMMAND,
|
||||||
|
ADD_BOTSPAM_COMMAND,
|
||||||
|
TOGGLE_BOTSPAM_COMMAND,
|
||||||
|
UPDATE_BOTSPAM_COMMAND,
|
||||||
|
LIST_BOTSPAM_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private Punish _punish;
|
private Punish _punish;
|
||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
private BotSpamRepository _repository;
|
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)
|
public BotSpamManager(JavaPlugin plugin, CoreClientManager clientManager, Punish punish)
|
||||||
{
|
{
|
||||||
@ -39,6 +50,19 @@ public class BotSpamManager extends MiniPlugin
|
|||||||
_spam = _repository.getSpamText();
|
_spam = _repository.getSpamText();
|
||||||
|
|
||||||
ServerCommandManager.getInstance().registerCommandType(ForceUpdateCommand.class, command -> runAsync(() -> _spam = _repository.getSpamText()));
|
ServerCommandManager.getInstance().registerCommandType(ForceUpdateCommand.class, command -> runAsync(() -> _spam = _repository.getSpamText()));
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
|
||||||
|
PermissionGroup.TRAINEE.setPermission(Perm.BYPASS_BOTSPAM, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.BOTSPAM_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.ADD_BOTSPAM_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.TOGGLE_BOTSPAM_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.UPDATE_BOTSPAM_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.LIST_BOTSPAM_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -46,11 +70,11 @@ public class BotSpamManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
Player recipient = event.getRecipient();
|
Player recipient = event.getRecipient();
|
||||||
// Ignore messages sent to staff members
|
// Ignore messages sent to staff members
|
||||||
if (_clientManager.hasRank(recipient, Rank.HELPER))
|
if (_clientManager.Get(recipient).hasPermission(Perm.BYPASS_BOTSPAM))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Ignore messages sent by staff members
|
// Ignore messages sent by staff members
|
||||||
if (_clientManager.hasRank(event.getSender(), Rank.HELPER))
|
if (_clientManager.Get(event.getSender()).hasPermission(Perm.BYPASS_BOTSPAM))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (SpamText spamText : _spam)
|
for (SpamText spamText : _spam)
|
||||||
@ -68,7 +92,7 @@ public class BotSpamManager extends MiniPlugin
|
|||||||
public void onChat(final AsyncPlayerChatEvent event)
|
public void onChat(final AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
// Ignore messages sent by staff members
|
// Ignore messages sent by staff members
|
||||||
if (_clientManager.hasRank(event.getPlayer(), Rank.HELPER))
|
if (_clientManager.Get(event.getPlayer()).hasPermission(Perm.BYPASS_BOTSPAM))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (final SpamText spamText : _spam)
|
for (final SpamText spamText : _spam)
|
||||||
@ -98,7 +122,9 @@ public class BotSpamManager extends MiniPlugin
|
|||||||
_spam = _repository.getSpamText();
|
_spam = _repository.getSpamText();
|
||||||
|
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
|
{
|
||||||
runSync(callback);
|
runSync(callback);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +140,9 @@ public class BotSpamManager extends MiniPlugin
|
|||||||
spamText.setEnabledBy(caller);
|
spamText.setEnabledBy(caller);
|
||||||
|
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
|
{
|
||||||
callback.run();
|
callback.run();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -131,7 +159,9 @@ public class BotSpamManager extends MiniPlugin
|
|||||||
spamText.setDisabledBy(caller);
|
spamText.setDisabledBy(caller);
|
||||||
|
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
|
{
|
||||||
callback.run();
|
callback.run();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -155,4 +185,4 @@ public class BotSpamManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
addCommand(new BotSpamCommand(this));
|
addCommand(new BotSpamCommand(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,18 +3,17 @@ package mineplex.core.botspam.command;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.botspam.BotSpamManager;
|
||||||
import mineplex.core.botspam.SpamText;
|
import mineplex.core.botspam.SpamText;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.botspam.BotSpamManager;
|
|
||||||
|
|
||||||
public class BotSpamAddCommand extends CommandBase<BotSpamManager>
|
public class BotSpamAddCommand extends CommandBase<BotSpamManager>
|
||||||
{
|
{
|
||||||
public BotSpamAddCommand(BotSpamManager plugin)
|
public BotSpamAddCommand(BotSpamManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "add");
|
super(plugin, BotSpamManager.Perm.ADD_BOTSPAM_COMMAND, "add");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,4 +49,4 @@ public class BotSpamAddCommand extends CommandBase<BotSpamManager>
|
|||||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam add <text>"));
|
UtilPlayer.message(caller, F.main("BotSpam", "/botspam add <text>"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.botspam.BotSpamManager;
|
import mineplex.core.botspam.BotSpamManager;
|
||||||
import mineplex.core.command.MultiCommandBase;
|
import mineplex.core.command.MultiCommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ public class BotSpamCommand extends MultiCommandBase<BotSpamManager>
|
|||||||
{
|
{
|
||||||
public BotSpamCommand(BotSpamManager plugin)
|
public BotSpamCommand(BotSpamManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "botban", "botspam");
|
super(plugin, BotSpamManager.Perm.BOTSPAM_COMMAND, "botban", "botspam");
|
||||||
|
|
||||||
AddCommand(new BotSpamAddCommand(Plugin));
|
AddCommand(new BotSpamAddCommand(Plugin));
|
||||||
AddCommand(new BotSpamEnableCommand(Plugin));
|
AddCommand(new BotSpamEnableCommand(Plugin));
|
||||||
@ -30,4 +29,4 @@ public class BotSpamCommand extends MultiCommandBase<BotSpamManager>
|
|||||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
|
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
|
||||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam globalupdate"));
|
UtilPlayer.message(caller, F.main("BotSpam", "/botspam globalupdate"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,10 +2,9 @@ package mineplex.core.botspam.command;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.botspam.BotSpamManager;
|
||||||
import mineplex.core.botspam.SpamText;
|
import mineplex.core.botspam.SpamText;
|
||||||
import mineplex.core.command.CommandBase;
|
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.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ public class BotSpamDisableCommand extends CommandBase<BotSpamManager>
|
|||||||
{
|
{
|
||||||
public BotSpamDisableCommand(BotSpamManager plugin)
|
public BotSpamDisableCommand(BotSpamManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "disable");
|
super(plugin, BotSpamManager.Perm.TOGGLE_BOTSPAM_COMMAND, "disable");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,6 +58,5 @@ public class BotSpamDisableCommand extends CommandBase<BotSpamManager>
|
|||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
|
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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.botspam.BotSpamManager;
|
||||||
import mineplex.core.botspam.SpamText;
|
import mineplex.core.botspam.SpamText;
|
||||||
import mineplex.core.command.CommandBase;
|
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.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ public class BotSpamEnableCommand extends CommandBase<BotSpamManager>
|
|||||||
{
|
{
|
||||||
public BotSpamEnableCommand(BotSpamManager plugin)
|
public BotSpamEnableCommand(BotSpamManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "enable");
|
super(plugin, BotSpamManager.Perm.TOGGLE_BOTSPAM_COMMAND, "enable");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,6 +58,5 @@ public class BotSpamEnableCommand extends CommandBase<BotSpamManager>
|
|||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable <text id>"));
|
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.BotSpamManager;
|
||||||
import mineplex.core.botspam.ForceUpdateCommand;
|
import mineplex.core.botspam.ForceUpdateCommand;
|
||||||
import mineplex.core.botspam.SpamText;
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.serverdata.commands.ServerCommandManager;
|
import mineplex.serverdata.commands.ServerCommandManager;
|
||||||
@ -15,7 +13,7 @@ public class BotSpamGlobalUpdateCommand extends CommandBase<BotSpamManager>
|
|||||||
{
|
{
|
||||||
public BotSpamGlobalUpdateCommand(BotSpamManager plugin)
|
public BotSpamGlobalUpdateCommand(BotSpamManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "globalupdate");
|
super(plugin, BotSpamManager.Perm.UPDATE_BOTSPAM_COMMAND, "globalupdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -24,4 +22,4 @@ public class BotSpamGlobalUpdateCommand extends CommandBase<BotSpamManager>
|
|||||||
ServerCommandManager.getInstance().publishCommand(new ForceUpdateCommand());
|
ServerCommandManager.getInstance().publishCommand(new ForceUpdateCommand());
|
||||||
UtilPlayer.message(caller, F.main("Botspam", "Forced an update across all servers!"));
|
UtilPlayer.message(caller, F.main("Botspam", "Forced an update across all servers!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,6 @@ import org.bukkit.entity.Player;
|
|||||||
import mineplex.core.botspam.BotSpamManager;
|
import mineplex.core.botspam.BotSpamManager;
|
||||||
import mineplex.core.botspam.SpamText;
|
import mineplex.core.botspam.SpamText;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -24,7 +23,7 @@ public class BotSpamListCommand extends CommandBase<BotSpamManager>
|
|||||||
{
|
{
|
||||||
public BotSpamListCommand(BotSpamManager plugin)
|
public BotSpamListCommand(BotSpamManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "list");
|
super(plugin, BotSpamManager.Perm.LIST_BOTSPAM_COMMAND, "list");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -207,4 +206,4 @@ public class BotSpamListCommand extends CommandBase<BotSpamManager>
|
|||||||
|
|
||||||
caller.spigot().sendMessage(pageSwitch.create());
|
caller.spigot().sendMessage(pageSwitch.create());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,39 +1,5 @@
|
|||||||
package mineplex.core.chat;
|
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 org.apache.commons.lang3.Validate;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.JSONValue;
|
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
import javax.net.ssl.HostnameVerifier;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
@ -49,13 +15,62 @@ import java.nio.charset.Charset;
|
|||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.JSONValue;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
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 class Chat extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
ALLOW_CAPS,
|
||||||
|
BYPASS_COOLDOWN,
|
||||||
|
BYPASS_SLOW,
|
||||||
|
BYPASS_SILENCE,
|
||||||
|
BYPASS_SIGNS,
|
||||||
|
ALLOW_HACKUSATE,
|
||||||
|
ALLOW_SIMILAR,
|
||||||
|
SILENCE_COMMAND,
|
||||||
|
SLOW_CHAT_COMMAND,
|
||||||
|
BROADCAST_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
private PreferencesManager _preferences;
|
private PreferencesManager _preferences;
|
||||||
private AchievementManager _achievements;
|
private AchievementManager _achievements;
|
||||||
@ -73,7 +88,7 @@ public class Chat extends MiniPlugin
|
|||||||
private List<Function<AsyncPlayerChatEvent, Boolean>> _highPriorityFilters = new ArrayList<>();
|
private List<Function<AsyncPlayerChatEvent, Boolean>> _highPriorityFilters = new ArrayList<>();
|
||||||
private List<Function<AsyncPlayerChatEvent, Boolean>> _lowPriorityFilters = 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)
|
public Chat(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName)
|
||||||
{
|
{
|
||||||
@ -93,6 +108,22 @@ public class Chat extends MiniPlugin
|
|||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.ALLOW_CAPS, true, true);
|
||||||
|
PermissionGroup.MOD.setPermission(Perm.BYPASS_COOLDOWN, true, true);
|
||||||
|
PermissionGroup.TRAINEE.setPermission(Perm.BYPASS_SLOW, true, true);
|
||||||
|
PermissionGroup.MOD.setPermission(Perm.BYPASS_SILENCE, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.BYPASS_SIGNS, true, true);
|
||||||
|
PermissionGroup.TRAINEE.setPermission(Perm.ALLOW_HACKUSATE, true, true);
|
||||||
|
PermissionGroup.MOD.setPermission(Perm.ALLOW_SIMILAR, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.SILENCE_COMMAND, true, true);
|
||||||
|
PermissionGroup.SRMOD.setPermission(Perm.SLOW_CHAT_COMMAND, true, true);
|
||||||
|
PermissionGroup.MOD.setPermission(Perm.BROADCAST_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -190,7 +221,7 @@ public class Chat extends MiniPlugin
|
|||||||
if (_silenced == 0)
|
if (_silenced == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_clientManager.Get(player).GetRank().has(player, Rank.MODERATOR, false))
|
if (_clientManager.Get(player).hasPermission(Perm.BYPASS_SILENCE))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_silenced == -1)
|
if (_silenced == -1)
|
||||||
@ -208,7 +239,10 @@ public class Chat extends MiniPlugin
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onSignChange(SignChangeEvent event)
|
public void onSignChange(SignChangeEvent event)
|
||||||
{
|
{
|
||||||
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) return;
|
if (_clientManager.Get(event.getPlayer()).hasPermission(Perm.BYPASS_SIGNS))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent silenced players from using signs
|
// Prevent silenced players from using signs
|
||||||
if (SilenceCheck(event.getPlayer()))
|
if (SilenceCheck(event.getPlayer()))
|
||||||
@ -343,13 +377,13 @@ public class Chat extends MiniPlugin
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
|
else if (!_clientManager.Get(sender).hasPermission(Perm.BYPASS_COOLDOWN) &&
|
||||||
!Recharge.Instance.use(sender, "Chat Message", 400, false, false))
|
!Recharge.Instance.use(sender, "Chat Message", 400, false, false))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast."));
|
UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast."));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.HELPER) &&
|
else if (!_clientManager.Get(sender).hasPermission(Perm.ALLOW_HACKUSATE) &&
|
||||||
msgContainsHack(event.getMessage()))
|
msgContainsHack(event.getMessage()))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(sender, F.main("Chat",
|
UtilPlayer.message(sender, F.main("Chat",
|
||||||
@ -363,12 +397,12 @@ public class Chat extends MiniPlugin
|
|||||||
MessageData lastMessage = _playerLastMessage.get(sender.getUniqueId());
|
MessageData lastMessage = _playerLastMessage.get(sender.getUniqueId());
|
||||||
long chatSlowTime = 1000L * _chatSlow;
|
long chatSlowTime = 1000L * _chatSlow;
|
||||||
long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
|
long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
|
||||||
if (timeDiff < chatSlowTime && !_clientManager.Get(sender).GetRank().has(Rank.HELPER))
|
if (timeDiff < chatSlowTime && !_clientManager.Get(sender).hasPermission(Perm.BYPASS_SLOW))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(sender, F.main("Chat", "Chat slow enabled. Please wait " + F.time(UtilTime.convertString(chatSlowTime - timeDiff, 1, UtilTime.TimeUnit.FIT))));
|
UtilPlayer.message(sender, F.main("Chat", "Chat slow enabled. Please wait " + F.time(UtilTime.convertString(chatSlowTime - timeDiff, 1, UtilTime.TimeUnit.FIT))));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
|
else if (!_clientManager.Get(sender).hasPermission(Perm.ALLOW_SIMILAR) &&
|
||||||
UtilText.isStringSimilar(event.getMessage(), lastMessage.getMessage(), 0.8f))
|
UtilText.isStringSimilar(event.getMessage(), lastMessage.getMessage(), 0.8f))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(sender, F.main("Chat", "This message is too similar to your previous message."));
|
UtilPlayer.message(sender, F.main("Chat", "This message is too similar to your previous message."));
|
||||||
@ -379,7 +413,7 @@ public class Chat extends MiniPlugin
|
|||||||
if (!event.isCancelled())
|
if (!event.isCancelled())
|
||||||
{
|
{
|
||||||
String oldMessage = event.getMessage();
|
String oldMessage = event.getMessage();
|
||||||
if (!_clientManager.Get(sender).GetRank().has(Rank.ADMIN))
|
if (!_clientManager.Get(sender).hasPermission(Perm.ALLOW_CAPS))
|
||||||
{
|
{
|
||||||
int capsCount = 0;
|
int capsCount = 0;
|
||||||
for (char c : oldMessage.toCharArray())
|
for (char c : oldMessage.toCharArray())
|
||||||
@ -669,5 +703,4 @@ public class Chat extends MiniPlugin
|
|||||||
_lowPriorityFilters.add(restriction);
|
_lowPriorityFilters.add(restriction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -13,7 +12,7 @@ public class BroadcastCommand extends CommandBase<Chat>
|
|||||||
{
|
{
|
||||||
public BroadcastCommand(Chat plugin)
|
public BroadcastCommand(Chat plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.MODERATOR, "s");
|
super(plugin, Chat.Perm.BROADCAST_COMMAND, "s");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -35,4 +34,4 @@ public class BroadcastCommand extends CommandBase<Chat>
|
|||||||
|
|
||||||
UtilServer.broadcast(caller.getName(), announcement);
|
UtilServer.broadcast(caller.getName(), announcement);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ public class ChatSlowCommand extends CommandBase<Chat>
|
|||||||
{
|
{
|
||||||
public ChatSlowCommand(Chat plugin)
|
public ChatSlowCommand(Chat plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.SNR_MODERATOR, "chatslow");
|
super(plugin, Chat.Perm.SLOW_CHAT_COMMAND, "chatslow");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,4 +47,4 @@ public class ChatSlowCommand extends CommandBase<Chat>
|
|||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Chat", "Usage: /chatslow <seconds>"));
|
UtilPlayer.message(caller, F.main("Chat", "Usage: /chatslow <seconds>"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ public class SilenceCommand extends CommandBase<Chat>
|
|||||||
{
|
{
|
||||||
public SilenceCommand(Chat plugin)
|
public SilenceCommand(Chat plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "silence");
|
super(plugin, Chat.Perm.SILENCE_COMMAND, "silence");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,4 +46,4 @@ public class SilenceCommand extends CommandBase<Chat>
|
|||||||
UtilPlayer.message(caller, F.main("Chat", "Invalid Time Parameter."));
|
UtilPlayer.message(caller, F.main("Chat", "Invalid Time Parameter."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.chatsnap.command.ChatSnapCommand;
|
import mineplex.core.chatsnap.command.ChatSnapCommand;
|
||||||
import mineplex.core.message.PrivateMessageEvent;
|
import mineplex.core.message.PrivateMessageEvent;
|
||||||
|
|
||||||
@ -19,6 +21,11 @@ import mineplex.core.message.PrivateMessageEvent;
|
|||||||
*/
|
*/
|
||||||
public class SnapshotPlugin extends MiniPlugin
|
public class SnapshotPlugin extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
CHAT_SNAP_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private final SnapshotManager _snapshotManager;
|
private final SnapshotManager _snapshotManager;
|
||||||
private final CoreClientManager _clientManager;
|
private final CoreClientManager _clientManager;
|
||||||
|
|
||||||
@ -27,6 +34,14 @@ public class SnapshotPlugin extends MiniPlugin
|
|||||||
super("ChatSnap", plugin);
|
super("ChatSnap", plugin);
|
||||||
_snapshotManager = snapshotManager;
|
_snapshotManager = snapshotManager;
|
||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
|
||||||
|
PermissionGroup.TITAN.setPermission(Perm.CHAT_SNAP_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SnapshotManager getSnapshotManager()
|
public SnapshotManager getSnapshotManager()
|
||||||
@ -79,4 +94,4 @@ public class SnapshotPlugin extends MiniPlugin
|
|||||||
String message = e.getMessage();
|
String message = e.getMessage();
|
||||||
return new SnapshotMessage(senderId, recipientId, message);
|
return new SnapshotMessage(senderId, recipientId, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,6 @@ import mineplex.core.chatsnap.SnapshotMessage;
|
|||||||
import mineplex.core.chatsnap.SnapshotPlugin;
|
import mineplex.core.chatsnap.SnapshotPlugin;
|
||||||
import mineplex.core.chatsnap.SnapshotRepository;
|
import mineplex.core.chatsnap.SnapshotRepository;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.jsonchat.ClickEvent;
|
import mineplex.core.common.jsonchat.ClickEvent;
|
||||||
import mineplex.core.common.jsonchat.JsonMessage;
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -23,7 +22,7 @@ public class ChatSnapCommand extends CommandBase<SnapshotPlugin>
|
|||||||
{
|
{
|
||||||
public ChatSnapCommand(SnapshotPlugin plugin)
|
public ChatSnapCommand(SnapshotPlugin plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.TITAN, "chatsnap");
|
super(plugin, SnapshotPlugin.Perm.CHAT_SNAP_COMMAND, "chatsnap");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,4 +67,4 @@ public class ChatSnapCommand extends CommandBase<SnapshotPlugin>
|
|||||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed)));
|
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,34 +15,23 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.PlayerSelector;
|
import mineplex.core.PlayerSelector;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.account.permissions.Permission;
|
||||||
import mineplex.core.common.util.UtilLambda;
|
import mineplex.core.common.util.UtilLambda;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
|
|
||||||
public abstract class CommandBase<PluginType extends MiniPlugin> implements ICommand
|
public abstract class CommandBase<PluginType extends MiniPlugin> implements ICommand
|
||||||
{
|
{
|
||||||
private Rank _requiredRank;
|
private final Permission _permission;
|
||||||
private Rank[] _specificRank;
|
|
||||||
|
|
||||||
private List<String> _aliases;
|
private List<String> _aliases;
|
||||||
|
|
||||||
protected PluginType Plugin;
|
protected PluginType Plugin;
|
||||||
protected String _aliasUsed;
|
protected String _aliasUsed;
|
||||||
protected CommandCenter _commandCenter;
|
protected CommandCenter _commandCenter;
|
||||||
|
|
||||||
public CommandBase(PluginType plugin, Rank requiredRank, String... aliases)
|
public CommandBase(PluginType plugin, Permission permission, String... aliases)
|
||||||
{
|
{
|
||||||
Plugin = plugin;
|
Plugin = plugin;
|
||||||
_requiredRank = requiredRank;
|
_permission = permission;
|
||||||
_aliases = Arrays.asList(aliases);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommandBase(PluginType plugin, Rank requiredRank, Rank[] specificRank, String... aliases)
|
|
||||||
{
|
|
||||||
Plugin = plugin;
|
|
||||||
_requiredRank = requiredRank;
|
|
||||||
_specificRank = specificRank;
|
|
||||||
|
|
||||||
_aliases = Arrays.asList(aliases);
|
_aliases = Arrays.asList(aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,19 +45,9 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
|
|||||||
_aliasUsed = alias;
|
_aliasUsed = alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank GetRequiredRank()
|
public Permission getPermission()
|
||||||
{
|
{
|
||||||
return _requiredRank;
|
return _permission;
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequiredRank(Rank rank)
|
|
||||||
{
|
|
||||||
_requiredRank = rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rank[] GetSpecificRanks()
|
|
||||||
{
|
|
||||||
return _specificRank;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCommandCenter(CommandCenter commandCenter)
|
public void SetCommandCenter(CommandCenter commandCenter)
|
||||||
@ -158,4 +137,4 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,6 @@
|
|||||||
package mineplex.core.command;
|
package mineplex.core.command;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -22,11 +20,14 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilPlayerBase;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.packethandler.IPacketHandler;
|
import mineplex.core.packethandler.IPacketHandler;
|
||||||
import mineplex.core.packethandler.PacketHandler;
|
import mineplex.core.packethandler.PacketHandler;
|
||||||
import mineplex.core.packethandler.PacketInfo;
|
import mineplex.core.packethandler.PacketInfo;
|
||||||
@ -46,6 +47,11 @@ public class CommandCenter implements Listener, IPacketHandler
|
|||||||
|
|
||||||
private static AtomicIntegerFieldUpdater<PlayerConnection> chatSpamField = null;
|
private static AtomicIntegerFieldUpdater<PlayerConnection> chatSpamField = null;
|
||||||
|
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
BLOCKED_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -78,6 +84,12 @@ public class CommandCenter implements Listener, IPacketHandler
|
|||||||
Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
|
Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
|
||||||
|
|
||||||
_packetHandler.addPacketHandler(this, true, PacketPlayInTabComplete.class);
|
_packetHandler.addPacketHandler(this, true, PacketPlayInTabComplete.class);
|
||||||
|
|
||||||
|
PermissionGroup.DEV.setPermission(Perm.BLOCKED_COMMAND, true, true);
|
||||||
|
if (UtilServer.isTestServer())
|
||||||
|
{
|
||||||
|
PermissionGroup.QAM.setPermission(Perm.BLOCKED_COMMAND, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClientManager(CoreClientManager clientManager)
|
public void setClientManager(CoreClientManager clientManager)
|
||||||
@ -104,7 +116,7 @@ public class CommandCenter implements Listener, IPacketHandler
|
|||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true)
|
if (ClientManager.Get(event.getPlayer()).hasPermission(command.getPermission())
|
||||||
|| UtilPlayer.isCommandAllowed(event.getPlayer(), commandName.toLowerCase()))
|
|| UtilPlayer.isCommandAllowed(event.getPlayer(), commandName.toLowerCase()))
|
||||||
{
|
{
|
||||||
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
|
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
|
||||||
@ -122,10 +134,14 @@ public class CommandCenter implements Listener, IPacketHandler
|
|||||||
|
|
||||||
command.Execute(event.getPlayer(), args);
|
command.Execute(event.getPlayer(), args);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayerBase.message(event.getPlayer(), C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
|
||||||
|
}
|
||||||
return;
|
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.Get(event.getPlayer()).hasPermission(Perm.BLOCKED_COMMAND)))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(MESSAGE);
|
event.getPlayer().sendMessage(MESSAGE);
|
||||||
@ -199,7 +215,7 @@ public class CommandCenter implements Listener, IPacketHandler
|
|||||||
|
|
||||||
if (command != null)
|
if (command != null)
|
||||||
{
|
{
|
||||||
if (ClientManager.Get(packetInfo.getPlayer()).GetRank().has(packetInfo.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), false)
|
if (ClientManager.Get(packetInfo.getPlayer()).hasPermission(command.getPermission())
|
||||||
|| UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase()))
|
|| UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase()))
|
||||||
{
|
{
|
||||||
List<String> tmpres = command.onTabComplete(packetInfo.getPlayer(), commandName.toLowerCase(), args);
|
List<String> tmpres = command.onTabComplete(packetInfo.getPlayer(), commandName.toLowerCase(), args);
|
||||||
@ -216,7 +232,7 @@ public class CommandCenter implements Listener, IPacketHandler
|
|||||||
// System.out.println("Path 2");
|
// System.out.println("Path 2");
|
||||||
for (ICommand command : Commands.values())
|
for (ICommand command : Commands.values())
|
||||||
{
|
{
|
||||||
if (ClientManager.Get(packetInfo.getPlayer()).GetRank().has(packetInfo.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), false)
|
if (ClientManager.Get(packetInfo.getPlayer()).hasPermission(command.getPermission())
|
||||||
|| UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase()))
|
|| UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase()))
|
||||||
{
|
{
|
||||||
for (String alias : command.Aliases())
|
for (String alias : command.Aliases())
|
||||||
@ -236,4 +252,4 @@ public class CommandCenter implements Listener, IPacketHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,12 +3,12 @@ package mineplex.core.command;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
|
|
||||||
import mineplex.core.lifetimes.Component;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.lifetimes.Component;
|
||||||
|
|
||||||
public interface ICommand extends Component
|
public interface ICommand extends Component
|
||||||
{
|
{
|
||||||
void SetCommandCenter(CommandCenter commandCenter);
|
void SetCommandCenter(CommandCenter commandCenter);
|
||||||
@ -17,9 +17,8 @@ public interface ICommand extends Component
|
|||||||
Collection<String> Aliases();
|
Collection<String> Aliases();
|
||||||
|
|
||||||
void SetAliasUsed(String name);
|
void SetAliasUsed(String name);
|
||||||
|
|
||||||
Rank GetRequiredRank();
|
Permission getPermission();
|
||||||
Rank[] GetSpecificRanks();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void activate()
|
default void activate()
|
||||||
@ -34,4 +33,4 @@ public interface ICommand extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args);
|
List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args);
|
||||||
}
|
}
|
@ -7,11 +7,9 @@ package mineplex.core.command;
|
|||||||
*/
|
*/
|
||||||
public interface LoggedCommand
|
public interface LoggedCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
default void execute(long time, String username, String command, String args)
|
default void execute(long time, String username, String command, String args)
|
||||||
{
|
{
|
||||||
LoggingServerCommand cmd = new LoggingServerCommand(time, username, command, args);
|
LoggingServerCommand cmd = new LoggingServerCommand(time, username, command, args);
|
||||||
cmd.publish();
|
cmd.publish();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -21,4 +21,4 @@ public class LoggingServerCommand extends ServerCommand
|
|||||||
_command = command;
|
_command = command;
|
||||||
_args = args;
|
_args = args;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,23 +9,18 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.core.common.util.UtilPlayerBase;
|
||||||
|
|
||||||
public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends CommandBase<PluginType>
|
public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends CommandBase<PluginType>
|
||||||
{
|
{
|
||||||
private NautHashMap<String, ICommand> Commands;
|
private NautHashMap<String, ICommand> Commands;
|
||||||
|
|
||||||
public MultiCommandBase(PluginType plugin, Rank rank, String... aliases)
|
public MultiCommandBase(PluginType plugin, Permission permission, String... aliases)
|
||||||
{
|
{
|
||||||
super(plugin, rank, aliases);
|
super(plugin, permission, aliases);
|
||||||
|
|
||||||
Commands = new NautHashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MultiCommandBase(PluginType plugin, Rank rank, Rank[] specificRanks, String... aliases)
|
|
||||||
{
|
|
||||||
super(plugin, rank, specificRanks, aliases);
|
|
||||||
|
|
||||||
Commands = new NautHashMap<>();
|
Commands = new NautHashMap<>();
|
||||||
}
|
}
|
||||||
@ -72,11 +67,17 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
|
|||||||
|
|
||||||
ICommand command = Commands.get(commandName);
|
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.Get(caller).hasPermission(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 to do that.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -105,7 +106,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
|
|||||||
Stream<ICommand> stream = Commands.values().stream();
|
Stream<ICommand> stream = Commands.values().stream();
|
||||||
if (sender instanceof Player)
|
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().Get((Player) sender).hasPermission(command.getPermission()));
|
||||||
}
|
}
|
||||||
return getMatches(args[0], stream.map(ICommand::Aliases).flatMap(Collection::stream));
|
return getMatches(args[0], stream.map(ICommand::Aliases).flatMap(Collection::stream));
|
||||||
}
|
}
|
||||||
@ -114,4 +115,4 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void Help(Player caller, String[] args);
|
protected abstract void Help(Player caller, String[] args);
|
||||||
}
|
}
|
@ -25,6 +25,8 @@ import mineplex.core.Managers;
|
|||||||
import mineplex.core.MiniDbClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.ILoginProcessor;
|
import mineplex.core.account.ILoginProcessor;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.common.jsonchat.ClickEvent;
|
import mineplex.core.common.jsonchat.ClickEvent;
|
||||||
import mineplex.core.common.jsonchat.JsonMessage;
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -71,6 +73,27 @@ import mineplex.serverdata.servers.ServerRepository;
|
|||||||
|
|
||||||
public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||||
{
|
{
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
OWN_COMMUNITY,
|
||||||
|
COMMUNITY_CHAT_COMMAND,
|
||||||
|
COMMUNITY_COMMAND,
|
||||||
|
COMMUNITY_DESCRIPTION_COMMAND,
|
||||||
|
COMMUNITY_DESCRIPTION_STAFF_COMMAND,
|
||||||
|
COMMUNITY_DISBAND_COMMAND,
|
||||||
|
COMMUNITY_DISBAND_STAFF_COMMAND,
|
||||||
|
COMMUNITY_INVITE_COMMAND,
|
||||||
|
COMMUNITY_INVITE_STAFF_COMMAND,
|
||||||
|
COMMUNITY_JOIN_COMMAND,
|
||||||
|
COMMUNITY_MCS_COMMAND,
|
||||||
|
COMMUNITY_MCS_STAFF_COMMAND,
|
||||||
|
COMMUNITY_MENU_COMMAND,
|
||||||
|
COMMUNITY_RENAME_COMMAND,
|
||||||
|
COMMUNITY_RENAME_STAFF_COMMAND,
|
||||||
|
COMMUNITY_UNINVITE_COMMAND,
|
||||||
|
COMMUNITY_UNINVITE_STAFF_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private final int UPDATE_CYCLE_SECONDS = 10; // The number of seconds between dirty communities refreshes
|
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
|
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]");
|
public final Pattern ALPHA_NUMERIC_PATTERN = Pattern.compile("[^A-Za-z0-9]");
|
||||||
@ -183,6 +206,30 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
|||||||
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateMembership.class, new CommunityUpdateMembershipHandler(this));
|
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateMembership.class, new CommunityUpdateMembershipHandler(this));
|
||||||
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateName.class, new CommunityUpdateNameHandler(this));
|
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateName.class, new CommunityUpdateNameHandler(this));
|
||||||
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateSetting.class, new CommunityUpdateSettingHandler(this));
|
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateSetting.class, new CommunityUpdateSettingHandler(this));
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
|
||||||
|
PermissionGroup.ETERNAL.setPermission(Perm.OWN_COMMUNITY, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_CHAT_COMMAND, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_COMMAND, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_DESCRIPTION_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_DESCRIPTION_STAFF_COMMAND, true, true);
|
||||||
|
PermissionGroup.ETERNAL.setPermission(Perm.COMMUNITY_DISBAND_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_DISBAND_STAFF_COMMAND, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_INVITE_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_INVITE_STAFF_COMMAND, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_JOIN_COMMAND, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_MCS_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_MCS_STAFF_COMMAND, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_MENU_COMMAND, true, true);
|
||||||
|
PermissionGroup.ETERNAL.setPermission(Perm.COMMUNITY_RENAME_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_RENAME_STAFF_COMMAND, true, true);
|
||||||
|
PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_UNINVITE_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_UNINVITE_STAFF_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ownsCommunity(UUID uuid)
|
public boolean ownsCommunity(UUID uuid)
|
||||||
|
@ -4,7 +4,6 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -14,7 +13,7 @@ public class CommunityChatCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityChatCommand(CommunityManager plugin)
|
public CommunityChatCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "chat");
|
super(plugin, CommunityManager.Perm.COMMUNITY_CHAT_COMMAND, "chat");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -22,7 +21,7 @@ public class CommunityChatCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||||
|
@ -4,7 +4,6 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.MultiCommandBase;
|
import mineplex.core.command.MultiCommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -16,7 +15,7 @@ public class CommunityCommand extends MultiCommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityCommand(CommunityManager plugin)
|
public CommunityCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "community", "communities", "com");
|
super(plugin, CommunityManager.Perm.COMMUNITY_COMMAND, "community", "communities", "com");
|
||||||
|
|
||||||
AddCommand(new CommunityChatCommand(plugin));
|
AddCommand(new CommunityChatCommand(plugin));
|
||||||
AddCommand(new CommunityCreateCommand(plugin));
|
AddCommand(new CommunityCreateCommand(plugin));
|
||||||
@ -38,17 +37,16 @@ public class CommunityCommand extends MultiCommandBase<CommunityManager>
|
|||||||
if (args[0].equalsIgnoreCase("help"))
|
if (args[0].equalsIgnoreCase("help"))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Community Commands:"));
|
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 <community>", "Opens a community's menu", 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", ChatColor.DARK_AQUA));
|
||||||
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", 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", 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", 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", 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", 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", 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", 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", ChatColor.DARK_AQUA));
|
||||||
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", Rank.ETERNAL, ChatColor.DARK_AQUA));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Community community = Plugin.getLoadedCommunity(args[0]);
|
Community community = Plugin.getLoadedCommunity(args[0]);
|
||||||
|
@ -9,7 +9,6 @@ import mineplex.core.Managers;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -19,7 +18,7 @@ public class CommunityCreateCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityCreateCommand(CommunityManager plugin)
|
public CommunityCreateCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ETERNAL, "create");
|
super(plugin, CommunityManager.Perm.OWN_COMMUNITY, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,7 +26,7 @@ public class CommunityCreateCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||||
|
@ -7,7 +7,6 @@ import mineplex.core.Managers;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -20,7 +19,7 @@ public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityDescriptionCommand(CommunityManager plugin)
|
public CommunityDescriptionCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "description");
|
super(plugin, CommunityManager.Perm.COMMUNITY_DESCRIPTION_COMMAND, "description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,7 +27,7 @@ public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 2)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||||
@ -44,7 +43,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 (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).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_DESCRIPTION_STAFF_COMMAND))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||||
return;
|
return;
|
||||||
|
@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
|||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -18,7 +17,7 @@ public class CommunityDisbandCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityDisbandCommand(CommunityManager plugin)
|
public CommunityDisbandCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ETERNAL, "disband");
|
super(plugin, CommunityManager.Perm.COMMUNITY_DISBAND_COMMAND, "disband");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -26,7 +25,7 @@ public class CommunityDisbandCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||||
@ -37,7 +36,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 (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).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_DISBAND_STAFF_COMMAND))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!"));
|
||||||
return;
|
return;
|
||||||
|
@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
|||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -18,7 +17,7 @@ public class CommunityInviteCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityInviteCommand(CommunityManager plugin)
|
public CommunityInviteCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "invite");
|
super(plugin, CommunityManager.Perm.COMMUNITY_INVITE_COMMAND, "invite");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -26,7 +25,7 @@ public class CommunityInviteCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 2)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
String player = args[0];
|
String player = args[0];
|
||||||
@ -38,7 +37,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 (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).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_INVITE_STAFF_COMMAND))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||||
return;
|
return;
|
||||||
|
@ -4,7 +4,6 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -15,7 +14,7 @@ public class CommunityJoinCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityJoinCommand(CommunityManager plugin)
|
public CommunityJoinCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "join");
|
super(plugin, CommunityManager.Perm.COMMUNITY_JOIN_COMMAND, "join");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -23,7 +22,7 @@ public class CommunityJoinCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||||
|
@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
|||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -19,7 +18,7 @@ public class CommunityMCSCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityMCSCommand(CommunityManager plugin)
|
public CommunityMCSCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "mcs");
|
super(plugin, CommunityManager.Perm.COMMUNITY_MCS_COMMAND, "mcs");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,7 +26,7 @@ public class CommunityMCSCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||||
@ -38,7 +37,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 (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).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_MCS_STAFF_COMMAND))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||||
return;
|
return;
|
||||||
|
@ -3,7 +3,6 @@ package mineplex.core.communities.commands;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.communities.CommunityManager;
|
import mineplex.core.communities.CommunityManager;
|
||||||
import mineplex.core.communities.gui.overview.CommunityOverviewPage;
|
import mineplex.core.communities.gui.overview.CommunityOverviewPage;
|
||||||
|
|
||||||
@ -11,7 +10,7 @@ public class CommunityMenuCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityMenuCommand(CommunityManager plugin)
|
public CommunityMenuCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "menu");
|
super(plugin, CommunityManager.Perm.COMMUNITY_MENU_COMMAND, "menu");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,7 +9,6 @@ import mineplex.core.Managers;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -21,7 +20,7 @@ public class CommunityRenameCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityRenameCommand(CommunityManager plugin)
|
public CommunityRenameCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ETERNAL, "rename");
|
super(plugin, CommunityManager.Perm.COMMUNITY_RENAME_COMMAND, "rename");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,7 +28,7 @@ public class CommunityRenameCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 2)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||||
@ -41,7 +40,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 (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).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_RENAME_STAFF_COMMAND))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!"));
|
||||||
return;
|
return;
|
||||||
|
@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
|||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
@ -18,7 +17,7 @@ public class CommunityUnInviteCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
public CommunityUnInviteCommand(CommunityManager plugin)
|
public CommunityUnInviteCommand(CommunityManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ALL, "uninvite");
|
super(plugin, CommunityManager.Perm.COMMUNITY_UNINVITE_COMMAND, "uninvite");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -26,7 +25,7 @@ public class CommunityUnInviteCommand extends CommandBase<CommunityManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 2)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
String player = args[0];
|
String player = args[0];
|
||||||
@ -38,7 +37,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 (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).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_UNINVITE_STAFF_COMMAND))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||||
return;
|
return;
|
||||||
|
@ -5,10 +5,10 @@ import org.bukkit.event.inventory.ClickType;
|
|||||||
|
|
||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.communities.Community;
|
import mineplex.core.communities.Community;
|
||||||
|
import mineplex.core.communities.CommunityManager;
|
||||||
import mineplex.core.communities.CommunityMemberInfo;
|
import mineplex.core.communities.CommunityMemberInfo;
|
||||||
import mineplex.core.communities.CommunityRole;
|
import mineplex.core.communities.CommunityRole;
|
||||||
import mineplex.core.communities.gui.CommunitiesGUIButton;
|
import mineplex.core.communities.gui.CommunitiesGUIButton;
|
||||||
@ -18,6 +18,7 @@ public class CommunityMemberButton extends CommunitiesGUIButton
|
|||||||
private Player _viewer;
|
private Player _viewer;
|
||||||
private Community _community;
|
private Community _community;
|
||||||
private CommunityMemberInfo _info;
|
private CommunityMemberInfo _info;
|
||||||
|
private boolean _fetching = false;
|
||||||
|
|
||||||
public CommunityMemberButton(Player viewer, Community community, CommunityMemberInfo info)
|
public CommunityMemberButton(Player viewer, Community community, CommunityMemberInfo info)
|
||||||
{
|
{
|
||||||
@ -37,6 +38,10 @@ public class CommunityMemberButton extends CommunitiesGUIButton
|
|||||||
@Override
|
@Override
|
||||||
public void handleClick(ClickType type)
|
public void handleClick(ClickType type)
|
||||||
{
|
{
|
||||||
|
if (_fetching)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (type == ClickType.SHIFT_RIGHT)
|
if (type == ClickType.SHIFT_RIGHT)
|
||||||
{
|
{
|
||||||
if (getCommunityManager().Get(_viewer).getRoleIn(_community) != null && getCommunityManager().Get(_viewer).getRoleIn(_community).ordinal() < _info.Role.ordinal())
|
if (getCommunityManager().Get(_viewer).getRoleIn(_community) != null && getCommunityManager().Get(_viewer).getRoleIn(_community).ordinal() < _info.Role.ordinal())
|
||||||
@ -59,13 +64,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!"));
|
UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), F.name(_info.Name) + " can only own one community at a time!"));
|
||||||
return;
|
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, (primaryGroup, additionalGroups) ->
|
||||||
|
{
|
||||||
|
if (primaryGroup.hasPermission(CommunityManager.Perm.OWN_COMMUNITY))
|
||||||
|
{
|
||||||
|
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!"));
|
UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), "Only Eternal rank and above can own a community!"));
|
||||||
return;
|
_fetching = false;
|
||||||
}
|
});
|
||||||
getCommunityManager().handleRoleUpdate(_viewer, _community, _info, CommunityRole.LEADER);
|
|
||||||
getCommunityManager().handleRoleUpdate(_viewer, _community, _community.getMembers().get(_viewer.getUniqueId()), CommunityRole.COLEADER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,22 +4,14 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
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.Location;
|
||||||
import org.bukkit.Material;
|
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.entity.Skeleton.SkeletonType;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -31,14 +23,43 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.account.permissions.Permission;
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
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 class Creature extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
public enum Perm implements Permission
|
||||||
|
{
|
||||||
|
MOB_COMMAND,
|
||||||
|
KILL_MOB_COMMAND,
|
||||||
|
}
|
||||||
|
|
||||||
private boolean _spawnForce = false;
|
private boolean _spawnForce = false;
|
||||||
private boolean _disableCustom = false;
|
private boolean _disableCustom = false;
|
||||||
|
|
||||||
public Creature(JavaPlugin plugin)
|
public Creature(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
super("Creature", plugin);
|
super("Creature", plugin);
|
||||||
|
|
||||||
|
generatePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePermissions()
|
||||||
|
{
|
||||||
|
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.MOB_COMMAND, true, true);
|
||||||
|
PermissionGroup.ADMIN.setPermission(Perm.KILL_MOB_COMMAND, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -315,4 +336,4 @@ public class Creature extends MiniPlugin
|
|||||||
{
|
{
|
||||||
_disableCustom = var;
|
_disableCustom = var;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -21,7 +20,7 @@ public class KillCommand extends CommandBase<Creature>
|
|||||||
{
|
{
|
||||||
public KillCommand(Creature plugin)
|
public KillCommand(Creature plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "kill", "k");
|
super(plugin, Creature.Perm.KILL_MOB_COMMAND, "kill", "k");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,4 +69,4 @@ public class KillCommand extends CommandBase<Creature>
|
|||||||
|
|
||||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Killed " + target + ". " + count + " Removed."));
|
UtilPlayer.message(caller, F.main(Plugin.getName(), "Killed " + target + ". " + count + " Removed."));
|
||||||
}
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user