diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 8123d0b96..3a5edd15d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -8,6 +8,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; 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.InventoryType; import org.bukkit.inventory.EnchantingInventory; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; @@ -174,7 +176,14 @@ public class InventoryManager extends MiniDbClientPlugin 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) @@ -198,6 +207,14 @@ public class InventoryManager extends MiniDbClientPlugin 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; } @@ -205,21 +222,45 @@ public class InventoryManager extends MiniDbClientPlugin } @EventHandler - public void onInventoryClick(InventoryClickEvent event) + public void onInventoryClick(final InventoryClickEvent event) { if (event.getView().getTopInventory().getType() != InventoryType.ENCHANTING) { 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; } - 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 diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index e20b1cf79..23dc523e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -100,24 +100,19 @@ public abstract class Game implements Listener public enum GameState { - Loading, - Recruit, - Prepare, - Live, - End, - Dead + Loading, Recruit, Prepare, Live, End, Dead } public ArcadeManager Manager; - //Game + // Game private GameType _gameType; protected String[] _gameDesc; - //Map + // Map private HashMap> _files; - //State + // State private GameState _gameState = GameState.Loading; private long _gameLiveTime; private long _gameStateTime = System.currentTimeMillis(); @@ -129,36 +124,36 @@ public abstract class Game implements Listener private String _customWinLine = ""; - //Kits + // Kits private Kit[] _kits; - //Teams + // Teams protected ArrayList _teamList = new ArrayList(); - //Player Preferences + // Player Preferences protected NautHashMap _playerKit = new NautHashMap(); private NautHashMap> _teamPreference = new NautHashMap>(); - //Player Data + // Player Data private NautHashMap> _gemCount = new NautHashMap>(); private NautHashMap> _stats = new NautHashMap>(); - //Player Location Store + // Player Location Store private NautHashMap _playerLocationStore = new NautHashMap(); - //Scoreboard + // Scoreboard protected GameScoreboard Scoreboard; - //Loaded from Map Config + // Loaded from Map Config public WorldData WorldData = null; - //Game Help + // Game Help private long _helpTimer = 0; private int _helpIndex = 0; private ChatColor _helpColor = ChatColor.YELLOW; protected String[] _help; - //Gameplay Flags + // Gameplay Flags public long GameTimeout = 1200000; public boolean Damage = true; @@ -203,7 +198,7 @@ public abstract class Game implements Listener public boolean QuitOut = true; public boolean QuitDropItems = false; - + public boolean IdleKickz = true; public boolean CreatureAllow = false; @@ -235,40 +230,40 @@ public abstract class Game implements Listener public GameState KitRegisterState = GameState.Live; public boolean JoinInProgress = false; - + public int TickPerTeleport = 1; - + public int FillTeamsInOrderToCount = -1; - + public boolean SpawnNearAllies = false; public boolean SpawnNearEnemies = false; - + public boolean StrictAntiHack = false; - + public boolean DisableKillCommand = true; - + public boolean GadgetsDisabled = true; - + public boolean TeleportsDisqualify = true; - + public boolean DontAllowOverfill = false; - //Addons + // Addons public boolean CompassEnabled = false; public boolean CompassGiveItem = true; public boolean SoupEnabled = true; public boolean TeamArmor = false; - public boolean TeamArmorHotbar = false; + public boolean TeamArmorHotbar = false; + + public boolean GiveClock = true; + + public boolean AllowParticles = true; - public boolean GiveClock = true; - - public boolean AllowParticles = true; - public long PrepareTime = 9000; public boolean PlaySoundGameStart = true; - - //Gems + + // Gems public double GemMultiplier = 1; public boolean GemHunterEnabled = true; public boolean GemBoosterEnabled = true; @@ -276,11 +271,11 @@ public abstract class Game implements Listener public double GemKillDeathRespawn = .5; public double GemAssistDeathRespawn = .5; - + public double GemKillDeathOut = 4; public double GemAssistDeathOut = 1; - - //Gameplay Data + + // Gameplay Data public HashMap PrivateBlockMap = new HashMap(); public HashMap PrivateBlockCount = new HashMap(); @@ -296,7 +291,7 @@ public abstract class Game implements Listener public boolean CanAddStats = true; public boolean CanGiveLoot = true; - + public boolean HideTeamSheep = false; public boolean ReplaceTeamsWithKits = false; @@ -306,7 +301,6 @@ public abstract class Game implements Listener public int DeadBodiesExpire = -1; private IPacketHandler _useEntityPacketHandler; - protected Field PacketTeam; private int _deadBodyCount; private NautHashMap _deadBodies = new NautHashMap(); private NautHashMap _deadBodiesExpire = new NautHashMap(); @@ -318,38 +312,39 @@ public abstract class Game implements Listener { Manager = manager; - //Player List - UtilTabTitle.broadcastHeaderAndFooter(C.cGold + C.Bold + gameType.GetName(), "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); - - //Game + // Player List + UtilTabTitle.broadcastHeaderAndFooter(C.cGold + C.Bold + gameType.GetName(), "Visit " + C.cGreen + "www.mineplex.com" + + ChatColor.RESET + " for News, Forums and Shop"); + + // Game _gameType = gameType; _gameDesc = gameDesc; - //Kits + // Kits _kits = kits; - //Scoreboard + // Scoreboard Scoreboard = new GameScoreboard(this); - //Map Select + // Map Select _files = new HashMap>(); - for(GameType type : GetWorldHostNames()) + for (GameType type : GetWorldHostNames()) { _files.put(type, Manager.LoadFiles(type.GetName())); } if (Manager.GetGameCreationManager().MapPref != null) { System.out.println("Map Preference: " + Manager.GetGameCreationManager().MapPref); - + HashMap> matches = new HashMap>(); for (GameType game : _files.keySet()) { ArrayList list = new ArrayList(); - for(String cur : _files.get(game)) + for (String cur : _files.get(game)) { 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); System.out.print("Map Preference: " + cur); @@ -371,32 +366,12 @@ public abstract class Game implements Listener } WorldData = new WorldData(this); - //Stat Trackers - registerStatTrackers( - new KillsStatTracker(this), - new DeathsStatTracker(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()); + // Stat Trackers + registerStatTrackers(new KillsStatTracker(this), new DeathsStatTracker(this), new AssistsStatTracker(this), + new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker( + this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this)); - try - { - PacketTeam = Class.forName( - "org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftTeam") - .getDeclaredField("team"); - PacketTeam.setAccessible(true); - } - catch (Exception ex) - { - ex.printStackTrace(); - } + Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack()); _useEntityPacketHandler = new IPacketHandler() { @@ -405,9 +380,8 @@ public abstract class Game implements Listener { if (packetInfo.getPacket() instanceof PacketPlayInUseEntity) { - net.minecraft.server.v1_8_R3.Entity entity = ((PacketPlayInUseEntity) packetInfo - .getPacket()).a(((CraftWorld) packetInfo - .getPlayer().getWorld()).getHandle()); + net.minecraft.server.v1_8_R3.Entity entity = ((PacketPlayInUseEntity) packetInfo.getPacket()) + .a(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle()); if (entity instanceof EntityItem) { @@ -434,23 +408,26 @@ public abstract class Game implements Listener { return _gameType.GetName(); } - + public GameType[] GetWorldHostNames() { - GameType[] mapSource = new GameType[]{GetType()}; - if(GetType().getMapSource() != null) + GameType[] mapSource = new GameType[] + { + GetType() + }; + if (GetType().getMapSource() != null) { - if(GetType().ownMaps()) + if (GetType().ownMaps()) { int i = 1; mapSource = new GameType[GetType().getMapSource().length + 1]; - for(GameType type : GetType().getMapSource()) + for (GameType type : GetType().getMapSource()) { mapSource[i] = type; i++; } mapSource[0] = GetType(); - } + } else { mapSource = GetType().getMapSource(); @@ -458,16 +435,16 @@ public abstract class Game implements Listener } return mapSource; } - + 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(); } @@ -476,12 +453,12 @@ public abstract class Game implements Listener } return null; } - - public GameType GetGameByMapList(ArrayList maps) + + public GameType GetGameByMapList(ArrayList 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; } @@ -580,7 +557,7 @@ public abstract class Game implements Listener for (Player player : UtilServer.getPlayers()) player.leaveVehicle(); - //Event + // Event GameStateChangeEvent stateEvent = new GameStateChangeEvent(this, state); UtilServer.getServer().getPluginManager().callEvent(stateEvent); @@ -609,7 +586,7 @@ public abstract class Game implements Listener public void AddTeam(GameTeam team) { - //Add + // Add GetTeamList().add(team); System.out.println("Created Team: " + team.GetName()); @@ -632,7 +609,7 @@ public abstract class Game implements Listener public void RestrictKits() { - //Null Default + // Null Default } public void RegisterKits() @@ -643,8 +620,7 @@ public abstract class Game implements Listener for (Perk perk : kit.GetPerks()) { - UtilServer.getServer().getPluginManager() - .registerEvents(perk, Manager.getPlugin()); + UtilServer.getServer().getPluginManager().registerEvents(perk, Manager.getPlugin()); perk.registeredEvents(); } } @@ -666,13 +642,13 @@ public abstract class Game implements Listener public void ParseData() { - //Nothing by default, - //Use this to parse in extra location data from maps + // Nothing by default, + // Use this to parse in extra location data from maps } public void SetPlayerTeam(Player player, GameTeam team, boolean in) { - //Clean Old Team + // Clean Old Team GameTeam pastTeam = this.GetTeam(player); if (pastTeam != null) { @@ -681,16 +657,16 @@ public abstract class Game implements Listener team.AddPlayer(player, in); - //Ensure Valid Kit + // Ensure Valid Kit ValidateKit(player, team); - //Game Scoreboard + // Game Scoreboard Scoreboard.SetPlayerTeam(player, team.GetName().toUpperCase()); - //Lobby Scoreboard + // Lobby Scoreboard Manager.GetLobby().AddPlayerToScoreboards(player, team.GetName().toUpperCase()); - //Save Tournament Team + // Save Tournament Team Manager.GetGameTournamentManager().setTournamentTeam(player, team); } @@ -706,10 +682,10 @@ public abstract class Game implements Listener } } } - + GameTeam team = null; - //Random Team + // Random Team for (int i = 0; i < _teamList.size(); i++) { if (team == null || _teamList.get(i).GetSize() < team.GetSize()) @@ -759,7 +735,7 @@ public abstract class Game implements Listener { if (!countAmount && gems < 1) gems = 1; - + if (GetGems(player).containsKey(reason) && multipleAllowed) { GetGems(player).get(reason).AddGems(gems); @@ -772,13 +748,12 @@ public abstract class Game implements Listener public void ValidateKit(Player player, GameTeam team) { - //Kit + // Kit if (GetKit(player) == null || !team.KitAllowed(GetKit(player))) { for (Kit kit : _kits) { - if (kit.GetAvailability() == KitAvailability.Hide || - kit.GetAvailability() == KitAvailability.Null) + if (kit.GetAvailability() == KitAvailability.Hide || kit.GetAvailability() == KitAvailability.Null) continue; if (team.KitAllowed(kit)) @@ -798,7 +773,10 @@ public abstract class Game implements Listener if (!team.KitAllowed(kit)) { 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; } } @@ -863,7 +841,7 @@ public abstract class Game implements Listener team.SetPlayerState(player, state); - //Event + // Event PlayerStateChangeEvent playerStateEvent = new PlayerStateChangeEvent(this, player, PlayerState.OUT); UtilServer.getServer().getPluginManager().callEvent(playerStateEvent); @@ -879,11 +857,11 @@ public abstract class Game implements Listener Manager.Clear(player); - //Event + // Event PlayerGameRespawnEvent event = new PlayerGameRespawnEvent(this, player); UtilServer.getServer().getPluginManager().callEvent(event); - //Re-Give Kit + // Re-Give Kit Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { public void run() @@ -902,8 +880,8 @@ public abstract class Game implements Listener { if (entity instanceof Player) { - Player player = (Player)entity; - + Player player = (Player) entity; + GameTeam team = GetTeam(player); if (team == null) @@ -911,7 +889,7 @@ public abstract class Game implements Listener return team.IsAlive(player); } - + return false; } @@ -980,15 +958,16 @@ public abstract class Game implements Listener SpectatorSpawn.setY(vec.getY()); SpectatorSpawn.setZ(vec.getZ()); - //Move Up - Out Of Blocks - while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock()) || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) + // Move Up - Out Of Blocks + while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock()) + || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) { SpectatorSpawn.add(0, 1, 0); } int Up = 0; - //Move Up - Through Air + // Move Up - Through Air for (int i = 0; i < 15; i++) { if (UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) @@ -1002,8 +981,9 @@ public abstract class Game implements Listener } } - //Move Down - Out Of Blocks - while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock()) || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) + // Move Down - Out Of Blocks + while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock()) + || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP))) { SpectatorSpawn.subtract(0, 1, 0); Up--; @@ -1045,13 +1025,15 @@ public abstract class Game implements Listener 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 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) @@ -1091,7 +1073,11 @@ public abstract class Game implements Listener { 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, 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); } @@ -1135,7 +1122,7 @@ public abstract class Game implements Listener String winnerText = ChatColor.WHITE + "Nobody"; ChatColor subColor = ChatColor.WHITE; - + for (Player player : UtilServer.getPlayers()) { player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f); @@ -1152,9 +1139,9 @@ public abstract class Game implements Listener WinnerTeam = team; Winner = team.GetName() + " Team"; - winnerText = team.GetColor() + team.GetName(); + winnerText = team.GetColor() + team.GetName(); subColor = team.GetColor(); - + UtilPlayer.message(player, team.GetColor() + C.Bold + team.GetName() + " won the game!"); } else @@ -1162,10 +1149,10 @@ public abstract class Game implements Listener UtilPlayer.message(player, "Nobody won the game!"); } - UtilPlayer.message(player, _customWinLine); 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); } @@ -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()); } - if (places.size() >= 2) { UtilPlayer.message(player, C.cGold + C.Bold + "2nd Place" + C.cWhite + " - " + places.get(1).getName()); } - if (places.size() >= 3) { 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, "§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); } @@ -1234,12 +1220,11 @@ public abstract class Game implements Listener Manager.GetChat().Silence(5000, false); } - public void Announce(String message) { if (message == null) return; - + Announce(message, true); } @@ -1331,7 +1316,7 @@ public abstract class Game implements Listener UtilPlayer.message(player, F.main("Game", "You cannot use " + F.elem("Gem Boosters")) + " for this game."); return; } - + if (GemBoosters.size() >= 4) { UtilPlayer.message(player, F.main("Game", "Games cannot have more than " + F.elem("4 Gem Boosters")) + "."); @@ -1344,17 +1329,22 @@ public abstract class Game implements Listener 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()); } public double GetGemBoostAmount() { - if (GemBoosters.size() == 1) return 1; - if (GemBoosters.size() == 2) return 1.75; - if (GemBoosters.size() == 3) return 2.25; - if (GemBoosters.size() == 4) return 2.5; + if (GemBoosters.size() == 1) + return 1; + if (GemBoosters.size() == 2) + return 1.75; + if (GemBoosters.size() == 3) + return 2.25; + if (GemBoosters.size() == 4) + return 2.5; return 0; } @@ -1400,8 +1390,6 @@ public abstract class Game implements Listener } } - - public Collection> getStatTrackers() { return _statTrackers; @@ -1440,7 +1428,7 @@ public abstract class Game implements Listener { return Manager; } - + @EventHandler public void classCombatCreatureAllow(ClassCombatCreatureAllowSpawnEvent event) { @@ -1454,13 +1442,8 @@ public abstract class Game implements Listener public boolean isInsideMap(Location loc) { - return !( - loc.getX() >= WorldData.MaxX + 1 || - loc.getX() <= WorldData.MinX || - loc.getZ() >= WorldData.MaxZ + 1 || - loc.getZ() <= WorldData.MinZ || - loc.getY() >= WorldData.MaxY + 1 || - loc.getY() <= WorldData.MinY); + return !(loc.getX() >= WorldData.MaxX + 1 || 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) @@ -1497,7 +1480,7 @@ public abstract class Game implements Listener { Manager.GetGameCreationManager().SetNextGameType(gameType); - //End Current + // End Current if (GetState() == GameState.Recruit) { SetState(GameState.Dead); @@ -1511,26 +1494,26 @@ public abstract class Game implements Listener Announce(C.cAqua + C.Bold + caller.getName() + " set next game to " + gameType.GetName() + "."); } } - - public void endGame(GameTeam winningTeam) + + public void endGame(GameTeam winningTeam) { - AnnounceEnd(winningTeam); + AnnounceEnd(winningTeam); - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { - for (Player player : team.GetPlayers(false)) - AddGems(player, 10, "Winning Team", false, false); - } + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } - //End - SetState(GameState.End); + // End + SetState(GameState.End); } @EventHandler @@ -1538,46 +1521,11 @@ public abstract class Game implements Listener { if (event.GetState() == GameState.Live) { - getArcadeManager().getPacketHandler().addPacketHandler( - _useEntityPacketHandler, PacketPlayInUseEntity.class); + getArcadeManager().getPacketHandler().addPacketHandler(_useEntityPacketHandler, PacketPlayInUseEntity.class); } else if (event.GetState() == GameState.Dead) { - getArcadeManager().getPacketHandler().removePacketHandler( - _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(); - } + getArcadeManager().getPacketHandler().removePacketHandler(_useEntityPacketHandler); } } @@ -1628,43 +1576,21 @@ public abstract class Game implements Listener return; } - String name = ""; + String name = "Body #" + _deadBodyCount++; - for (char c : ("" + _deadBodyCount++).toCharArray()) + Team team = Scoreboard.GetScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBodies"); + + if (team == null) { - name += "§" + c; - } - - try - { - Team team = Scoreboard.GetScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBody"); - - if (team == null) - { - team = Scoreboard.GetScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBody"); - } - + team = Scoreboard.GetScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies"); team.setNameTagVisibility(NameTagVisibility.NEVER); - 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(); } + team.addEntry(name); + GameProfile newProfile = new GameProfile(UUID.randomUUID(), name); - newProfile.getProperties() - .putAll(((CraftPlayer) player).getHandle().getProfile() - .getProperties()); + newProfile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties()); DisguisePlayer disguise = new DisguisePlayer(null, newProfile); @@ -1675,10 +1601,8 @@ public abstract class Game implements Listener Location loc = player.getLocation(); WorldServer world = ((CraftWorld) loc.getWorld()).getHandle(); - EntityItem nmsItem = new EntityItem(world, loc.getX(), - loc.getY() + 0.5, loc.getZ(), - CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE) - .setTitle(System.currentTimeMillis() + "").build())); + EntityItem nmsItem = new EntityItem(world, loc.getX(), loc.getY() + 0.5, loc.getZ(), + CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE).setTitle(System.currentTimeMillis() + "").build())); nmsItem.motX = 0; nmsItem.motY = 0; @@ -1695,8 +1619,7 @@ public abstract class Game implements Listener if (DeadBodiesExpire > 0) { - _deadBodiesExpire.put(player.getName(), System.currentTimeMillis() - + (DeadBodiesExpire * 1000)); + _deadBodiesExpire.put(player.getName(), System.currentTimeMillis() + (DeadBodiesExpire * 1000)); } } @@ -1732,37 +1655,36 @@ public abstract class Game implements Listener { Block block = loc.getBlock(); - while (block.getY() > 0 - && !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN)) + while (block.getY() > 0 && !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN)) && !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) { block = block.getRelative(BlockFace.DOWN); } - BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3] - .getOppositeFace(); + BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3].getOppositeFace(); // A complicated way to get the face the dead body should be towards. for (HashSet validBlocks : new HashSet[] - { - UtilBlock.blockAirFoliageSet, UtilBlock.blockPassSet - }) + { + UtilBlock.blockAirFoliageSet, + UtilBlock.blockPassSet + }) { - if (validBlocks.contains((byte) block.getRelative(proper) - .getTypeId())) + if (validBlocks.contains((byte) block.getRelative(proper).getTypeId())) { return proper; } for (BlockFace face : new BlockFace[] + { + BlockFace.EAST, + BlockFace.SOUTH, + BlockFace.NORTH, + BlockFace.WEST + }) { - BlockFace.EAST, BlockFace.SOUTH, BlockFace.NORTH, - BlockFace.WEST - }) - { - if (validBlocks.contains((byte) block.getRelative(face) - .getTypeId())) + if (validBlocks.contains((byte) block.getRelative(face).getTypeId())) { return face; } @@ -1780,8 +1702,7 @@ public abstract class Game implements Listener return; } - Iterator> itel = _deadBodiesExpire.entrySet() - .iterator(); + Iterator> itel = _deadBodiesExpire.entrySet().iterator(); while (itel.hasNext()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index 689815a1b..1f378f0f0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -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.ScoreboardTeam; import net.minecraft.server.v1_8_R3.WorldServer; -import net.minecraft.server.v1_8_R3.WorldBorder; public abstract class SurvivalGames extends Game { @@ -643,7 +642,10 @@ public abstract class SurvivalGames extends Game border); } - setBorder(); + _borderStartedMoving = System.currentTimeMillis(); + + WorldBorder border = WorldData.World.getWorldBorder(); + border.setSize(_currentBorder * 2, 1); _deathMatchTime = 11; } @@ -876,31 +878,6 @@ public abstract class SurvivalGames extends Game }.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 public void onSecond(UpdateEvent event) { @@ -921,7 +898,10 @@ public abstract class SurvivalGames extends Game { _currentBorder = _borderPositions.get(_secondsSinceStart); - setBorder(); + _borderStartedMoving = System.currentTimeMillis(); + + WorldBorder border = WorldData.World.getWorldBorder(); + border.setSize(_currentBorder * 2, 1); } _secondsSinceStart++; @@ -1337,6 +1317,13 @@ public abstract class SurvivalGames extends Game _supplyLocations = WorldData.GetDataLocs("WHITE"); for (Location loc : _supplyLocations) 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 @@ -1467,50 +1454,6 @@ public abstract class SurvivalGames extends Game _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() { ArrayList chests = WorldData.GetCustomLocs("54"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index 7b4b6d0ef..e1523f86c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -34,9 +34,6 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.Game.GameState; 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.ChatColor; @@ -45,6 +42,7 @@ import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.WorldBorder; import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -231,6 +229,13 @@ public class UHC extends TeamGame { _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 @@ -270,28 +275,15 @@ public class UHC extends TeamGame { _currentBorder = _borderPositions.get(_secondsSinceStart); - setBorder(); + _borderStartedMoving = System.currentTimeMillis(); + + WorldBorder border = WorldData.World.getWorldBorder(); + border.setSize(_currentBorder * 2, 1); } _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 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 buildBorders(int seconds, double border, double leaveRemaining) { double totalNumber = Math.pow(seconds, 1.9D) + (seconds * 50); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java index e9f89681b..b36dac1eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java @@ -115,6 +115,7 @@ public class WorldData TimingManager.stop("WorldData loading world."); World.setDifficulty(Difficulty.HARD); + World.setGameRuleValue("showDeathmessages", "false"); TimingManager.start("WorldData loading WorldConfig."); //Load World Data