907 lines
24 KiB
Java
907 lines
24 KiB
Java
package mineplex.hub;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.GameMode;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
|
|
import org.bukkit.entity.Egg;
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.EventPriority;
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
|
import org.bukkit.event.player.PlayerLoginEvent;
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
|
import org.bukkit.event.server.ServerListPingEvent;
|
|
import org.bukkit.event.world.ChunkLoadEvent;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.bukkit.inventory.meta.BookMeta;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
import org.bukkit.scoreboard.DisplaySlot;
|
|
import org.bukkit.scoreboard.Objective;
|
|
import org.bukkit.scoreboard.Scoreboard;
|
|
|
|
import mineplex.core.MiniClientPlugin;
|
|
import mineplex.core.account.CoreClient;
|
|
import mineplex.core.account.CoreClientManager;
|
|
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
|
import mineplex.core.blockrestore.BlockRestore;
|
|
import mineplex.core.common.Rank;
|
|
import mineplex.core.common.util.C;
|
|
import mineplex.core.common.util.F;
|
|
import mineplex.core.common.util.UtilInv;
|
|
import mineplex.core.common.util.UtilParticle;
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
import mineplex.core.common.util.UtilServer;
|
|
import mineplex.core.common.util.UtilTime;
|
|
import mineplex.core.common.util.UtilWorld;
|
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
|
import mineplex.core.disguise.DisguiseManager;
|
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
|
import mineplex.core.disguise.disguises.DisguiseSlime;
|
|
import mineplex.core.donation.DonationManager;
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
|
import mineplex.core.logger.Logger;
|
|
import mineplex.core.portal.Portal;
|
|
import mineplex.core.preferences.PreferencesManager;
|
|
import mineplex.core.stats.StatsManager;
|
|
import mineplex.core.task.TaskManager;
|
|
import mineplex.core.updater.UpdateType;
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
import mineplex.hub.commands.ForcefieldRadius;
|
|
import mineplex.hub.commands.GadgetToggle;
|
|
import mineplex.hub.commands.NewsCommand;
|
|
import mineplex.hub.gadget.GadgetManager;
|
|
import mineplex.hub.modules.*;
|
|
import mineplex.hub.mount.MountManager;
|
|
import mineplex.hub.party.Party;
|
|
import mineplex.hub.party.PartyManager;
|
|
import mineplex.hub.pet.PetManager;
|
|
import mineplex.hub.tutorial.TutorialManager;
|
|
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
|
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
|
|
import mineplex.minecraft.game.core.condition.ConditionManager;
|
|
|
|
public class HubManager extends MiniClientPlugin<HubClient>
|
|
{
|
|
public String Mode = "Normal";
|
|
|
|
private BlockRestore _blockRestore;
|
|
private CoreClientManager _clientManager;
|
|
private ConditionManager _conditionManager;
|
|
private DonationManager _donationManager;
|
|
private DisguiseManager _disguiseManager;
|
|
private PartyManager _partyManager;
|
|
private ForcefieldManager _forcefieldManager;
|
|
private Portal _portal;
|
|
private StatsManager _statsManager;
|
|
private GadgetManager _gadgetManager;
|
|
private MountManager _mountManager;
|
|
private VisibilityManager _visibilityManager;
|
|
private TutorialManager _tutorialManager;
|
|
private TextManager _textCreator;
|
|
private ParkourManager _parkour;
|
|
private PreferencesManager _preferences;
|
|
private NewsManager _news;
|
|
|
|
private Location _spawn;
|
|
private int _scoreboardTick = 0;
|
|
|
|
private HashMap<Player, Scoreboard> _scoreboards = new HashMap<Player, Scoreboard>();
|
|
|
|
private String _pigStacker = "0 - Nobody";
|
|
|
|
private ItemStack _ruleBook = null;
|
|
|
|
private boolean _shuttingDown;
|
|
|
|
private HashMap<String, Long> _portalTime = new HashMap<String, Long>();
|
|
|
|
//Admin
|
|
private boolean _gadgetsEnabled = true;
|
|
|
|
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager)
|
|
{
|
|
super("Hub Manager", plugin);
|
|
|
|
_blockRestore = blockRestore;
|
|
_clientManager = clientManager;
|
|
_conditionManager = conditionManager;
|
|
_donationManager = donationManager;
|
|
_disguiseManager = disguiseManager;
|
|
|
|
_portal = portal;
|
|
|
|
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5);
|
|
|
|
_textCreator = new TextManager(this);
|
|
_parkour = new ParkourManager(this, donationManager, taskManager);
|
|
|
|
new MapManager(this);
|
|
new WorldManager(this);
|
|
new JumpManager(this);
|
|
|
|
_news = new NewsManager(this);
|
|
|
|
_mountManager = new MountManager(this);
|
|
_gadgetManager = new GadgetManager(this, _mountManager, petManager);
|
|
|
|
_partyManager = partyManager;
|
|
_preferences = preferences;
|
|
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
|
|
_visibilityManager = new VisibilityManager(this);
|
|
|
|
_forcefieldManager = new ForcefieldManager(this);
|
|
AddCommand(new ForcefieldRadius(_forcefieldManager));
|
|
|
|
_statsManager = new StatsManager(plugin);
|
|
|
|
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
|
|
|
|
_ruleBook = ItemStackFactory.Instance.CreateStack(Material.WRITTEN_BOOK, (byte)0, 1, ChatColor.GREEN + "Rule Book", new String[] { });
|
|
BookMeta meta = (BookMeta)_ruleBook.getItemMeta();
|
|
|
|
meta.addPage("§m-------------------§r\n"
|
|
+ "Welcome to §6§lMineplex§r\n"
|
|
+ "§r§0§l§r§m§0§m-------------------§r§0\n"
|
|
+ "\n"
|
|
+ "§2Please §0take a moment to read through this book!\n"
|
|
+ "\n"
|
|
+ "\n"
|
|
+ "Part 1 - Rules\n"
|
|
+ "\n"
|
|
+ "Part 2 - FAQ\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lRules§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§l1.§§§r §4No§r spamming.\n"
|
|
+ "\n"
|
|
+ "§0This is sending too many messages and/or repeating the same message in a short period of time.\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lRules§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§l2.§m§r §4No§0 use of excessive caps.\n"
|
|
+ "\n"
|
|
+ "This is sending messages with an excessive amount of capital letters.\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lRules§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§l3.§r §4No§0 hacking or use of any unapproved mods.\n"
|
|
+ "\n"
|
|
+ "This means we do not tolerate any sort of hacked client or any unapproved mods, such as fly hacks.\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lRules§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§l4.§r §4No§0 advertising non-Mineplex related links.\n"
|
|
+ "\n"
|
|
+ "This is when a link is sent in chat which directs others to non-Mineplex related content.\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lRules§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§l5.§r §4No§0 trolling or use of any exploits.\n"
|
|
+ "\n"
|
|
+ "This means that abuse of bugs/glitches is not tolerated. You also may not do things such as teamkilling and/or blocking spawns.\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lRules§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§l6.§r §2Be§0 respectful to others, yourself, and the environment around you.\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lRules§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§rPlease report any bugs, exploits, and/or rule breakers on our forums with evidence.\n"
|
|
+ "§omineplex.com/forums\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lFAQ§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§lWhat is stacker and how do you play it?\n"
|
|
+ "\n"
|
|
+ "§rStacker is a hub game where you can stack & throw players/mobs.\n"
|
|
+ "\n"
|
|
+ "§9Right-Click: pick up\n"
|
|
+ "Left-Click: throw\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lFAQ§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§lHow do I get §b§lUltra§0 §lor §5§lHero§0§l?\n"
|
|
+ "\n"
|
|
+ "§r§0You are able to purchase these ranks through our shop on our website at:\n"
|
|
+ "\n"
|
|
+ "§owww.mineplex.com/shop\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lFAQ§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§lWhy hasn't my rank been applied yet?\n"
|
|
+ "\n"
|
|
+ "§m§rYour rank may take a while to be applied. If it has been over 24 hours please email:\n"
|
|
+ "\n"
|
|
+ "§osupport@mineplex.com\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lFAQ§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§lWhat do I do if I was wrongfully punished?\n"
|
|
+ "\n"
|
|
+ "§0If you believe you were wrongfully punished, please submit an appeal at:\n"
|
|
+ "\n"
|
|
+ "§omineplex.com/appeals\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §2§lFAQ§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "§lHow do I apply for Helper?\n"
|
|
+ "\n"
|
|
+ "§rYou may only apply for Helper if you have §bUltra §0or §5Hero§0.\n"
|
|
+ "Apply at:\n"
|
|
+ "§omineplex.com/application\n");
|
|
|
|
meta.addPage("§m-------------------\n"
|
|
+ "§r §6§lThank you for \n"
|
|
+ " reading!§r§0\n"
|
|
+ "§m-------------------\n"
|
|
+ "§r\n"
|
|
+ "Remember to visit our website §2mineplex.com§0 for important news & updates!\n"
|
|
+ "\n"
|
|
+ "\n"
|
|
+ " §c§lH§6§lA§a§lV§9§lE §c§lF§6§lU§a§lN§9§l!\n");
|
|
|
|
_ruleBook.setItemMeta(meta);
|
|
}
|
|
|
|
@Override
|
|
public void AddCommands()
|
|
{
|
|
AddCommand(new GadgetToggle(this));
|
|
AddCommand(new NewsCommand(this));
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGHEST)
|
|
public void reflectMotd(ServerListPingEvent event)
|
|
{
|
|
if (_shuttingDown)
|
|
{
|
|
event.setMotd("Restarting soon");
|
|
}
|
|
}
|
|
|
|
public boolean BumpDisabled(Entity ent)
|
|
{
|
|
if (ent == null)
|
|
return false;
|
|
|
|
if (ent instanceof Player)
|
|
{
|
|
return !_preferences.Get((Player)ent).HubGames;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
@EventHandler
|
|
public void redirectStopCommand(PlayerCommandPreprocessEvent event)
|
|
{
|
|
if (event.getPlayer().isOp() && event.getMessage().equalsIgnoreCase("/stop"))
|
|
{
|
|
_shuttingDown = true;
|
|
|
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable()
|
|
{
|
|
public void run()
|
|
{
|
|
_portal.SendAllPlayers("Lobby");
|
|
|
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable()
|
|
{
|
|
public void run()
|
|
{
|
|
Bukkit.shutdown();
|
|
}
|
|
}, 40L);
|
|
}
|
|
}, 60L);
|
|
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler
|
|
public void preventEggSpawn(ItemSpawnEvent event)
|
|
{
|
|
if (event.getEntity() instanceof Egg)
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler
|
|
public void PlayerRespawn(PlayerRespawnEvent event)
|
|
{
|
|
event.setRespawnLocation(GetSpawn());
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
|
public void OnChunkLoad(ChunkLoadEvent event)
|
|
{
|
|
for (Entity entity : event.getChunk().getEntities())
|
|
{
|
|
if (entity instanceof LivingEntity)
|
|
{
|
|
if (((LivingEntity)entity).isCustomNameVisible() && ((LivingEntity)entity).getCustomName() != null)
|
|
{
|
|
if (ChatColor.stripColor(((LivingEntity)entity).getCustomName()).equalsIgnoreCase("Minekart"))
|
|
{
|
|
_disguiseManager.disguise(new DisguisePlayer(entity, ChatColor.YELLOW + "MineKart"));
|
|
}
|
|
else if (ChatColor.stripColor(((LivingEntity)entity).getCustomName()).equalsIgnoreCase("Block Hunt"))
|
|
{
|
|
DisguiseSlime disguise = new DisguiseSlime(entity);
|
|
disguise.SetCustomNameVisible(true);
|
|
disguise.SetName(((LivingEntity)entity).getCustomName());
|
|
disguise.SetSize(2);
|
|
_disguiseManager.disguise(disguise);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
public void login(final PlayerLoginEvent event)
|
|
{
|
|
CoreClient client = _clientManager.Get(event.getPlayer().getName());
|
|
|
|
// Reserved Slot Check
|
|
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
|
|
{
|
|
if (!client.GetRank().Has(Rank.ULTRA))
|
|
{
|
|
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
|
|
{
|
|
public void run()
|
|
{
|
|
_portal.SendPlayerToServer(event.getPlayer(), "Lobby");
|
|
}
|
|
});
|
|
|
|
event.allow();
|
|
}
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
public void PlayerJoin(PlayerJoinEvent event)
|
|
{
|
|
try
|
|
{
|
|
final Player player = event.getPlayer();
|
|
|
|
//Survival
|
|
player.setGameMode(GameMode.SURVIVAL);
|
|
|
|
//Public Message
|
|
event.setJoinMessage(null);
|
|
|
|
//Teleport
|
|
player.teleport(GetSpawn());
|
|
|
|
//Allow Double Jump
|
|
player.setAllowFlight(true);
|
|
|
|
UtilInv.Clear(player);
|
|
|
|
player.getInventory().setItem(6, _ruleBook);
|
|
|
|
//Scoreboard
|
|
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
|
|
player.setScoreboard(board);
|
|
_scoreboards.put(player, board);
|
|
|
|
//Objective
|
|
Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy");
|
|
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
|
|
|
|
|
for (Rank rank : Rank.values())
|
|
{
|
|
if (rank != Rank.ALL)
|
|
board.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " ");
|
|
else
|
|
board.registerNewTeam(rank.Name).setPrefix("");
|
|
}
|
|
|
|
for (Player otherPlayer : Bukkit.getOnlinePlayers())
|
|
{
|
|
if (_clientManager.Get(otherPlayer) == null)
|
|
continue;
|
|
|
|
String rankName = _clientManager.Get(player).GetRank().Name;
|
|
String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name;
|
|
|
|
if (!_clientManager.Get(player).GetRank().Has(Rank.ULTRA) && _donationManager.Get(player.getName()).OwnsUltraPackage())
|
|
{
|
|
rankName = Rank.ULTRA.Name;
|
|
}
|
|
|
|
if (!_clientManager.Get(otherPlayer).GetRank().Has(Rank.ULTRA) && _donationManager.Get(otherPlayer.getName()).OwnsUltraPackage())
|
|
{
|
|
otherRankName = Rank.ULTRA.Name;
|
|
}
|
|
|
|
//Add Other to Self
|
|
board.getTeam(otherRankName).addPlayer(otherPlayer);
|
|
|
|
//Add Self to Other
|
|
otherPlayer.getScoreboard().getTeam(rankName).addPlayer(player);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Instance.log(ex);
|
|
System.out.println("[HubManager] Player Join exception");
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
@EventHandler
|
|
public void PlayerQuit(PlayerQuitEvent event)
|
|
{
|
|
event.setQuitMessage(null);
|
|
|
|
event.getPlayer().leaveVehicle();
|
|
event.getPlayer().eject();
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
player.getScoreboard().resetScores(event.getPlayer().getName());
|
|
|
|
_scoreboards.remove(event.getPlayer());
|
|
|
|
_portalTime.remove(event.getPlayer().getName());
|
|
}
|
|
|
|
@EventHandler
|
|
public void PlayerChat(AsyncPlayerChatEvent event)
|
|
{
|
|
if (event.isCancelled())
|
|
return;
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
Rank rank = GetClients().Get(player).GetRank();
|
|
|
|
boolean ownsUltra = _donationManager.Get(player.getName()).OwnsUltraPackage();
|
|
|
|
//Rank Prefix
|
|
String rankStr = "";
|
|
if (rank != Rank.ALL)
|
|
rankStr = rank.GetTag(true, true) + " ";
|
|
|
|
if (ownsUltra && !rank.Has(Rank.ULTRA))
|
|
rankStr = Rank.ULTRA.GetTag(true, true) + " ";
|
|
|
|
//Party Chat
|
|
if (event.getMessage().charAt(0) == '@')
|
|
{
|
|
Party party = _partyManager.GetParty(player);
|
|
if (party != null)
|
|
{
|
|
event.getRecipients().clear();
|
|
|
|
event.setMessage(event.getMessage().substring(1, event.getMessage().length()));
|
|
event.setFormat(C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + "%1$s " + C.cPurple + "%2$s");
|
|
|
|
for (String name : party.GetPlayers())
|
|
{
|
|
Player other = UtilPlayer.searchExact(name);
|
|
|
|
if (other != null)
|
|
event.getRecipients().add(other);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UtilPlayer.message(player, F.main("Party", "You are not in a Party."));
|
|
event.setCancelled(true);
|
|
}
|
|
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
for (Player other : UtilServer.getPlayers())
|
|
{
|
|
if (_tutorialManager.InTutorial(other))
|
|
{
|
|
event.getRecipients().remove(other);
|
|
continue;
|
|
}
|
|
|
|
event.setMessage(event.getMessage());
|
|
event.setFormat(rankStr + C.cYellow + "%1$s " + C.cWhite + "%2$s");
|
|
}
|
|
}
|
|
}
|
|
|
|
@EventHandler
|
|
public void Damage(EntityDamageEvent event)
|
|
{
|
|
if (event.getCause() == DamageCause.VOID)
|
|
if (event.getEntity() instanceof Player)
|
|
{
|
|
event.getEntity().eject();
|
|
event.getEntity().leaveVehicle();
|
|
event.getEntity().teleport(GetSpawn());
|
|
}
|
|
|
|
else
|
|
event.getEntity().remove();
|
|
|
|
event.setCancelled(true);
|
|
}
|
|
|
|
|
|
@EventHandler
|
|
public void FoodHealthUpdate(UpdateEvent event)
|
|
{
|
|
if (event.getType() != UpdateType.SLOW)
|
|
return;
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
{
|
|
player.setHealth(20);
|
|
player.setFoodLevel(20);
|
|
}
|
|
}
|
|
|
|
@EventHandler
|
|
public void InventoryCancel(InventoryClickEvent event)
|
|
{
|
|
if (event.getWhoClicked() instanceof Player && ((Player)event.getWhoClicked()).getGameMode() != GameMode.CREATIVE)
|
|
event.setCancelled(true);
|
|
}
|
|
|
|
@EventHandler
|
|
public void UpdateScoreboard(UpdateEvent event)
|
|
{
|
|
if (event.getType() != UpdateType.TICK)
|
|
return;
|
|
|
|
_scoreboardTick = (_scoreboardTick + 1)%3;
|
|
|
|
if (_scoreboardTick != 0)
|
|
return;
|
|
|
|
int bestPig = 0;
|
|
for (Player player : UtilServer.getPlayers())
|
|
{
|
|
if (player.getVehicle() != null)
|
|
continue;
|
|
|
|
int count = 0;
|
|
|
|
Entity ent = player;
|
|
while (ent.getPassenger() != null)
|
|
{
|
|
ent = ent.getPassenger();
|
|
count++;
|
|
}
|
|
|
|
if (count > bestPig)
|
|
{
|
|
_pigStacker = player.getName();
|
|
bestPig = count;
|
|
}
|
|
}
|
|
if (bestPig == 0)
|
|
{
|
|
_pigStacker = "0 - Nobody";
|
|
}
|
|
else
|
|
{
|
|
_pigStacker = bestPig + " - " + _pigStacker;
|
|
|
|
if (_pigStacker.length() > 16)
|
|
_pigStacker = _pigStacker.substring(0, 16);
|
|
}
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
{
|
|
//Dont Waste Time
|
|
if (_partyManager.GetParty(player) != null)
|
|
continue;
|
|
|
|
//Return to Main Scoreboard
|
|
if (!player.getScoreboard().equals(_scoreboards.get(player)))
|
|
player.setScoreboard(_scoreboards.get(player));
|
|
|
|
//Objective
|
|
Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
|
|
|
//Title
|
|
obj.setDisplayName(C.cWhite + C.Bold + Get(player).GetScoreboardText());
|
|
|
|
int line = 15;
|
|
|
|
obj.getScore(C.cGreen + C.Bold + "Gems").setScore(line--);
|
|
|
|
// Remove Old
|
|
player.getScoreboard().resetScores(Get(player.getName()).GetLastGemCount() + "");
|
|
// Add New
|
|
obj.getScore(GetDonation().Get(player.getName()).GetGems() + "").setScore(line--);
|
|
|
|
Get(player.getName()).SetLastGemCount(GetDonation().Get(player.getName()).GetGems());
|
|
|
|
//Space
|
|
obj.getScore(" ").setScore(line--);
|
|
|
|
/*
|
|
//News
|
|
obj.getScore(C.cGray + C.Bold + "Latest News")).setScore(line--);
|
|
player.getScoreboard().resetScores(Get(player).GetNewsText(false)));
|
|
obj.getScore(Get(player).GetNewsText(true))).setScore(line--);
|
|
*/
|
|
|
|
//Stacker
|
|
obj.getScore(C.cGray + C.Bold + "Stacker").setScore(line--);
|
|
player.getScoreboard().resetScores(Get(player).BestPig);
|
|
Get(player).BestPig = _pigStacker;
|
|
obj.getScore(Get(player).BestPig).setScore(line--);
|
|
|
|
//Space
|
|
obj.getScore(" ").setScore(line--);
|
|
|
|
//Display Rank
|
|
if (GetClients().Get(player).GetRank().Has(Rank.HERO))
|
|
{
|
|
obj.getScore(C.cPurple + C.Bold + "Hero Rank").setScore(line--);
|
|
|
|
player.getScoreboard().resetScores(Get(player).GetUltraText(false));
|
|
obj.getScore(Get(player).GetUltraText(true)).setScore(line--);
|
|
}
|
|
else if (GetClients().Get(player).GetRank().Has(Rank.ULTRA))
|
|
{
|
|
obj.getScore(C.cAqua + C.Bold + "Ultra Rank").setScore(line--);
|
|
|
|
player.getScoreboard().resetScores(Get(player).GetUltraText(false));
|
|
obj.getScore(Get(player).GetUltraText(true)).setScore(line--);
|
|
}
|
|
else
|
|
{
|
|
obj.getScore(C.cRed + C.Bold + "No Rank").setScore(line--);
|
|
|
|
player.getScoreboard().resetScores(Get(player).GetPurchaseText(false));
|
|
obj.getScore(Get(player).GetPurchaseText(true)).setScore(line--);
|
|
}
|
|
|
|
//Space
|
|
obj.getScore(" ").setScore(line--);
|
|
|
|
//Display Staff
|
|
obj.getScore(C.cGold + C.Bold + "Online Staff").setScore(line--);
|
|
String staff = "";
|
|
for (Player other : UtilServer.getPlayers())
|
|
{
|
|
Rank rank = GetClients().Get(other).GetRank();
|
|
|
|
if (!rank.Has(Rank.HELPER))
|
|
continue;
|
|
|
|
staff += other.getName() + " ";
|
|
}
|
|
if (staff.length() == 0)
|
|
staff = "None";
|
|
|
|
player.getScoreboard().resetScores(Get(player).GetStaffText(false));
|
|
Get(player).StaffString = staff;
|
|
obj.getScore(Get(player).GetStaffText(true)).setScore(line--);
|
|
|
|
//Space
|
|
obj.getScore(" ").setScore(line--);
|
|
|
|
//Website
|
|
obj.getScore(C.cYellow + C.Bold + "Website").setScore(line--);
|
|
obj.getScore("www.mineplex.com").setScore(line--);
|
|
obj.getScore("----------------").setScore(line--);
|
|
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected HubClient AddPlayer(String player)
|
|
{
|
|
return new HubClient(player);
|
|
}
|
|
|
|
public BlockRestore GetBlockRestore()
|
|
{
|
|
return _blockRestore;
|
|
}
|
|
|
|
public CoreClientManager GetClients()
|
|
{
|
|
return _clientManager;
|
|
}
|
|
|
|
public ConditionManager GetCondition()
|
|
{
|
|
return _conditionManager;
|
|
}
|
|
|
|
public DonationManager GetDonation()
|
|
{
|
|
return _donationManager;
|
|
}
|
|
|
|
public DisguiseManager GetDisguise()
|
|
{
|
|
return _disguiseManager;
|
|
}
|
|
|
|
public GadgetManager GetGadget()
|
|
{
|
|
return _gadgetManager;
|
|
}
|
|
|
|
public MountManager GetMount()
|
|
{
|
|
return _mountManager;
|
|
}
|
|
|
|
public ParkourManager GetParkour()
|
|
{
|
|
return _parkour;
|
|
}
|
|
|
|
public PreferencesManager getPreferences()
|
|
{
|
|
return _preferences;
|
|
}
|
|
|
|
public Location GetSpawn()
|
|
{
|
|
return _spawn.clone();
|
|
}
|
|
|
|
public TutorialManager GetTutorial()
|
|
{
|
|
return _tutorialManager;
|
|
}
|
|
|
|
public StatsManager GetStats()
|
|
{
|
|
return _statsManager;
|
|
}
|
|
|
|
public VisibilityManager GetVisibility()
|
|
{
|
|
return _visibilityManager;
|
|
}
|
|
|
|
public void SetPortalDelay(Entity ent)
|
|
{
|
|
if (ent instanceof Player)
|
|
_portalTime.put(((Player)ent).getName(), System.currentTimeMillis());
|
|
}
|
|
|
|
public boolean CanPortal(Player player)
|
|
{
|
|
//Riding
|
|
if (player.getVehicle() != null || player.getPassenger() != null)
|
|
return false;
|
|
|
|
//Portal Delay
|
|
if (!_portalTime.containsKey(player.getName()))
|
|
return true;
|
|
|
|
return UtilTime.elapsed(_portalTime.get(player.getName()), 5000);
|
|
}
|
|
|
|
public boolean CanBump(LivingEntity ent)
|
|
{
|
|
if (!(ent instanceof Player))
|
|
return true;
|
|
|
|
if (BumpDisabled(ent))
|
|
return false;
|
|
|
|
if (!getPreferences().Get((Player)ent).ShowPlayers)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
@EventHandler
|
|
public void HeartDisplay(UpdateEvent event)
|
|
{
|
|
if (event.getType() != UpdateType.FASTER)
|
|
return;
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
{
|
|
if (!player.isOp())
|
|
continue;
|
|
|
|
for (Player other : UtilServer.getPlayers())
|
|
{
|
|
if (player.getName().equalsIgnoreCase("Chiss"))
|
|
UtilParticle.PlayParticle(other, ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.25f, 0.5f, 0.25f, 0, 1);
|
|
|
|
else if (player.getName().equalsIgnoreCase("defek7"))
|
|
UtilParticle.PlayParticle(other, ParticleType.FIREWORKS_SPARK, player.getLocation().add(0, 1, 0), 0.25f, 0.5f, 0.25f, 0, 2);
|
|
|
|
else if (player.getName().equalsIgnoreCase("Spu_"))
|
|
UtilParticle.PlayParticle(other, ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.25f, 0.5f, 0.25f, 0, 2);
|
|
|
|
else if (player.getName().equalsIgnoreCase("sterling_"))
|
|
UtilParticle.PlayParticle(other, ParticleType.WITCH_MAGIC, player.getLocation().add(0, 1, 0), 0.25f, 0.5f, 0.25f, 0, 2);
|
|
}
|
|
}
|
|
}
|
|
|
|
@EventHandler
|
|
public void SkillTrigger(SkillTriggerEvent event)
|
|
{
|
|
event.SetCancelled(true);
|
|
}
|
|
|
|
@EventHandler
|
|
public void ItemTrigger(ItemTriggerEvent event)
|
|
{
|
|
event.SetCancelled(true);
|
|
}
|
|
|
|
public boolean IsGadgetEnabled()
|
|
{
|
|
return _gadgetsEnabled;
|
|
}
|
|
|
|
public void SetGadgetEnabled(boolean _enabled)
|
|
{
|
|
this._gadgetsEnabled = _enabled;
|
|
}
|
|
|
|
public NewsManager GetNewsManager()
|
|
{
|
|
return _news;
|
|
}
|
|
|
|
@Override
|
|
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
|
{
|
|
|
|
}
|
|
}
|