Hub merges

This commit is contained in:
Sam 2017-09-01 16:27:29 +01:00
parent 07cc9c3646
commit 39792675dc
3 changed files with 206 additions and 97 deletions

View File

@ -9,10 +9,10 @@ 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.leveling.LevelingManager;
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.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager; import mineplex.core.elo.EloManager;
@ -23,6 +23,16 @@ import mineplex.core.stats.event.StatChangeEvent;
public class AchievementManager extends MiniPlugin public class AchievementManager extends MiniPlugin
{ {
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;
private StatsManager _statsManager; private StatsManager _statsManager;
@ -32,7 +42,7 @@ public class AchievementManager extends MiniPlugin
private int _interfaceSlot = 7; private int _interfaceSlot = 7;
private boolean _giveInterfaceItem = false; private boolean _giveInterfaceItem = false;
private NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<>(); private NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<String, NautHashMap<Achievement, AchievementLog>>();
private boolean _shopEnabled = true; private boolean _shopEnabled = true;
@ -45,8 +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");
new LevelingManager(this); 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)
@ -197,27 +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 (rank.has(Rank.MODERATOR)) if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_50))
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()
@ -239,4 +262,4 @@ public class AchievementManager extends MiniPlugin
{ {
return _statsManager; return _statsManager;
} }
} }

View File

@ -2,20 +2,40 @@ package mineplex.core.npc;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.UUID;
import com.mojang.authlib.GameProfile; import net.minecraft.server.v1_8_R3.EntityInsentient;
import mineplex.core.aprilfools.AprilFoolsManager;
import mineplex.core.common.skin.SkinData; import org.bukkit.Bukkit;
import mineplex.core.disguise.DisguiseManager; import org.bukkit.ChatColor;
import mineplex.core.disguise.disguises.DisguisePlayer; import org.bukkit.DyeColor;
import mineplex.core.utils.UtilGameProfile; import org.bukkit.Location;
import org.bukkit.*; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.*; import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
@ -28,16 +48,18 @@ import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.inventory.ItemStack; 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 net.minecraft.server.v1_8_R3.EntityInsentient; import org.jooq.Result;
import org.jooq.impl.DSL;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank; import mineplex.core.account.permissions.Permission;
import mineplex.core.account.permissions.PermissionGroup;
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;
import mineplex.core.creature.Creature; import mineplex.core.creature.Creature;
import mineplex.core.creature.event.CreatureKillEntitiesEvent; import mineplex.core.creature.event.CreatureKillEntitiesEvent;
import mineplex.serverdata.database.DBPool; import mineplex.core.disguise.DisguiseManager;
import mineplex.core.npc.command.NpcCommand; import mineplex.core.npc.command.NpcCommand;
import mineplex.core.npc.event.NpcDamageByEntityEvent; import mineplex.core.npc.event.NpcDamageByEntityEvent;
import mineplex.core.npc.event.NpcInteractEntityEvent; import mineplex.core.npc.event.NpcInteractEntityEvent;
@ -46,8 +68,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.database.Tables; import mineplex.database.Tables;
import mineplex.database.tables.records.NpcsRecord; import mineplex.database.tables.records.NpcsRecord;
import org.jooq.Result; import mineplex.serverdata.database.DBPool;
import org.jooq.impl.DSL;
public class NpcManager extends MiniPlugin public class NpcManager extends MiniPlugin
{ {
@ -84,14 +105,22 @@ public class NpcManager extends MiniPlugin
} }
} }
public enum Perm implements Permission
{
ADD_NPC_COMMAND,
CLEAR_NPCS_COMMAND,
DELETE_NPC_COMMAND,
NPC_HOME_COMMAND,
NPC_COMMAND,
REFRESH_NPCS_COMMAND,
}
private final Creature _creature; private final Creature _creature;
private final List<Npc> _npcs = new ArrayList<>(); private final List<Npc> _npcs = new ArrayList<>();
private final Queue<NpcsRecord> _queuedNpcs = new LinkedList<>(); private final Queue<NpcsRecord> _queuedNpcs = new LinkedList<>();
final Map<UUID, Npc> _npcMap = new HashMap<>(); final Map<UUID, Npc> _npcMap = new HashMap<>();
private final Set<UUID> _npcDeletingPlayers = new HashSet<>(); private final Set<UUID> _npcDeletingPlayers = new HashSet<>();
private final DisguiseManager _disguise;
public NpcManager(JavaPlugin plugin, Creature creature) public NpcManager(JavaPlugin plugin, Creature creature)
{ {
super("NpcManager", plugin); super("NpcManager", plugin);
@ -108,7 +137,7 @@ public class NpcManager extends MiniPlugin
_plugin.getServer().getPluginManager().registerEvents(this, _plugin); _plugin.getServer().getPluginManager().registerEvents(this, _plugin);
_disguise = require(DisguiseManager.class); require(DisguiseManager.class);
// try // try
// { // {
@ -118,6 +147,18 @@ public class NpcManager extends MiniPlugin
// { // {
// e.printStackTrace(); // e.printStackTrace();
// } // }
generatePermissions();
}
private void generatePermissions()
{
PermissionGroup.ADMIN.setPermission(Perm.ADD_NPC_COMMAND, true, true);
PermissionGroup.DEV.setPermission(Perm.CLEAR_NPCS_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.DELETE_NPC_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.NPC_HOME_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.NPC_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.REFRESH_NPCS_COMMAND, true, true);
} }
@Override @Override
@ -129,14 +170,16 @@ public class NpcManager extends MiniPlugin
public void help(Player caller, String message) public void help(Player caller, String message)
{ {
UtilPlayer.message(caller, F.main(_moduleName, "Commands List:")); UtilPlayer.message(caller, F.main(_moduleName, "Commands List:"));
UtilPlayer.message(caller, F.help("/npc add <type> [radius] [adult] [name]", "Create a new NPC.", Rank.DEVELOPER)); UtilPlayer.message(caller, F.help("/npc add <type> [radius] [adult] [name]", "Create a new NPC.", ChatColor.DARK_RED));
UtilPlayer.message(caller, F.help("/npc del ", "Right click NPC to delete.", Rank.DEVELOPER)); UtilPlayer.message(caller, F.help("/npc del ", "Right click NPC to delete.", ChatColor.DARK_RED));
UtilPlayer.message(caller, F.help("/npc home", "Teleport NPCs to home locations.", Rank.DEVELOPER)); UtilPlayer.message(caller, F.help("/npc home", "Teleport NPCs to home locations.", ChatColor.DARK_RED));
UtilPlayer.message(caller, F.help("/npc clear", "Deletes all NPCs.", Rank.DEVELOPER)); UtilPlayer.message(caller, F.help("/npc clear", "Deletes all NPCs.", ChatColor.DARK_RED));
UtilPlayer.message(caller, F.help("/npc refresh", "Refresh NPCs from database.", Rank.DEVELOPER)); UtilPlayer.message(caller, F.help("/npc refresh", "Refresh NPCs from database.", ChatColor.DARK_RED));
if (message != null) if (message != null)
{
UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message)); UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message));
}
} }
public void help(Player caller) public void help(Player caller)

