2013-08-27 17:14:08 +02:00
|
|
|
package mineplex.hub;
|
|
|
|
|
2013-09-01 00:34:53 +02:00
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
import java.io.DataInputStream;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.FileWriter;
|
|
|
|
import java.io.InputStreamReader;
|
2013-08-31 10:19:23 +02:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Effect;
|
|
|
|
import org.bukkit.GameMode;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.block.BlockFace;
|
2013-09-02 01:35:04 +02:00
|
|
|
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
|
2013-08-31 10:19:23 +02:00
|
|
|
import org.bukkit.entity.Chicken;
|
|
|
|
import org.bukkit.entity.Cow;
|
2013-09-04 20:35:59 +02:00
|
|
|
import org.bukkit.entity.Egg;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.entity.Entity;
|
2013-08-31 10:19:23 +02:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Pig;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2013-08-31 10:19:23 +02:00
|
|
|
import org.bukkit.entity.Sheep;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.block.BlockBreakEvent;
|
|
|
|
import org.bukkit.event.block.BlockPlaceEvent;
|
2013-09-02 00:16:35 +02:00
|
|
|
import org.bukkit.event.block.BlockSpreadEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.block.LeavesDecayEvent;
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
2013-08-31 11:51:59 +02:00
|
|
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
2013-09-04 20:35:59 +02:00
|
|
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
|
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
|
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
|
|
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
|
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
|
|
|
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
2013-08-31 11:01:41 +02:00
|
|
|
import org.bukkit.event.world.ChunkLoadEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
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.CoreClientManager;
|
|
|
|
import mineplex.core.common.Rank;
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.UtilAction;
|
|
|
|
import mineplex.core.common.util.UtilBlock;
|
|
|
|
import mineplex.core.common.util.UtilEnt;
|
|
|
|
import mineplex.core.common.util.UtilInv;
|
|
|
|
import mineplex.core.common.util.UtilMath;
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
|
|
|
import mineplex.core.common.util.UtilWorld;
|
2013-08-31 11:01:41 +02:00
|
|
|
import mineplex.core.disguise.DisguiseManager;
|
|
|
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.donation.DonationManager;
|
2013-09-03 20:34:28 +02:00
|
|
|
import mineplex.core.task.TaskManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
2013-09-03 02:16:44 +02:00
|
|
|
import mineplex.hub.tutorial.Tutorial;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
public class HubManager extends MiniClientPlugin<HubClient>
|
|
|
|
{
|
|
|
|
private CoreClientManager _clientManager;
|
|
|
|
private DonationManager _donationManager;
|
2013-08-31 11:01:41 +02:00
|
|
|
private DisguiseManager _disguiseManager;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-09-03 02:16:44 +02:00
|
|
|
private Tutorial _tutorial;
|
|
|
|
private TextCreator _textCreator;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
private Location _spawn;
|
|
|
|
private int _scoreboardTick = 0;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
private String _pigStacker = "0 - Nobody";
|
2013-08-31 10:19:23 +02:00
|
|
|
|
2013-09-01 00:34:53 +02:00
|
|
|
public String DragonTextA = "Mineplex";
|
|
|
|
public String DragonTextB = "";
|
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
private HashSet<LivingEntity> _mobs = new HashSet<LivingEntity>();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-09-03 20:34:28 +02:00
|
|
|
public HubManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, DisguiseManager disguiseManager, TaskManager taskManager)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
super("Hub Manager", plugin);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
_clientManager = clientManager;
|
|
|
|
_donationManager = donationManager;
|
2013-08-31 11:01:41 +02:00
|
|
|
_disguiseManager = disguiseManager;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-09-03 02:16:44 +02:00
|
|
|
_textCreator = new TextCreator(this);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-31 11:51:59 +02:00
|
|
|
new Dragon(this);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-09-03 20:34:28 +02:00
|
|
|
_tutorial = new Tutorial(this, _textCreator, donationManager, taskManager);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
|
|
|
DragonTextB = GetDragonText();
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
|
|
|
public String GetDragonText()
|
|
|
|
{
|
|
|
|
File file = new File("DragonText.dat");
|
|
|
|
|
|
|
|
//Write If Blank
|
|
|
|
if (!file.exists())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
FileWriter fstream = new FileWriter(file);
|
|
|
|
BufferedWriter out = new BufferedWriter(fstream);
|
|
|
|
|
|
|
|
out.write("Home of Premium Game Modes");
|
|
|
|
|
|
|
|
out.close();
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
System.out.println("Error: Game World GetId Write Exception");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String line = "Home of Premium Game Modes";
|
|
|
|
|
|
|
|
//Read
|
|
|
|
try
|
|
|
|
{
|
|
|
|
FileInputStream fstream = new FileInputStream(file);
|
|
|
|
DataInputStream in = new DataInputStream(fstream);
|
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
|
|
|
line = br.readLine();
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
System.out.println("Error: Game World GetId Read Exception");
|
|
|
|
}
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
2013-09-04 20:35:59 +02:00
|
|
|
@EventHandler
|
|
|
|
public void preventEggSpawn(ItemSpawnEvent event)
|
|
|
|
{
|
|
|
|
if (event.getEntity() instanceof Egg)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void PlayerRespawn(PlayerRespawnEvent event)
|
|
|
|
{
|
2013-08-31 10:19:23 +02:00
|
|
|
event.setRespawnLocation(GetSpawn());
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
|
|
|
@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 (((LivingEntity)entity).getCustomName().equalsIgnoreCase("play minekart plz"))
|
|
|
|
{
|
|
|
|
_disguiseManager.disguise(new DisguisePlayer(entity, "Play " + ChatColor.YELLOW + "MineKart"));
|
|
|
|
}
|
|
|
|
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("defek7"))
|
|
|
|
_disguiseManager.disguise(new DisguisePlayer(entity, "defek7"));
|
|
|
|
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("chiss"))
|
|
|
|
_disguiseManager.disguise(new DisguisePlayer(entity, "Chiss"));
|
|
|
|
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("Sterling_"))
|
|
|
|
_disguiseManager.disguise(new DisguisePlayer(entity, "sterling_"));
|
|
|
|
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("Spu_"))
|
|
|
|
_disguiseManager.disguise(new DisguisePlayer(entity, "Spu_"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void PlayerJoin(PlayerJoinEvent event)
|
|
|
|
{
|
|
|
|
final Player player = event.getPlayer();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Survival
|
|
|
|
player.setGameMode(GameMode.SURVIVAL);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Public Message
|
|
|
|
event.setJoinMessage(null);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Teleport
|
2013-08-31 10:19:23 +02:00
|
|
|
player.teleport(GetSpawn());
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Allow Double Jump
|
|
|
|
player.setAllowFlight(true);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
UtilInv.Clear(player);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Scoreboard
|
|
|
|
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
|
|
|
|
player.setScoreboard(board);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Objective
|
|
|
|
Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy");
|
|
|
|
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
for (Rank rank : Rank.values())
|
|
|
|
{
|
|
|
|
if (rank != Rank.ALL)
|
|
|
|
board.registerNewTeam(rank.Name).setPrefix(rank.Color + C.Bold + rank.Name + ChatColor.RESET + " ");
|
|
|
|
else
|
|
|
|
board.registerNewTeam(rank.Name).setPrefix("");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Player otherPlayer : Bukkit.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
//Add Other to Self
|
|
|
|
board.getTeam(_clientManager.Get(otherPlayer).GetRank().Name).addPlayer(otherPlayer);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Add Self to Other
|
|
|
|
otherPlayer.getScoreboard().getTeam(_clientManager.Get(player).GetRank().Name).addPlayer(player);
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-09-01 05:28:35 +02:00
|
|
|
board.getTeam(Rank.OWNER.Name).addPlayer(Bukkit.getOfflinePlayer("Chiss"));
|
|
|
|
board.getTeam(Rank.OWNER.Name).addPlayer(Bukkit.getOfflinePlayer("defek7"));
|
|
|
|
board.getTeam(Rank.OWNER.Name).addPlayer(Bukkit.getOfflinePlayer("Spu_"));
|
|
|
|
board.getTeam(Rank.OWNER.Name).addPlayer(Bukkit.getOfflinePlayer("sterling_"));
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void PlayerQuit(PlayerQuitEvent event)
|
|
|
|
{
|
|
|
|
event.setQuitMessage(null);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
event.getPlayer().leaveVehicle();
|
|
|
|
event.getPlayer().eject();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
player.getScoreboard().resetScores(event.getPlayer());
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void PlayerChat(AsyncPlayerChatEvent event)
|
|
|
|
{
|
|
|
|
if (event.isCancelled())
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
event.setCancelled(true);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Player player = event.getPlayer();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Rank rank = GetClients().Get(player).GetRank();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
String rankStr = "";
|
|
|
|
if (rank != Rank.ALL)
|
|
|
|
rankStr = rank.Color + C.Bold + GetClients().Get(player).GetRank().Name.toUpperCase() + " ";
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
for (Player other : UtilServer.getPlayers())
|
|
|
|
{
|
2013-09-03 02:16:44 +02:00
|
|
|
if (_tutorial.InTutorial(other))
|
|
|
|
continue;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
UtilPlayer.message(other, rankStr + C.cYellow + player.getName() + " " + C.cWhite + event.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void Damage(EntityDamageEvent event)
|
|
|
|
{
|
2013-09-02 00:24:37 +02:00
|
|
|
if (event.getCause() == DamageCause.VOID)
|
|
|
|
if (event.getEntity() instanceof Player)
|
|
|
|
event.getEntity().teleport(GetSpawn());
|
|
|
|
else
|
|
|
|
event.getEntity().remove();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void ItemPickup(PlayerPickupItemEvent event)
|
|
|
|
{
|
|
|
|
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void ItemDrop(PlayerDropItemEvent event)
|
|
|
|
{
|
|
|
|
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void BlockBreak(BlockBreakEvent event)
|
|
|
|
{
|
2013-08-31 10:19:23 +02:00
|
|
|
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void LeaveDecay(LeavesDecayEvent event)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void BlockPlace(BlockPlaceEvent event)
|
|
|
|
{
|
2013-08-31 10:19:23 +02:00
|
|
|
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void FlightHop(PlayerToggleFlightEvent event)
|
|
|
|
{
|
|
|
|
Player player = event.getPlayer();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (player.getGameMode() == GameMode.CREATIVE)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
event.setCancelled(true);
|
|
|
|
player.setFlying(false);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Disable Flight
|
|
|
|
player.setAllowFlight(false);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Velocity
|
|
|
|
UtilAction.velocity(player, 1.4, 0.2, 1, true);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Sound
|
2013-09-02 10:16:29 +02:00
|
|
|
player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void FlightUpdate(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.TICK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (player.getGameMode() == GameMode.CREATIVE)
|
|
|
|
continue;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
2013-09-02 00:16:35 +02:00
|
|
|
{
|
2013-08-27 17:14:08 +02:00
|
|
|
player.setAllowFlight(true);
|
2013-09-02 00:16:35 +02:00
|
|
|
player.setFlying(false);
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void FoodHealthUpdate(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.SLOW)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
player.setHealth(20);
|
|
|
|
player.setFoodLevel(20);
|
|
|
|
}
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void UpdateWeather(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.SEC)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
World world = UtilWorld.getWorld("world");
|
|
|
|
world.setTime(6000);
|
|
|
|
world.setStorm(false);
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void UpdateScoreboard(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.TICK)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
_scoreboardTick = (_scoreboardTick + 1)%3;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (_scoreboardTick != 0)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
int bestPig = 0;
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (player.getVehicle() != null)
|
|
|
|
continue;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
int count = 0;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Entity ent = player;
|
|
|
|
while (ent.getPassenger() != null)
|
|
|
|
{
|
|
|
|
ent = ent.getPassenger();
|
|
|
|
count++;
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (count > bestPig)
|
|
|
|
{
|
|
|
|
_pigStacker = player.getName();
|
|
|
|
bestPig = count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bestPig == 0)
|
|
|
|
{
|
|
|
|
_pigStacker = "0 - Nobody";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_pigStacker = bestPig + " - " + _pigStacker;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (_pigStacker.length() > 16)
|
|
|
|
_pigStacker = _pigStacker.substring(0, 16);
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
//Objective
|
|
|
|
Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Title
|
|
|
|
obj.setDisplayName(C.cWhite + C.Bold + Get(player).GetScoreboardText());
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
int line = 15;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(C.cGreen + C.Bold + "Gems")).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
// Remove Old
|
|
|
|
player.getScoreboard().resetScores(Bukkit.getOfflinePlayer(Get(player.getName()).GetLastGemCount() + ""));
|
|
|
|
// Add New
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(GetDonation().Get(player.getName()).GetGems() + "")).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Get(player.getName()).SetLastGemCount(GetDonation().Get(player.getName()).GetGems());
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Space
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(" ")).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
/*
|
|
|
|
//News
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(C.cGray + C.Bold + "Latest News")).setScore(line--);
|
|
|
|
player.getScoreboard().resetScores(Bukkit.getOfflinePlayer(Get(player).GetNewsText(false)));
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(Get(player).GetNewsText(true))).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
*/
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Stacker
|
2013-08-31 10:19:23 +02:00
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(C.cGray + C.Bold + "Stacker")).setScore(line--);
|
2013-08-27 17:14:08 +02:00
|
|
|
player.getScoreboard().resetScores(Bukkit.getOfflinePlayer(Get(player).BestPig));
|
|
|
|
Get(player).BestPig = _pigStacker;
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(Get(player).BestPig)).setScore(line--);
|
|
|
|
|
|
|
|
//Space
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(" ")).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Display Rank
|
|
|
|
if (GetClients().Get(player).GetRank().Has(Rank.ULTRA))
|
|
|
|
{
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(C.cPurple + C.Bold + "Ultra Rank")).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
player.getScoreboard().resetScores(Bukkit.getOfflinePlayer(Get(player).GetUltraText(false)));
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(Get(player).GetUltraText(true))).setScore(line--);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(C.cRed + C.Bold + "No Rank")).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
player.getScoreboard().resetScores(Bukkit.getOfflinePlayer(Get(player).GetPurchaseText(false)));
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(Get(player).GetPurchaseText(true))).setScore(line--);
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Space
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(" ")).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Display Staff
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(C.cGold + C.Bold + "Online Staff")).setScore(line--);
|
|
|
|
String staff = "";
|
|
|
|
for (Player other : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
Rank rank = GetClients().Get(other).GetRank();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (!rank.Has(Rank.HELPER))
|
|
|
|
continue;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
staff += other.getName() + " ";
|
|
|
|
}
|
|
|
|
if (staff.length() == 0)
|
|
|
|
staff = "None";
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
player.getScoreboard().resetScores(Bukkit.getOfflinePlayer(Get(player).GetStaffText(false)));
|
|
|
|
Get(player).StaffString = staff;
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(Get(player).GetStaffText(true))).setScore(line--);
|
|
|
|
|
|
|
|
//Space
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(" ")).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Website
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer(C.cYellow + C.Bold + "Website")).setScore(line--);
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer("www.mineplex.com")).setScore(line--);
|
|
|
|
obj.getScore(Bukkit.getOfflinePlayer("----------------")).setScore(line--);
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@Override
|
|
|
|
protected HubClient AddPlayer(String player)
|
|
|
|
{
|
|
|
|
return new HubClient(player);
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public CoreClientManager GetClients()
|
|
|
|
{
|
|
|
|
return _clientManager;
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public DonationManager GetDonation()
|
|
|
|
{
|
|
|
|
return _donationManager;
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
public Location GetSpawn()
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2013-08-31 10:19:23 +02:00
|
|
|
return _spawn.clone();
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
@EventHandler
|
|
|
|
public void UpdateVisibility(UpdateEvent event)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2013-08-31 10:19:23 +02:00
|
|
|
if (event.getType() != UpdateType.FAST)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
for (Player other : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (player.equals(other))
|
|
|
|
continue;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-09-04 10:03:01 +02:00
|
|
|
if (UtilMath.offset(player.getLocation(), GetSpawn()) < 4 || _tutorial.InTutorial(other) || _tutorial.InTutorial(player))
|
2013-08-31 10:19:23 +02:00
|
|
|
{
|
2013-09-02 01:35:04 +02:00
|
|
|
((CraftPlayer)other).hidePlayer(player, true, false);
|
2013-08-31 10:19:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
other.showPlayer(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
@EventHandler
|
|
|
|
public void SpawnAnimals(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.SLOW)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
Iterator<LivingEntity> entIterator = _mobs.iterator();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
while (entIterator.hasNext())
|
|
|
|
{
|
|
|
|
LivingEntity ent = entIterator.next();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
if (!ent.isValid())
|
|
|
|
{
|
|
|
|
ent.remove();
|
|
|
|
entIterator.remove();
|
|
|
|
}
|
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
if (_mobs.size() > 24)
|
|
|
|
return;
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
//Loc
|
|
|
|
double r = Math.random();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
Location loc = GetSpawn();
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 10:19:23 +02:00
|
|
|
if (r > 0.75) loc.add(32, 0.5, 0);
|
|
|
|
else if (r > 0.5) loc.add(0, 0.5, 32);
|
|
|
|
else if (r > 0.25) loc.add(-32, 0.5, 0);
|
|
|
|
else loc.add(0, 0.5, -32);
|
|
|
|
|
|
|
|
//Spawn
|
|
|
|
r = Math.random();
|
|
|
|
|
|
|
|
if (r > 0.75) _mobs.add(loc.getWorld().spawn(loc, Cow.class));
|
|
|
|
else if (r > 0.5) _mobs.add(loc.getWorld().spawn(loc, Pig.class));
|
|
|
|
else if (r > 0.25) _mobs.add(loc.getWorld().spawn(loc, Sheep.class));
|
|
|
|
else _mobs.add(loc.getWorld().spawn(loc, Chicken.class));
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-01 00:34:53 +02:00
|
|
|
|
2013-08-31 11:51:59 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
public void Explosion(EntityExplodeEvent event)
|
|
|
|
{
|
|
|
|
event.blockList().clear();
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-09-02 00:16:35 +02:00
|
|
|
@EventHandler
|
|
|
|
public void VineGrow(BlockSpreadEvent event)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|