Fixing bugs

This commit is contained in:
libraryaddict 2015-11-04 18:34:22 +13:00
parent c25b1969de
commit b3f86ba638
5 changed files with 257 additions and 406 deletions

View File

@ -8,6 +8,7 @@ import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
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;
@ -17,6 +18,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.EnchantingInventory; import org.bukkit.inventory.EnchantingInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -174,7 +176,14 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
return; return;
} }
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, 30, (byte) 4)); int level = ((Player) event.getPlayer()).getLevel();
for (HumanEntity viewer : event.getViewers())
{
level = Math.max(((Player) viewer).getLevel(), level);
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4));
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
@ -198,6 +207,14 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
if (event.getViewers().size() > 1) if (event.getViewers().size() > 1)
{ {
int level = ((Player) event.getPlayer()).getLevel();
for (HumanEntity viewer : event.getViewers())
{
level = Math.max(((Player) viewer).getLevel(), level);
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4));
return; return;
} }
@ -205,21 +222,45 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
} }
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) public void onInventoryClick(final InventoryClickEvent event)
{ {
if (event.getView().getTopInventory().getType() != InventoryType.ENCHANTING) if (event.getView().getTopInventory().getType() != InventoryType.ENCHANTING)
{ {
return; return;
} }
ItemStack item = event.getCurrentItem(); if (event.getSlot() == 1)
{
event.setCancelled(true);
return;
}
if (item == null || item.getType() != Material.INK_SACK) if (event.getSlot() != 2)
{ {
return; return;
} }
event.setCancelled(true); Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
public void run()
{
Inventory inv = event.getInventory();
if (inv.getViewers().isEmpty())
{
return;
}
int level = 0;
for (HumanEntity viewer : inv.getViewers())
{
level = Math.max(((Player) viewer).getLevel(), level);
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4));
}
});
} }
@EventHandler @EventHandler

View File