View File

@ -2,6 +2,8 @@ package mineplex.hub;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
@ -46,6 +48,8 @@ import mineplex.core.Managers;
import mineplex.core.MiniClientPlugin; import mineplex.core.MiniClientPlugin;
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.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
import mineplex.core.achievement.profile.ProfileManager; import mineplex.core.achievement.profile.ProfileManager;
import mineplex.core.antispam.AntiSpamManager; import mineplex.core.antispam.AntiSpamManager;
@ -56,7 +60,6 @@ import mineplex.core.boosters.BoosterManager;
import mineplex.core.botspam.BotSpamManager; import mineplex.core.botspam.BotSpamManager;
import mineplex.core.chat.ChatFormat; import mineplex.core.chat.ChatFormat;
import mineplex.core.chat.IChatMessageFormatter; import mineplex.core.chat.IChatMessageFormatter;
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.F; import mineplex.core.common.util.F;
@ -146,6 +149,17 @@ import mineplex.minecraft.game.core.condition.ConditionManager;
public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter
{ {
public enum Perm implements Permission
{
GADGET_TOGGLE_COMMAND,
GAMEMODE_COMMAND,
AUTO_OP,
VANISH,
SPAWN_PM,
NEWS_COMMAND,
JOIN_FULL,
}
// Snowman! // Snowman!
public HubType Type = HubType.Normal; public HubType Type = HubType.Normal;
@ -190,9 +204,9 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
private final String _serverName; private final String _serverName;
private boolean _shuttingDown; private boolean _shuttingDown;
private HashMap<String, Long> _portalTime = new HashMap<String, Long>(); private Map<String, Long> _portalTime = new HashMap<>();
private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>(); private Map<String, List<String>> _creativeAdmin = new HashMap<>();
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager, CastleManager castleManager) public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager, CastleManager castleManager)
{ {
@ -263,7 +277,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
_achievementManager.setGiveInterfaceItem(true); _achievementManager.setGiveInterfaceItem(true);
_packetHandler = packetHandler; _packetHandler = packetHandler;
new NotificationManager(getPlugin(), clientManager, _preferences); new NotificationManager(getPlugin(), clientManager);
new BotSpamManager(plugin, clientManager, punish); new BotSpamManager(plugin, clientManager, punish);
((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
@ -302,12 +316,20 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
@Override @Override
public void setup(MineplexScoreboard scoreboard) public void setup(MineplexScoreboard scoreboard)
{ {
for (Rank rank : Rank.values()) for (PermissionGroup group : PermissionGroup.values())
{ {
if (rank == Rank.ALL) if (!group.canBePrimary())
scoreboard.getHandle().registerNewTeam(rank.ScoreboardTag).setPrefix(""); {
continue;
}
if (!group.getDisplay(false, false, false, false).isEmpty())
{
scoreboard.getHandle().registerNewTeam(group.name()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " ");
}
else else
scoreboard.getHandle().registerNewTeam(rank.ScoreboardTag).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); {
scoreboard.getHandle().registerNewTeam(group.name()).setPrefix("");
}
} }
scoreboard.register(HubScoreboardLine.SERVER_TITLE) scoreboard.register(HubScoreboardLine.SERVER_TITLE)
@ -344,9 +366,9 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
scoreboard.get(HubScoreboardLine.GEM_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); scoreboard.get(HubScoreboardLine.GEM_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM));
scoreboard.get(HubScoreboardLine.SHARDS_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.TREASURE_SHARD)); scoreboard.get(HubScoreboardLine.SHARDS_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.TREASURE_SHARD));
String rankName = getRankName(GetClients().Get(scoreboard.getOwner()).GetRank(), GetDonation().Get(scoreboard.getOwner())); String rankName = getRankName(GetClients().Get(scoreboard.getOwner()).getPrimaryGroup(), GetDonation().Get(scoreboard.getOwner()));
Rank disguisedRank = GetClients().Get(scoreboard.getOwner()).getDisguisedRank(); PermissionGroup disguisedRank = GetClients().Get(scoreboard.getOwner()).getDisguisedPrimaryGroup();
String disguisedAs = GetClients().Get(scoreboard.getOwner()).getDisguisedAs(); String disguisedAs = GetClients().Get(scoreboard.getOwner()).getDisguisedAs();
if (disguisedRank != null && disguisedAs != null) if (disguisedRank != null && disguisedAs != null)
{ {
@ -364,19 +386,19 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
HubClient hubclient = HubManager.this.Get(player); HubClient hubclient = HubManager.this.Get(player);
hubclient.setName(playerName); hubclient.setName(playerName);
CoreClient client = GetClients().Get(player.getUniqueId()); PermissionGroup group = _clientManager.Get(player).getRealOrDisguisedPrimaryGroup();
for (MineplexScoreboard scoreboard : getScoreboards().values()) for (MineplexScoreboard scoreboard : getScoreboards().values())
{ {
scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().ScoreboardTag).addEntry(playerName); scoreboard.getHandle().getTeam(group.name()).addEntry(playerName);
} }
if (get(player) != null) if (get(player) != null)
{ {
for (Player player1 : Bukkit.getOnlinePlayers()) for (Player player1 : Bukkit.getOnlinePlayers())
{ {
client = GetClients().Get(player1); group = _clientManager.Get(player1).getRealOrDisguisedPrimaryGroup();
get(player).getHandle().getTeam(client.getRealOrDisguisedRank().ScoreboardTag).addEntry(player1.getName()); get(player).getHandle().getTeam(group.name()).addEntry(player1.getName());
} }
} }
} }
@ -386,28 +408,34 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
{ {
Player player = Bukkit.getPlayerExact(playerName); Player player = Bukkit.getPlayerExact(playerName);
CoreClient client = GetClients().Get(player); PermissionGroup group = _clientManager.Get(player).getRealOrDisguisedPrimaryGroup();
for (MineplexScoreboard scoreboard : getScoreboards().values()) for (MineplexScoreboard scoreboard : getScoreboards().values())
{ {
scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().ScoreboardTag).removeEntry(playerName); scoreboard.getHandle().getTeam(group.name()).removeEntry(playerName);
} }
} }
private String getRankName(Rank rank, Donor donor) private String getRankName(PermissionGroup group, Donor donor)
{ {
String rankName; String display = group.getDisplay(false, false, false, false);
if (rank.has(Rank.ULTRA)) if (display.isEmpty())
rankName = rank.Name; {
else if (donor.ownsUnknownSalesPackage("SuperSmashMobs ULTRA") || if (donor.ownsUnknownSalesPackage("SuperSmashMobs ULTRA") ||
donor.ownsUnknownSalesPackage("Survival Games ULTRA") || donor.ownsUnknownSalesPackage("Survival Games ULTRA") ||
donor.ownsUnknownSalesPackage("Minigames ULTRA") || donor.ownsUnknownSalesPackage("Minigames ULTRA") ||
donor.ownsUnknownSalesPackage("CastleSiege ULTRA") || donor.ownsUnknownSalesPackage("CastleSiege ULTRA") ||
donor.ownsUnknownSalesPackage("Champions ULTRA")) donor.ownsUnknownSalesPackage("Champions ULTRA"))
rankName = "Single Ultra"; {
else display = "Single Ultra";
rankName = "No Rank"; }
return rankName; else
{
display = "No Rank";
}
}
return display;
} }
}; };
@ -415,6 +443,27 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
require(NewNPCManager.class); require(NewNPCManager.class);
require(ProfileManager.class); require(ProfileManager.class);
generatePermissions();
}
private void generatePermissions()
{
PermissionGroup.ADMIN.setPermission(Perm.GADGET_TOGGLE_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.GAMEMODE_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.NEWS_COMMAND, true, true);
if (UtilServer.isDevServer() || UtilServer.isTestServer())
{
PermissionGroup.ADMIN.setPermission(Perm.AUTO_OP, true, true);
PermissionGroup.QAM.setPermission(Perm.AUTO_OP, false, true);
}
else
{
PermissionGroup.LT.setPermission(Perm.AUTO_OP, true, true);
}
PermissionGroup.ADMIN.setPermission(Perm.VANISH, true, true);
PermissionGroup.TRAINEE.setPermission(Perm.SPAWN_PM, true, true);
PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, true, true);
} }
@Override @Override
@ -500,21 +549,20 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
// Reserved Slot Check // Reserved Slot Check
if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20)
{ {
if (!client.GetRank().has(Rank.ULTRA)) if (!client.hasPermission(Perm.JOIN_FULL))
{ {
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () ->
{ {
public void run() _portal.sendPlayerToGenericServer(event.getPlayer(), GenericServer.HUB, Intent.KICK);
{
_portal.sendPlayerToGenericServer(event.getPlayer(), GenericServer.HUB, Intent.KICK);
}
}); });
event.allow(); event.allow();
} }
} }
else else
{
event.allow(); event.allow();
}
} }
private boolean _made; private boolean _made;
@ -522,14 +570,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void AdminOP(PlayerJoinEvent event) public void AdminOP(PlayerJoinEvent event)
{ {
// Give developers operator on their servers if (_clientManager.Get(event.getPlayer()).hasPermission(Perm.AUTO_OP))
Rank minimum = Rank.OWNER;
if (UtilServer.isTestServer() || UtilServer.isDevServer())
{
minimum = Rank.JNR_DEV;
}
if (_clientManager.Get(event.getPlayer()).GetRank().has(minimum))
event.getPlayer().setOp(true); event.getPlayer().setOp(true);
else else
event.getPlayer().setOp(false); event.getPlayer().setOp(false);
@ -603,7 +644,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
public void playerPrivateMessage(PrivateMessageEvent event) public void playerPrivateMessage(PrivateMessageEvent event)
{ {
//Dont Let PM Near Spawn! //Dont Let PM Near Spawn!
if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).GetRank().has(Rank.HELPER)) if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !!_clientManager.Get(event.getSender()).hasPermission(Perm.SPAWN_PM))
{ {
UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!"));
event.setCancelled(true); event.setCancelled(true);
@ -613,7 +654,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
@EventHandler @EventHandler
public void Incog(IncognitoHidePlayerEvent event) public void Incog(IncognitoHidePlayerEvent event)
{ {
if (!_clientManager.hasRank(event.getPlayer(), Rank.ADMIN)) if (!_clientManager.Get(event.getPlayer()).hasPermission(Perm.VANISH))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -626,7 +667,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
return; return;
//Dont Let Chat Near Spawn! //Dont Let Chat Near Spawn!
if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER)) if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).hasPermission(Perm.SPAWN_PM))
{ {
UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!")); UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!"));
event.setCancelled(true); event.setCancelled(true);
@ -635,15 +676,17 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
Player player = event.getPlayer(); Player player = event.getPlayer();
String playerName = player.getName(); String playerName = player.getName();
Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); PermissionGroup group = GetClients().Get(player).getRealOrDisguisedPrimaryGroup();
//Level Prefix //Level Prefix
String levelStr = _achievementManager.getMineplexLevel(player, rank); String levelStr = _achievementManager.getMineplexLevel(player);
//Rank Prefix //Rank Prefix
String rankStr = ""; String rankStr = "";
if (rank != Rank.ALL) if (!group.getDisplay(false, false, false, false).isEmpty())
rankStr = rank.getTag(true, true) + " "; {
rankStr = group.getDisplay(true, true, true, false) + " ";
}
//Party Chat //Party Chat
if (event.getMessage().charAt(0) == '@') if (event.getMessage().charAt(0) == '@')
{ {
@ -676,7 +719,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName); TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName);
TextComponent component = new TextComponent(); TextComponent component = new TextComponent();
rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(group.getDisplay(true, true, true, true) + ChatColor.WHITE + "\n" + group.getDescription()).create()));
component.setText(levelStr); component.setText(levelStr);
component.addExtra(rankComponent); component.addExtra(rankComponent);
@ -697,21 +740,23 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
@Override @Override
public ChatFormat getChatFormat(Player player, String message) public ChatFormat getChatFormat(Player player, String message)
{ {
Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); PermissionGroup group = GetClients().Get(player).getRealOrDisguisedPrimaryGroup();
//Level Prefix //Level Prefix
String levelStr = _achievementManager.getMineplexLevel(player, rank); String levelStr = _achievementManager.getMineplexLevel(player);
//Rank Prefix //Rank Prefix
String rankStr = ""; String rankStr = "";
if (rank != Rank.ALL) if (!group.getDisplay(false, false, false, false).isEmpty())
rankStr = rank.getTag(true, true) + " "; {
rankStr = group.getDisplay(true, true, true, false) + " ";
}
TextComponent rankComponent = new TextComponent(rankStr); TextComponent rankComponent = new TextComponent(rankStr);
TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + "%1$s"); TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + "%1$s");
TextComponent component = new TextComponent(); TextComponent component = new TextComponent();
rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(group.getDisplay(true, true, true, true) + ChatColor.WHITE + "\n" + group.getDescription()).create()));
component.setText(levelStr); component.setText(levelStr);
component.addExtra(rankComponent); component.addExtra(rankComponent);
@ -923,9 +968,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
@EventHandler @EventHandler
public void ignoreVelocity(PlayerVelocityEvent event) public void ignoreVelocity(PlayerVelocityEvent event)
{ {
Player player = event.getPlayer(); if (_clientManager.Get(event.getPlayer()).hasPermission(Preference.IGNORE_VELOCITY) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY) && !getJumpManager().isDoubleJumping(event.getPlayer()))
if (_clientManager.Get(player).GetRank().has(Rank.TWITCH) && _preferences.get(player).isActive(Preference.IGNORE_VELOCITY) && !getJumpManager().isDoubleJumping(player))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -983,7 +1026,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
@EventHandler @EventHandler
public void clearGameMode(PlayerQuitEvent event) public void clearGameMode(PlayerQuitEvent event)
{ {
ArrayList<String> creative = _creativeAdmin.remove(event.getPlayer().getName()); List<String> creative = _creativeAdmin.remove(event.getPlayer().getName());
if (creative == null) if (creative == null)
return; return;
@ -1046,4 +1089,4 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
{ {
return _questManager; return _questManager;
} }
} }