@ -100,24 +100,19 @@ public abstract class Game implements Listener
public enum GameState public enum GameState
{ {
Loading, Loading, Recruit, Prepare, Live, End, Dead
Recruit,
Prepare,
Live,
End,
Dead
} }
public ArcadeManager Manager; public ArcadeManager Manager;
//Game // Game
private GameType _gameType; private GameType _gameType;
protected String[] _gameDesc; protected String[] _gameDesc;
//Map // Map
private HashMap<GameType, ArrayList<String>> _files; private HashMap<GameType, ArrayList<String>> _files;
//State // State
private GameState _gameState = GameState.Loading; private GameState _gameState = GameState.Loading;
private long _gameLiveTime; private long _gameLiveTime;
private long _gameStateTime = System.currentTimeMillis(); private long _gameStateTime = System.currentTimeMillis();
@ -129,36 +124,36 @@ public abstract class Game implements Listener
private String _customWinLine = ""; private String _customWinLine = "";
//Kits // Kits
private Kit[] _kits; private Kit[] _kits;
//Teams // Teams
protected ArrayList<GameTeam> _teamList = new ArrayList<GameTeam>(); protected ArrayList<GameTeam> _teamList = new ArrayList<GameTeam>();
//Player Preferences // Player Preferences
protected NautHashMap<Player, Kit> _playerKit = new NautHashMap<Player, Kit>(); protected NautHashMap<Player, Kit> _playerKit = new NautHashMap<Player, Kit>();
private NautHashMap<GameTeam, ArrayList<Player>> _teamPreference = new NautHashMap<GameTeam, ArrayList<Player>>(); private NautHashMap<GameTeam, ArrayList<Player>> _teamPreference = new NautHashMap<GameTeam, ArrayList<Player>>();
//Player Data // Player Data
private NautHashMap<Player, HashMap<String, GemData>> _gemCount = new NautHashMap<Player, HashMap<String, GemData>>(); private NautHashMap<Player, HashMap<String, GemData>> _gemCount = new NautHashMap<Player, HashMap<String, GemData>>();
private NautHashMap<Player, HashMap<String, Integer>> _stats = new NautHashMap<Player, HashMap<String, Integer>>(); private NautHashMap<Player, HashMap<String, Integer>> _stats = new NautHashMap<Player, HashMap<String, Integer>>();
//Player Location Store // Player Location Store
private NautHashMap<String, Location> _playerLocationStore = new NautHashMap<String, Location>(); private NautHashMap<String, Location> _playerLocationStore = new NautHashMap<String, Location>();
//Scoreboard // Scoreboard
protected GameScoreboard Scoreboard; protected GameScoreboard Scoreboard;
//Loaded from Map Config // Loaded from Map Config
public WorldData WorldData = null; public WorldData WorldData = null;
//Game Help // Game Help
private long _helpTimer = 0; private long _helpTimer = 0;
private int _helpIndex = 0; private int _helpIndex = 0;
private ChatColor _helpColor = ChatColor.YELLOW; private ChatColor _helpColor = ChatColor.YELLOW;
protected String[] _help; protected String[] _help;
//Gameplay Flags // Gameplay Flags
public long GameTimeout = 1200000; public long GameTimeout = 1200000;
public boolean Damage = true; public boolean Damage = true;
@ -253,7 +248,7 @@ public abstract class Game implements Listener
public boolean DontAllowOverfill = false; public boolean DontAllowOverfill = false;
//Addons // Addons
public boolean CompassEnabled = false; public boolean CompassEnabled = false;
public boolean CompassGiveItem = true; public boolean CompassGiveItem = true;
@ -268,7 +263,7 @@ public abstract class Game implements Listener
public long PrepareTime = 9000; public long PrepareTime = 9000;
public boolean PlaySoundGameStart = true; public boolean PlaySoundGameStart = true;
//Gems // Gems
public double GemMultiplier = 1; public double GemMultiplier = 1;
public boolean GemHunterEnabled = true; public boolean GemHunterEnabled = true;
public boolean GemBoosterEnabled = true; public boolean GemBoosterEnabled = true;
@ -280,7 +275,7 @@ public abstract class Game implements Listener
public double GemKillDeathOut = 4; public double GemKillDeathOut = 4;
public double GemAssistDeathOut = 1; public double GemAssistDeathOut = 1;
//Gameplay Data // Gameplay Data
public HashMap<Location, Player> PrivateBlockMap = new HashMap<Location, Player>(); public HashMap<Location, Player> PrivateBlockMap = new HashMap<Location, Player>();
public HashMap<String, Integer> PrivateBlockCount = new HashMap<String, Integer>(); public HashMap<String, Integer> PrivateBlockCount = new HashMap<String, Integer>();
@ -306,7 +301,6 @@ public abstract class Game implements Listener
public int DeadBodiesExpire = -1; public int DeadBodiesExpire = -1;
private IPacketHandler _useEntityPacketHandler; private IPacketHandler _useEntityPacketHandler;
protected Field PacketTeam;
private int _deadBodyCount; private int _deadBodyCount;
private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>(); private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>();
private NautHashMap<String, Long> _deadBodiesExpire = new NautHashMap<String, Long>(); private NautHashMap<String, Long> _deadBodiesExpire = new NautHashMap<String, Long>();
@ -318,22 +312,23 @@ public abstract class Game implements Listener
{ {
Manager = manager; Manager = manager;
//Player List // Player List
UtilTabTitle.broadcastHeaderAndFooter(C.cGold + C.Bold + gameType.GetName(), "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); UtilTabTitle.broadcastHeaderAndFooter(C.cGold + C.Bold + gameType.GetName(), "Visit " + C.cGreen + "www.mineplex.com"
+ ChatColor.RESET + " for News, Forums and Shop");
//Game // Game
_gameType = gameType; _gameType = gameType;
_gameDesc = gameDesc; _gameDesc = gameDesc;
//Kits // Kits
_kits = kits; _kits = kits;
//Scoreboard // Scoreboard
Scoreboard = new GameScoreboard(this); Scoreboard = new GameScoreboard(this);
//Map Select // Map Select
_files = new HashMap<GameType, ArrayList<String>>(); _files = new HashMap<GameType, ArrayList<String>>();
for(GameType type : GetWorldHostNames()) for (GameType type : GetWorldHostNames())
{ {
_files.put(type, Manager.LoadFiles(type.GetName())); _files.put(type, Manager.LoadFiles(type.GetName()));
} }
@ -345,11 +340,11 @@ public abstract class Game implements Listener
for (GameType game : _files.keySet()) for (GameType game : _files.keySet())
{ {
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<String>();
for(String cur : _files.get(game)) for (String cur : _files.get(game))
{ {
if (cur.toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase())) if (cur.toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase()))
{ {
if(game.GetName().toLowerCase().contains(Manager.GetGameCreationManager().MapSource.toLowerCase())) if (game.GetName().toLowerCase().contains(Manager.GetGameCreationManager().MapSource.toLowerCase()))
{ {
list.add(cur); list.add(cur);
System.out.print("Map Preference: " + cur); System.out.print("Map Preference: " + cur);
@ -371,33 +366,13 @@ public abstract class Game implements Listener
} }
WorldData = new WorldData(this); WorldData = new WorldData(this);
//Stat Trackers // Stat Trackers
registerStatTrackers( registerStatTrackers(new KillsStatTracker(this), new DeathsStatTracker(this), new AssistsStatTracker(this),
new KillsStatTracker(this), new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker(
new DeathsStatTracker(this), this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this));
new AssistsStatTracker(this),
new ExperienceStatTracker(this),
new WinStatTracker(this),
new LoseStatTracker(this),
new DamageDealtStatTracker(this),
new DamageTakenStatTracker(this),
new GamesPlayedStatTracker(this)
);
Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack()); Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack());
try
{
PacketTeam = Class.forName(
"org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftTeam")
.getDeclaredField("team");
PacketTeam.setAccessible(true);
}
catch (Exception ex)
{
ex.printStackTrace();
}
_useEntityPacketHandler = new IPacketHandler() _useEntityPacketHandler = new IPacketHandler()
{ {
@Override @Override
@ -405,9 +380,8 @@ public abstract class Game implements Listener
{ {
if (packetInfo.getPacket() instanceof PacketPlayInUseEntity) if (packetInfo.getPacket() instanceof PacketPlayInUseEntity)
{ {
net.minecraft.server.v1_8_R3.Entity entity = ((PacketPlayInUseEntity) packetInfo net.minecraft.server.v1_8_R3.Entity entity = ((PacketPlayInUseEntity) packetInfo.getPacket())
.getPacket()).a(((CraftWorld) packetInfo .a(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle());
.getPlayer().getWorld()).getHandle());
if (entity instanceof EntityItem) if (entity instanceof EntityItem)
{ {
@ -437,14 +411,17 @@ public abstract class Game implements Listener
public GameType[] GetWorldHostNames() public GameType[] GetWorldHostNames()
{ {
GameType[] mapSource = new GameType[]{GetType()}; GameType[] mapSource = new GameType[]
if(GetType().getMapSource() != null)
{ {
if(GetType().ownMaps()) GetType()
};
if (GetType().getMapSource() != null)
{
if (GetType().ownMaps())
{ {
int i = 1; int i = 1;
mapSource = new GameType[GetType().getMapSource().length + 1]; mapSource = new GameType[GetType().getMapSource().length + 1];
for(GameType type : GetType().getMapSource()) for (GameType type : GetType().getMapSource())
{ {
mapSource[i] = type; mapSource[i] = type;
i++; i++;
@ -461,13 +438,13 @@ public abstract class Game implements Listener
public String GetGameNamebyMap(String game, String map) public String GetGameNamebyMap(String game, String map)
{ {
for(GameType type : _files.keySet()) for (GameType type : _files.keySet())
{ {
if(type.GetName().toLowerCase().contains(game.toLowerCase())) if (type.GetName().toLowerCase().contains(game.toLowerCase()))
{ {
for(String string : _files.get(type)) for (String string : _files.get(type))
{ {
if(string.toLowerCase().contains(map.toLowerCase())) if (string.toLowerCase().contains(map.toLowerCase()))
{ {
return type.GetName(); return type.GetName();
} }
@ -479,9 +456,9 @@ public abstract class Game implements Listener
public GameType GetGameByMapList(ArrayList<String> maps) public GameType GetGameByMapList(ArrayList<String> maps)
{ {
for(GameType game : _files.keySet()) for (GameType game : _files.keySet())
{ {
if(maps.equals(_files.get(game))) if (maps.equals(_files.get(game)))
{ {
return game; return game;
} }
@ -580,7 +557,7 @@ public abstract class Game implements Listener
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
player.leaveVehicle(); player.leaveVehicle();
//Event // Event
GameStateChangeEvent stateEvent = new GameStateChangeEvent(this, state); GameStateChangeEvent stateEvent = new GameStateChangeEvent(this, state);
UtilServer.getServer().getPluginManager().callEvent(stateEvent); UtilServer.getServer().getPluginManager().callEvent(stateEvent);
@ -609,7 +586,7 @@ public abstract class Game implements Listener
public void AddTeam(GameTeam team) public void AddTeam(GameTeam team)
{ {
//Add // Add
GetTeamList().add(team); GetTeamList().add(team);
System.out.println("Created Team: " + team.GetName()); System.out.println("Created Team: " + team.GetName());
@ -632,7 +609,7 @@ public abstract class Game implements Listener
public void RestrictKits() public void RestrictKits()
{ {
//Null Default // Null Default
} }
public void RegisterKits() public void RegisterKits()
@ -643,8 +620,7 @@ public abstract class Game implements Listener
for (Perk perk : kit.GetPerks()) for (Perk perk : kit.GetPerks())
{ {
UtilServer.getServer().getPluginManager() UtilServer.getServer().getPluginManager().registerEvents(perk, Manager.getPlugin());
.registerEvents(perk, Manager.getPlugin());
perk.registeredEvents(); perk.registeredEvents();
} }
} }
@ -666,13 +642,13 @@ public abstract class Game implements Listener
public void ParseData() public void ParseData()
{ {
//Nothing by default, // Nothing by default,
//Use this to parse in extra location data from maps // Use this to parse in extra location data from maps
} }
public void SetPlayerTeam(Player player, GameTeam team, boolean in) public void SetPlayerTeam(Player player, GameTeam team, boolean in)
{ {
//Clean Old Team // Clean Old Team
GameTeam pastTeam = this.GetTeam(player); GameTeam pastTeam = this.GetTeam(player);
if (pastTeam != null) if (pastTeam != null)
{ {
@ -681,16 +657,16 @@ public abstract class Game implements Listener
team.AddPlayer(player, in); team.AddPlayer(player, in);
//Ensure Valid Kit // Ensure Valid Kit
ValidateKit(player, team); ValidateKit(player, team);
//Game Scoreboard // Game Scoreboard
Scoreboard.SetPlayerTeam(player, team.GetName().toUpperCase()); Scoreboard.SetPlayerTeam(player, team.GetName().toUpperCase());
//Lobby Scoreboard // Lobby Scoreboard
Manager.GetLobby().AddPlayerToScoreboards(player, team.GetName().toUpperCase()); Manager.GetLobby().AddPlayerToScoreboards(player, team.GetName().toUpperCase());
//Save Tournament Team // Save Tournament Team
Manager.GetGameTournamentManager().setTournamentTeam(player, team); Manager.GetGameTournamentManager().setTournamentTeam(player, team);
} }
@ -709,7 +685,7 @@ public abstract class Game implements Listener
GameTeam team = null; GameTeam team = null;
//Random Team // Random Team
for (int i = 0; i < _teamList.size(); i++) for (int i = 0; i < _teamList.size(); i++)
{ {
if (team == null || _teamList.get(i).GetSize() < team.GetSize()) if (team == null || _teamList.get(i).GetSize() < team.GetSize())
@ -772,13 +748,12 @@ public abstract class Game implements Listener
public void ValidateKit(Player player, GameTeam team) public void ValidateKit(Player player, GameTeam team)
{ {
//Kit // Kit
if (GetKit(player) == null || !team.KitAllowed(GetKit(player))) if (GetKit(player) == null || !team.KitAllowed(GetKit(player)))
{ {
for (Kit kit : _kits) for (Kit kit : _kits)
{ {
if (kit.GetAvailability() == KitAvailability.Hide || if (kit.GetAvailability() == KitAvailability.Hide || kit.GetAvailability() == KitAvailability.Null)
kit.GetAvailability() == KitAvailability.Null)
continue; continue;
if (team.KitAllowed(kit)) if (team.KitAllowed(kit))
@ -798,7 +773,10 @@ public abstract class Game implements Listener
if (!team.KitAllowed(kit)) if (!team.KitAllowed(kit))
{ {
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 0.5f); player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 0.5f);
UtilPlayer.message(player, F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit") + ".")); UtilPlayer.message(
player,
F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit")
+ "."));
return; return;
} }
} }
@ -863,7 +841,7 @@ public abstract class Game implements Listener
team.SetPlayerState(player, state); team.SetPlayerState(player, state);
//Event // Event
PlayerStateChangeEvent playerStateEvent = new PlayerStateChangeEvent(this, player, PlayerState.OUT); PlayerStateChangeEvent playerStateEvent = new PlayerStateChangeEvent(this, player, PlayerState.OUT);
UtilServer.getServer().getPluginManager().callEvent(playerStateEvent); UtilServer.getServer().getPluginManager().callEvent(playerStateEvent);
@ -879,11 +857,11 @@ public abstract class Game implements Listener
Manager.Clear(player); Manager.Clear(player);
//Event // Event
PlayerGameRespawnEvent event = new PlayerGameRespawnEvent(this, player); PlayerGameRespawnEvent event = new PlayerGameRespawnEvent(this, player);
UtilServer.getServer().getPluginManager().callEvent(event); UtilServer.getServer().getPluginManager().callEvent(event);
//Re-Give Kit // Re-Give Kit
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
{ {
public void run() public void run()
@ -902,7 +880,7 @@ public abstract class Game implements Listener
{ {
if (entity instanceof Player) if (entity instanceof Player)
{ {
Player player = (Player)entity; Player player = (Player) entity;
GameTeam team = GetTeam(player); GameTeam team = GetTeam(player);
@ -980,15 +958,16 @@ public abstract class Game implements Listener
SpectatorSpawn.setY(vec.getY()); SpectatorSpawn.setY(vec.getY());
SpectatorSpawn.setZ(vec.getZ()); SpectatorSpawn.setZ(vec.getZ());
//Move Up - Out Of Blocks // Move Up - Out Of Blocks
while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock()) || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock())
|| !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP)))
{ {
SpectatorSpawn.add(0, 1, 0); SpectatorSpawn.add(0, 1, 0);
} }
int Up = 0; int Up = 0;
//Move Up - Through Air // Move Up - Through Air
for (int i = 0; i < 15; i++) for (int i = 0; i < 15; i++)
{ {
if (UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) if (UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP)))
@ -1002,8 +981,9 @@ public abstract class Game implements Listener
} }
} }
//Move Down - Out Of Blocks // Move Down - Out Of Blocks
while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock()) || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock())
|| !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP)))
{ {
SpectatorSpawn.subtract(0, 1, 0); SpectatorSpawn.subtract(0, 1, 0);
Up--; Up--;
@ -1045,13 +1025,15 @@ public abstract class Game implements Listener
public boolean CanJoinTeam(GameTeam team) public boolean CanJoinTeam(GameTeam team)
{ {
return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size()) : true; return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size())
: true;
} }
@EventHandler @EventHandler
public final void onFoodLevelChangeEvent(FoodLevelChangeEvent event) public final void onFoodLevelChangeEvent(FoodLevelChangeEvent event)
{ {
((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original food level changes ((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original
// food level changes
} }
public GameTeam GetTeamPreference(Player player) public GameTeam GetTeamPreference(Player player)
@ -1091,7 +1073,11 @@ public abstract class Game implements Listener
{ {
for (Player player : _teamPreference.get(team)) for (Player player : _teamPreference.get(team))
{ {
UtilPlayer.message(player, F.main("Team", "You are " + F.elem(GetTeamQueuePosition(player)) + " in queue for " + F.elem(team.GetFormattedName() + " Team") + ".")); UtilPlayer.message(
player,
F.main("Team",
"You are " + F.elem(GetTeamQueuePosition(player)) + " in queue for "
+ F.elem(team.GetFormattedName() + " Team") + "."));
} }
} }
} }
@ -1123,7 +1109,8 @@ public abstract class Game implements Listener
} }
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cGreen + "Map - " + C.cYellow + C.Bold + WorldData.MapName + ChatColor.RESET + C.cGray + " created by " + C.cYellow + C.Bold + WorldData.MapAuthor); UtilPlayer.message(player, C.cGreen + "Map - " + C.cYellow + C.Bold + WorldData.MapName + ChatColor.RESET + C.cGray
+ " created by " + C.cYellow + C.Bold + WorldData.MapAuthor);
UtilPlayer.message(player, ArcadeFormat.Line); UtilPlayer.message(player, ArcadeFormat.Line);
} }
@ -1162,10 +1149,10 @@ public abstract class Game implements Listener
UtilPlayer.message(player, "Nobody won the game!"); UtilPlayer.message(player, "Nobody won the game!");
} }
UtilPlayer.message(player, _customWinLine); UtilPlayer.message(player, _customWinLine);
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l" + WorldData.MapAuthor); UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l"
+ WorldData.MapAuthor);
UtilPlayer.message(player, ArcadeFormat.Line); UtilPlayer.message(player, ArcadeFormat.Line);
} }
@ -1209,13 +1196,11 @@ public abstract class Game implements Listener
UtilPlayer.message(player, C.cRed + C.Bold + "1st Place" + C.cWhite + " - " + places.get(0).getName()); UtilPlayer.message(player, C.cRed + C.Bold + "1st Place" + C.cWhite + " - " + places.get(0).getName());
} }
if (places.size() >= 2) if (places.size() >= 2)
{ {
UtilPlayer.message(player, C.cGold + C.Bold + "2nd Place" + C.cWhite + " - " + places.get(1).getName()); UtilPlayer.message(player, C.cGold + C.Bold + "2nd Place" + C.cWhite + " - " + places.get(1).getName());
} }
if (places.size() >= 3) if (places.size() >= 3)
{ {
UtilPlayer.message(player, C.cYellow + C.Bold + "3rd Place" + C.cWhite + " - " + places.get(2).getName()); UtilPlayer.message(player, C.cYellow + C.Bold + "3rd Place" + C.cWhite + " - " + places.get(2).getName());
@ -1223,7 +1208,8 @@ public abstract class Game implements Listener
} }
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l" + WorldData.MapAuthor); UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l"
+ WorldData.MapAuthor);
UtilPlayer.message(player, ArcadeFormat.Line); UtilPlayer.message(player, ArcadeFormat.Line);
} }
@ -1234,7 +1220,6 @@ public abstract class Game implements Listener
Manager.GetChat().Silence(5000, false); Manager.GetChat().Silence(5000, false);
} }
public void Announce(String message) public void Announce(String message)
{ {
if (message == null) if (message == null)
@ -1344,17 +1329,22 @@ public abstract class Game implements Listener
return; return;
} }
Announce(F.elem(player.getName()) + " used a " + F.elem(C.cGreen + "Gem Booster") + " for " + F.elem("+" + (100 - (GemBoosters.size() * 25)) + "% Gems") + "!"); Announce(F.elem(player.getName()) + " used a " + F.elem(C.cGreen + "Gem Booster") + " for "
+ F.elem("+" + (100 - (GemBoosters.size() * 25)) + "% Gems") + "!");
GemBoosters.add(player.getName()); GemBoosters.add(player.getName());
} }
public double GetGemBoostAmount() public double GetGemBoostAmount()
{ {
if (GemBoosters.size() == 1) return 1; if (GemBoosters.size() == 1)
if (GemBoosters.size() == 2) return 1.75; return 1;
if (GemBoosters.size() == 3) return 2.25; if (GemBoosters.size() == 2)
if (GemBoosters.size() == 4) return 2.5; return 1.75;
if (GemBoosters.size() == 3)
return 2.25;
if (GemBoosters.size() == 4)
return 2.5;
return 0; return 0;
} }
@ -1400,8 +1390,6 @@ public abstract class Game implements Listener
} }
} }
public Collection<StatTracker<? extends Game>> getStatTrackers() public Collection<StatTracker<? extends Game>> getStatTrackers()
{ {
return _statTrackers; return _statTrackers;
@ -1454,13 +1442,8 @@ public abstract class Game implements Listener
public boolean isInsideMap(Location loc) public boolean isInsideMap(Location loc)
{ {
return !( return !(loc.getX() >= WorldData.MaxX + 1 || loc.getX() <= WorldData.MinX || loc.getZ() >= WorldData.MaxZ + 1
loc.getX() >= WorldData.MaxX + 1 || || loc.getZ() <= WorldData.MinZ || loc.getY() >= WorldData.MaxY + 1 || loc.getY() <= WorldData.MinY);
loc.getX() <= WorldData.MinX ||
loc.getZ() >= WorldData.MaxZ + 1 ||
loc.getZ() <= WorldData.MinZ ||
loc.getY() >= WorldData.MaxY + 1 ||
loc.getY() <= WorldData.MinY);
} }
public void setItemMerge(boolean itemMerge) public void setItemMerge(boolean itemMerge)
@ -1497,7 +1480,7 @@ public abstract class Game implements Listener
{ {
Manager.GetGameCreationManager().SetNextGameType(gameType); Manager.GetGameCreationManager().SetNextGameType(gameType);
//End Current // End Current
if (GetState() == GameState.Recruit) if (GetState() == GameState.Recruit)
{ {
SetState(GameState.Dead); SetState(GameState.Dead);
@ -1529,7 +1512,7 @@ public abstract class Game implements Listener
AddGems(player, 10, "Participation", false, false); AddGems(player, 10, "Participation", false, false);
} }
//End // End
SetState(GameState.End); SetState(GameState.End);
} }
@ -1538,46 +1521,11 @@ public abstract class Game implements Listener
{ {
if (event.GetState() == GameState.Live) if (event.GetState() == GameState.Live)
{ {
getArcadeManager().getPacketHandler().addPacketHandler( getArcadeManager().getPacketHandler().addPacketHandler(_useEntityPacketHandler, PacketPlayInUseEntity.class);
_useEntityPacketHandler, PacketPlayInUseEntity.class);
} }
else if (event.GetState() == GameState.Dead) else if (event.GetState() == GameState.Dead)
{ {
getArcadeManager().getPacketHandler().removePacketHandler( getArcadeManager().getPacketHandler().removePacketHandler(_useEntityPacketHandler);
_useEntityPacketHandler);
}
}
@EventHandler
public void onDeadBodyJoin(PlayerJoinEvent event)
{
for (int i = 0; i < _deadBodyCount; i++)
{
String name = "";
for (char c : ("" + i).toCharArray())
{
name += "§" + c;
}
try
{
Team team = Scoreboard.GetScoreboard().getTeam(name);
if (team == null)
{
continue;
}
PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(
(ScoreboardTeam) PacketTeam.get(team), 2);
UtilPlayer.sendPacket(event.getPlayer(), packet);
}
catch (Exception ex)
{
ex.printStackTrace();
}
} }
} }
@ -1628,43 +1576,21 @@ public abstract class Game implements Listener
return; return;
} }
String name = ""; String name = "Body #" + _deadBodyCount++;
for (char c : ("" + _deadBodyCount++).toCharArray()) Team team = Scoreboard.GetScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBodies");
{
name += "§" + c;
}
try
{
Team team = Scoreboard.GetScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBody");
if (team == null) if (team == null)
{ {
team = Scoreboard.GetScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBody"); team = Scoreboard.GetScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies");
}
team.setNameTagVisibility(NameTagVisibility.NEVER); team.setNameTagVisibility(NameTagVisibility.NEVER);
}
team.addEntry(name); team.addEntry(name);
PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(
(ScoreboardTeam) PacketTeam.get(team), 2);
for (Player alive : GetPlayers(false))
{
UtilPlayer.sendPacket(alive, packet);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
GameProfile newProfile = new GameProfile(UUID.randomUUID(), name); GameProfile newProfile = new GameProfile(UUID.randomUUID(), name);
newProfile.getProperties() newProfile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties());
.putAll(((CraftPlayer) player).getHandle().getProfile()
.getProperties());
DisguisePlayer disguise = new DisguisePlayer(null, newProfile); DisguisePlayer disguise = new DisguisePlayer(null, newProfile);
@ -1675,10 +1601,8 @@ public abstract class Game implements Listener
Location loc = player.getLocation(); Location loc = player.getLocation();
WorldServer world = ((CraftWorld) loc.getWorld()).getHandle(); WorldServer world = ((CraftWorld) loc.getWorld()).getHandle();
EntityItem nmsItem = new EntityItem(world, loc.getX(), EntityItem nmsItem = new EntityItem(world, loc.getX(), loc.getY() + 0.5, loc.getZ(),
loc.getY() + 0.5, loc.getZ(), CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE).setTitle(System.currentTimeMillis() + "").build()));
CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE)
.setTitle(System.currentTimeMillis() + "").build()));
nmsItem.motX = 0; nmsItem.motX = 0;
nmsItem.motY = 0; nmsItem.motY = 0;
@ -1695,8 +1619,7 @@ public abstract class Game implements Listener
if (DeadBodiesExpire > 0) if (DeadBodiesExpire > 0)
{ {
_deadBodiesExpire.put(player.getName(), System.currentTimeMillis() _deadBodiesExpire.put(player.getName(), System.currentTimeMillis() + (DeadBodiesExpire * 1000));
+ (DeadBodiesExpire * 1000));
} }
} }
@ -1732,37 +1655,36 @@ public abstract class Game implements Listener
{ {
Block block = loc.getBlock(); Block block = loc.getBlock();
while (block.getY() > 0 while (block.getY() > 0 && !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))
&& !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))
&& !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) && !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
{ {
block = block.getRelative(BlockFace.DOWN); block = block.getRelative(BlockFace.DOWN);
} }
BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3] BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3].getOppositeFace();
.getOppositeFace();
// A complicated way to get the face the dead body should be towards. // A complicated way to get the face the dead body should be towards.
for (HashSet<Byte> validBlocks : new HashSet[] for (HashSet<Byte> validBlocks : new HashSet[]
{ {
UtilBlock.blockAirFoliageSet, UtilBlock.blockPassSet UtilBlock.blockAirFoliageSet,
UtilBlock.blockPassSet
}) })
{ {
if (validBlocks.contains((byte) block.getRelative(proper) if (validBlocks.contains((byte) block.getRelative(proper).getTypeId()))
.getTypeId()))
{ {
return proper; return proper;
} }
for (BlockFace face : new BlockFace[] for (BlockFace face : new BlockFace[]
{ {
BlockFace.EAST, BlockFace.SOUTH, BlockFace.NORTH, BlockFace.EAST,
BlockFace.SOUTH,
BlockFace.NORTH,
BlockFace.WEST BlockFace.WEST
}) })
{ {
if (validBlocks.contains((byte) block.getRelative(face) if (validBlocks.contains((byte) block.getRelative(face).getTypeId()))
.getTypeId()))
{ {
return face; return face;
} }
@ -1780,8 +1702,7 @@ public abstract class Game implements Listener
return; return;
} }
Iterator<Entry<String, Long>> itel = _deadBodiesExpire.entrySet() Iterator<Entry<String, Long>> itel = _deadBodiesExpire.entrySet().iterator();
.iterator();
while (itel.hasNext()) while (itel.hasNext())
{ {

View File

@ -97,7 +97,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction; import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction;
import net.minecraft.server.v1_8_R3.ScoreboardTeam; import net.minecraft.server.v1_8_R3.ScoreboardTeam;
import net.minecraft.server.v1_8_R3.WorldServer; import net.minecraft.server.v1_8_R3.WorldServer;
import net.minecraft.server.v1_8_R3.WorldBorder;
public abstract class SurvivalGames extends Game public abstract class SurvivalGames extends Game
{ {
@ -643,7 +642,10 @@ public abstract class SurvivalGames extends Game
border); border);
} }
setBorder(); _borderStartedMoving = System.currentTimeMillis();
WorldBorder border = WorldData.World.getWorldBorder();
border.setSize(_currentBorder * 2, 1);
_deathMatchTime = 11; _deathMatchTime = 11;
} }
@ -876,31 +878,6 @@ public abstract class SurvivalGames extends Game
}.runTaskTimer(getArcadeManager().getPlugin(), 0, 60); }.runTaskTimer(getArcadeManager().getPlugin(), 0, 60);
} }
@EventHandler
public void onGameState(GameStateChangeEvent event)
{
if (GetState() != GameState.Live)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
setupBorder(player);
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
if (!IsLive())
{
return;
}
setupBorder(event.getPlayer());
}
@EventHandler @EventHandler
public void onSecond(UpdateEvent event) public void onSecond(UpdateEvent event)
{ {
@ -921,7 +898,10 @@ public abstract class SurvivalGames extends Game
{ {
_currentBorder = _borderPositions.get(_secondsSinceStart); _currentBorder = _borderPositions.get(_secondsSinceStart);
setBorder(); _borderStartedMoving = System.currentTimeMillis();
WorldBorder border = WorldData.World.getWorldBorder();
border.setSize(_currentBorder * 2, 1);
} }
_secondsSinceStart++; _secondsSinceStart++;
@ -1337,6 +1317,13 @@ public abstract class SurvivalGames extends Game
_supplyLocations = WorldData.GetDataLocs("WHITE"); _supplyLocations = WorldData.GetDataLocs("WHITE");
for (Location loc : _supplyLocations) for (Location loc : _supplyLocations)
loc.getBlock().setType(Material.GLASS); loc.getBlock().setType(Material.GLASS);
WorldBorder border = WorldData.World.getWorldBorder();
border.setCenter(_spawn);
border.setSize(_currentBorder * 2);
border.setDamageBuffer(-99);
border.setWarningDistance(-99);
border.setWarningTime(-99);
} }
@EventHandler @EventHandler
@ -1467,50 +1454,6 @@ public abstract class SurvivalGames extends Game
_hiddenNames.remove(event.getPlayer()); _hiddenNames.remove(event.getPlayer());
} }
private void setBorder()
{
_borderStartedMoving = System.currentTimeMillis();
WorldBorder border = new WorldBorder();
border.setCenter(_spawn.getX(), _spawn.getZ());
border.transitionSizeBetween(_previousBorder * 2, _currentBorder * 2,
_currentBorder != _previousBorder ? 1000 : 0);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border,
EnumWorldBorderAction.LERP_SIZE);
for (Player player : Bukkit.getOnlinePlayers())
{
UtilPlayer.sendPacket(player, packet);
}
}
private void setupBorder(Player player)
{
WorldBorder border = new WorldBorder();
border.transitionSizeBetween(
_previousBorder * 2,
_currentBorder * 2,
_currentBorder != _previousBorder ? 1000 - Math.min(1000,
(System.currentTimeMillis() - _borderStartedMoving))
: 0);
border.setCenter(_spawn.getX(), _spawn.getZ());
border.setWarningDistance(-10);
border.setWarningTime(-10);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border,
EnumWorldBorderAction.INITIALIZE);
// We don't set warnings speed or blocks as its not particularly useful
// for this game.
// Also if we don't use it here, its more effective in other places to
// reinforce the idea what its for.
UtilPlayer.sendPacket(player, packet);
}
private void setupChestsEnchantingCrafting() private void setupChestsEnchantingCrafting()
{ {
ArrayList<Location> chests = WorldData.GetCustomLocs("54"); ArrayList<Location> chests = WorldData.GetCustomLocs("54");

View File

@ -34,9 +34,6 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder;
import net.minecraft.server.v1_8_R3.WorldBorder;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -45,6 +42,7 @@ import org.bukkit.Difficulty;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.WorldBorder;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -231,6 +229,13 @@ public class UHC extends TeamGame
{ {
_borderPositions.put(i++ * 4, border); _borderPositions.put(i++ * 4, border);
} }
WorldBorder border = WorldData.World.getWorldBorder();
border.setCenter(0, 0);
border.setSize(_currentBorder * 2);
border.setDamageBuffer(-99);
border.setWarningDistance(-99);
border.setWarningTime(-99);
} }
@EventHandler @EventHandler
@ -270,28 +275,15 @@ public class UHC extends TeamGame
{ {
_currentBorder = _borderPositions.get(_secondsSinceStart); _currentBorder = _borderPositions.get(_secondsSinceStart);
setBorder(); _borderStartedMoving = System.currentTimeMillis();
WorldBorder border = WorldData.World.getWorldBorder();
border.setSize(_currentBorder * 2, 1);
} }
_secondsSinceStart++; _secondsSinceStart++;
} }
private void setBorder()
{
WorldBorder border = new WorldBorder();
border.transitionSizeBetween(_previousBorder * 2, _currentBorder * 2,
_currentBorder != _previousBorder ? 1000 : 0);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border,
EnumWorldBorderAction.LERP_SIZE);
for (Player player : Bukkit.getOnlinePlayers())
{
UtilPlayer.sendPacket(player, packet);
}
}
@EventHandler @EventHandler
public void outsideBorder(UpdateEvent event) public void outsideBorder(UpdateEvent event)
{ {
@ -349,53 +341,6 @@ public class UHC extends TeamGame
} }
} }
@EventHandler
public void onGameState(GameStateChangeEvent event)
{
if (GetState() != GameState.Live)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
setupBorder(player);
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
if (!IsLive())
{
return;
}
setupBorder(event.getPlayer());
}
private void setupBorder(Player player)
{
WorldBorder border = new WorldBorder();
border.transitionSizeBetween(
_previousBorder * 2,
_currentBorder * 2,
_currentBorder != _previousBorder ? 1000 - Math.min(1000,
(System.currentTimeMillis() - _borderStartedMoving))
: 0);
border.setWarningDistance(-10);
border.setWarningTime(-10);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border,
EnumWorldBorderAction.INITIALIZE);
// We don't set warnings speed or blocks as its not particularly useful for this game.
// Also if we don't use it here, its more effective in other places to reinforce the idea what its for.
UtilPlayer.sendPacket(player, packet);
}
private ArrayList<Double> buildBorders(int seconds, double border, double leaveRemaining) private ArrayList<Double> buildBorders(int seconds, double border, double leaveRemaining)
{ {
double totalNumber = Math.pow(seconds, 1.9D) + (seconds * 50); double totalNumber = Math.pow(seconds, 1.9D) + (seconds * 50);

View File

@ -115,6 +115,7 @@ public class WorldData
TimingManager.stop("WorldData loading world."); TimingManager.stop("WorldData loading world.");
World.setDifficulty(Difficulty.HARD); World.setDifficulty(Difficulty.HARD);
World.setGameRuleValue("showDeathmessages", "false");
TimingManager.start("WorldData loading WorldConfig."); TimingManager.start("WorldData loading WorldConfig.");
//Load World Data //Load World Data