From 95937db83a5af6aba96f7c6df525bdec4027a3c7 Mon Sep 17 00:00:00 2001 From: Chiss Date: Fri, 24 Oct 2014 19:10:10 +1100 Subject: [PATCH 1/5] changed firework color --- .../src/nautilus/game/arcade/kit/perks/PerkLazer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java index 133554984..78416f90e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java @@ -182,7 +182,7 @@ public class PerkLazer extends Perk UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1); //Firework - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BALL).trail(false).build(); + FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL).trail(false).build(); try { From 01f311a3d65d7044a8b502083769eba47bec016c Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 25 Oct 2014 10:38:47 +1100 Subject: [PATCH 2/5] Added missing requirements for SG Achievement Kit fixed a parkour exploit --- .../src/mineplex/hub/modules/ParkourManager.java | 3 +++ .../src/nautilus/game/arcade/ArcadeManager.java | 12 ------------ .../game/games/survivalgames/kit/KitHorseman.java | 9 +++++++++ .../nautilus/game/arcade/managers/GameManager.java | 9 --------- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index 8b31bc1cd..4dd7128f3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -21,6 +21,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; @@ -120,6 +121,8 @@ public class ParkourManager extends MiniPlugin UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("Parkour Mode") + ".")); Manager.GetGadget().DisableAll(player); + + player.setVelocity(new Vector(0,-1,0)); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 5aed24fb8..50e3a1fa3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -708,18 +708,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation GetDisguise().undisguise(player); } - - public void RefreshPlayers() - { - for (Player player : UtilServer.getPlayers()) - { - for (Player other : UtilServer.getPlayers()) - { - player.hidePlayer(other); - player.showPlayer(other); - } - } - } public ArrayList LoadFiles(String gameName) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitHorseman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitHorseman.java index 5f7bf906b..dbf7f7638 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitHorseman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitHorseman.java @@ -5,6 +5,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import mineplex.core.achievement.Achievement; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; @@ -29,6 +30,14 @@ public class KitHorseman extends Kit EntityType.HORSE, new ItemStack(Material.DIAMOND_BARDING)); + this.setAchievementRequirements(new Achievement[] + { + Achievement.SURVIVAL_GAMES_BLOODLUST, + Achievement.SURVIVAL_GAMES_LIGHT_WEIGHT, + Achievement.SURVIVAL_GAMES_LOOT, + Achievement.SURVIVAL_GAMES_SKELETONS, + Achievement.SURVIVAL_GAMES_WINS, + }); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index ecba09dd3..936e066a3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -259,15 +259,6 @@ public class GameManager implements Listener if (Manager.GetGame() != null && Manager.GetGame().GetState() != GameState.Recruit) event.setCancelled(true); } - - @EventHandler - public void VisibilityRefresh(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - Manager.RefreshPlayers(); - } @EventHandler public void KitRegister(GameStateChangeEvent event) From 92d9fc4ca0a603a75cfc68f6b676e633afa3c520 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 25 Oct 2014 11:03:45 +1100 Subject: [PATCH 3/5] Deleted deprecated firework module and converted to Util --- .../core/common/util/UtilFirework.java | 7 ++ .../nautilus/game/arcade/ArcadeManager.java | 16 ++- .../game/games/castlesiege/CastleSiege.java | 13 +-- .../game/games/dragonescape/DragonEscape.java | 26 ++--- .../games/dragonescape/DragonEscapeTeams.java | 26 ++--- .../game/games/evolution/Evolution.java | 14 +-- .../game/arcade/kit/perks/PerkBlink.java | 23 +--- .../arcade/kit/perks/PerkChickenRocket.java | 13 +-- .../game/arcade/kit/perks/PerkFirefly.java | 24 +---- .../game/arcade/kit/perks/PerkLazer.java | 12 +-- .../game/arcade/kit/perks/PerkSparkler.java | 12 +-- .../game/arcade/kit/perks/PerkSquidRifle.java | 8 +- .../arcade/kit/perks/PerkSquidShotgun.java | 8 +- .../arcade/kit/perks/PerkSquidSniper.java | 8 +- .../game/arcade/managers/GameGemManager.java | 1 - .../arcade/managers/GameLobbyManager.java | 14 +-- .../game/arcade/managers/GameManager.java | 16 +-- .../game/arcade/world/FireworkHandler.java | 101 ------------------ 18 files changed, 65 insertions(+), 277 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/FireworkHandler.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java index 9e9595ad0..23cd659b5 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java @@ -1,6 +1,8 @@ package mineplex.core.common.util; +import org.bukkit.Color; import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; @@ -57,4 +59,9 @@ public class UtilFirework firework.remove(); } + + public static void playFirework(Location loc, Type ballLarge, Color color, boolean flicker, boolean trail) + { + playFirework(loc, FireworkEffect.builder().flicker(false).withColor(color).with(Type.BALL_LARGE).trail(false).build()); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 50e3a1fa3..bfff331c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -9,9 +9,12 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.OfflinePlayer; +import org.bukkit.FireworkEffect.Type; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -39,6 +42,7 @@ import mineplex.core.chat.Chat; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; @@ -63,6 +67,8 @@ import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.timing.TimingManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -103,7 +109,6 @@ import nautilus.game.arcade.managers.HalloweenManager; import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; import nautilus.game.arcade.shop.ArcadeShop; -import nautilus.game.arcade.world.FireworkHandler; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -120,7 +125,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation private DamageManager _damageManager; private Explosion _explosionManager; private Fire _fire; - private FireworkHandler _firework; private ProjectileManager _projectileManager; private Portal _portal; @@ -206,7 +210,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation _donationManager = donationManager; - _firework = new FireworkHandler(); _fire = new Fire(plugin, _conditionManager, damageManager); _projectileManager = projectileManager; @@ -359,12 +362,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return _fire; } - - public FireworkHandler GetFirework() - { - return _firework; - } - + public ProjectileManager GetProjectile() { return _projectileManager; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index da2865ebb..4d81fa301 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -44,6 +44,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -771,16 +772,8 @@ public class CastleSiege extends TeamGame continue; } - FireworkEffect effect = FireworkEffect.builder().withColor(Color.RED).with(Type.BURST).build(); - - try - { - Manager.GetFirework().playFirework(player.getEyeLocation(), effect); - } - catch (Exception e) - { - e.printStackTrace(); - } + //Firework + UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index 927a914aa..a4381b7e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -28,6 +28,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -489,17 +490,9 @@ public class DragonEscape extends SoloGame UtilInv.Update(player); //Firework - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.BLACK).with(Type.BALL).trail(false).build(); - try - { - Manager.GetFirework().playFirework(player.getEyeLocation(), effect); - player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); - } - catch (Exception e) - { - e.printStackTrace(); - } - + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); + //Teleport player.teleport(target.getLocation().add(0, 0.5, 0)); player.setVelocity(new Vector(0,0,0)); @@ -516,15 +509,8 @@ public class DragonEscape extends SoloGame //Firework - try - { - Manager.GetFirework().playFirework(player.getEyeLocation(), effect); - player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java index d7f43170d..9a835d5ee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java @@ -27,6 +27,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -534,17 +535,9 @@ public class DragonEscapeTeams extends TeamGame UtilInv.Update(player); //Firework - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.BLACK).with(Type.BALL).trail(false).build(); - try - { - Manager.GetFirework().playFirework(player.getEyeLocation(), effect); - player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); - } - catch (Exception e) - { - e.printStackTrace(); - } - + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); + //Teleport player.teleport(target.getLocation().add(0, 0.5, 0)); player.setVelocity(new Vector(0,0,0)); @@ -561,15 +554,8 @@ public class DragonEscapeTeams extends TeamGame //Firework - try - { - Manager.GetFirework().playFirework(player.getEyeLocation(), effect); - player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index f3570be42..3f1c0125c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -14,6 +14,7 @@ import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -177,17 +178,8 @@ public class Evolution extends SoloGame GetKits()[i].ApplyKit(player); //Firework - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.LIME).with(Type.BALL).trail(false).build(); - - try - { - Manager.GetFirework().playFirework(player.getEyeLocation(), effect); - } - catch (Exception e) - { - e.printStackTrace(); - } - + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.LIME, false, false); + //Teleport player.teleport(GetTeam(player).GetSpawn()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java index f6dc80fb8..97e2a5cdf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java @@ -17,6 +17,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.kit.Perk; @@ -100,30 +101,12 @@ public class PerkBlink extends Perk if (curRange > 0) { //Firework - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.BLACK).with(Type.BALL).trail(false).build(); - - try - { - Manager.GetFirework().playFirework(player.getEyeLocation(), effect); - player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); player.teleport(loc); //Firework - try - { - Manager.GetFirework().playFirework(player.getEyeLocation(), effect); - player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java index c89bc4964..a090f4e53 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java @@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; @@ -180,16 +181,8 @@ public class PerkChickenRocket extends Perk data.Chicken.getWorld().createExplosion(data.Chicken.getLocation(), 1.8f); //Firework - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.WHITE).with(Type.BALL).trail(false).build(); - - try - { - Manager.GetFirework().playFirework(data.Chicken.getLocation().add(0, 0.6, 0), effect); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(data.Chicken.getLocation().add(0, 0.6, 0), Type.BALL, Color.WHITE, false, false); + data.Chicken.remove(); dataIterator.remove(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java index 809b77cd2..f60c6c5d4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java @@ -18,6 +18,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; @@ -95,16 +96,7 @@ public class PerkFirefly extends Perk if (_tick == 0) { //Firework - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.ORANGE).with(Type.BURST).trail(false).build(); - - try - { - Manager.GetFirework().playFirework(data.Player.getLocation(), effect); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(data.Player.getLocation().add(0, 0.6, 0), Type.BURST, Color.ORANGE, false, false); } } @@ -118,19 +110,9 @@ public class PerkFirefly extends Perk if (_tick == 0) { //Firework - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BURST).trail(false).build(); - - try - { - Manager.GetFirework().playFirework(data.Player.getLocation(), effect); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(data.Player.getLocation().add(0, 0.6, 0), Type.BURST, Color.RED, false, false); } - for (Player other : UtilPlayer.getNearby(data.Player.getLocation(), 3)) { if (other.equals(data.Player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java index 78416f90e..4bc4d0bfd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java @@ -20,6 +20,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; @@ -182,16 +183,7 @@ public class PerkLazer extends Perk UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1); //Firework - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL).trail(false).build(); - - try - { - Manager.GetFirework().playFirework(player.getEyeLocation(), effect); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.YELLOW, false, false); for (LivingEntity other : UtilEnt.getInRadius(target, 5).keySet()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSparkler.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSparkler.java index 73027a682..6f32b72d4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSparkler.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSparkler.java @@ -23,6 +23,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -196,16 +197,7 @@ public class PerkSparkler extends Perk continue; } - FireworkEffect effect = FireworkEffect.builder().withColor(Color.GREEN).with(Type.BURST).build(); - - try - { - Manager.GetFirework().playFirework(item.getLocation(), effect); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(item.getLocation(), Type.BURST, Color.GREEN, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java index 8222a8d95..7beb2494c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java @@ -85,11 +85,11 @@ public class PerkSquidRifle extends Perk implements IThrown try { Vector vel = player.getLocation().getDirection().multiply(1.8); - Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel); - _fireworks.put(fw, vel); + //Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel); + //_fireworks.put(fw, vel); //Projectile - Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true, 3d, Manager.GetDisguise()); + //Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true, 3d, Manager.GetDisguise()); } catch (Exception e) { @@ -165,7 +165,7 @@ public class PerkSquidRifle extends Perk implements IThrown try { - Manager.GetFirework().detonateFirework(fw); + //Manager.GetFirework().detonateFirework(fw); } catch (Exception e) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java index 070619d2f..cb51926b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java @@ -92,11 +92,11 @@ public class PerkSquidShotgun extends Perk implements IThrown try { Vector vel = player.getLocation().getDirection().multiply(1.4).add(random); - Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel); - _fireworks.put(fw, vel); + //Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel); + //_fireworks.put(fw, vel); //Projectile - Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true, 3d, Manager.GetDisguise()); + //Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true, 3d, Manager.GetDisguise()); } catch (Exception e) { @@ -182,7 +182,7 @@ public class PerkSquidShotgun extends Perk implements IThrown try { - Manager.GetFirework().detonateFirework(fw); + //Manager.GetFirework().detonateFirework(fw); } catch (Exception e) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java index 828bcdd76..687869ecc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java @@ -85,11 +85,11 @@ public class PerkSquidSniper extends Perk implements IThrown try { Vector vel = player.getLocation().getDirection().multiply(3); - Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel); - _fireworks.put(fw, vel); + //Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel); + //_fireworks.put(fw, vel); //Projectile - Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true, 3d, Manager.GetDisguise()); + //Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true, 3d, Manager.GetDisguise()); } catch (Exception e) { @@ -173,7 +173,7 @@ public class PerkSquidSniper extends Perk implements IThrown try { - Manager.GetFirework().detonateFirework(fw); + //Manager.GetFirework().detonateFirework(fw); } catch (Exception e) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index 237aeb11c..b6f1430be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -4,7 +4,6 @@ import java.util.HashMap; import mineplex.core.achievement.Achievement; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 2df45d1e9..4b50ddca0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -44,6 +44,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; @@ -857,17 +858,8 @@ public class GameLobbyManager implements Listener, IPacketHandler if (UtilTime.elapsed(_fireworkStart, 10000)) return; - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(_fireworkColor).with(Type.BALL_LARGE).trail(false).build(); - - try - { - Manager.GetFirework().playFirework(spawn.clone().add( - Math.random()*160-80, 30 + Math.random()*10, Math.random()*160-80), effect); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(spawn.clone().add(Math.random()*160-80, 30 + Math.random()*10, Math.random()*160-80), + Type.BALL_LARGE, _fireworkColor, false, false); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 936e066a3..3428c19d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilDisplay; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -33,6 +34,7 @@ import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.FireworkEffect.Type; import org.bukkit.entity.Player; @@ -629,18 +631,10 @@ public class GameManager implements Listener else if (game.WinnerTeam.GetColor() == ChatColor.YELLOW) color = Color.YELLOW; else color = Color.LIME; } + + Location loc = game.GetSpectatorLocation().clone().add(Math.random()*160-80, 10 + Math.random()*20, Math.random()*160-80); - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with(Type.BALL_LARGE).trail(false).build(); - - try - { - Manager.GetFirework().playFirework(game.GetSpectatorLocation().clone().add( - Math.random()*160-80, 10 + Math.random()*20, Math.random()*160-80), effect); - } - catch (Exception e) - { - e.printStackTrace(); - } + UtilFirework.playFirework(loc, Type.BALL_LARGE, color, false, false); } @EventHandler(priority = EventPriority.MONITOR) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/FireworkHandler.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/FireworkHandler.java deleted file mode 100644 index 594e25ae8..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/FireworkHandler.java +++ /dev/null @@ -1,101 +0,0 @@ -package nautilus.game.arcade.world; - -import java.lang.reflect.Method; - -import org.bukkit.FireworkEffect; -import org.bukkit.Location; -import org.bukkit.entity.Firework; -import org.bukkit.inventory.meta.FireworkMeta; -import org.bukkit.util.Vector; - -public class FireworkHandler -{ - private Method world_getHandle = null; - private Method nms_world_broadcastEntityEffect = null; - private Method firework_getHandle = null; - - public void playFirework(Location loc, FireworkEffect fe) throws Exception - { - Firework fw = (Firework) loc.getWorld().spawn(loc, Firework.class); - - Object nms_world = null; - Object nms_firework = null; - - - if(world_getHandle == null) - { - world_getHandle = getMethod(loc.getWorld().getClass(), "getHandle"); - firework_getHandle = getMethod(fw.getClass(), "getHandle"); - } - - nms_world = world_getHandle.invoke(loc.getWorld(), (Object[]) null); - nms_firework = firework_getHandle.invoke(fw, (Object[]) null); - - if(nms_world_broadcastEntityEffect == null) - { - nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect"); - } - - FireworkMeta data = (FireworkMeta) fw.getFireworkMeta(); - data.clearEffects(); - data.setPower(1); - data.addEffect(fe); - fw.setFireworkMeta(data); - - nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17}); - - fw.remove(); - } - - private static Method getMethod(Class cl, String method) - { - for(Method m : cl.getMethods()) - { - if(m.getName().equals(method)) - { - return m; - } - } - return null; - } - - public Firework launchFirework(Location loc, FireworkEffect fe, Vector dir) throws Exception - { - Firework fw = (Firework) loc.getWorld().spawn(loc, Firework.class); - - FireworkMeta data = (FireworkMeta) fw.getFireworkMeta(); - data.clearEffects(); - data.setPower(1); - data.addEffect(fe); - fw.setFireworkMeta(data); - - fw.setVelocity(dir); - - return fw; - } - - public void detonateFirework(Firework fw) throws Exception - { - Object nms_world = null; - Object nms_firework = null; - - - if(world_getHandle == null) - { - world_getHandle = getMethod(fw.getWorld().getClass(), "getHandle"); - firework_getHandle = getMethod(fw.getClass(), "getHandle"); - } - - nms_world = world_getHandle.invoke(fw.getWorld(), (Object[]) null); - nms_firework = firework_getHandle.invoke(fw, (Object[]) null); - - if(nms_world_broadcastEntityEffect == null) - { - nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect"); - } - - nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17}); - - fw.remove(); - } -} From 7dbba0a1f92b6c38e9baf84fdf99d608fb381837 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 25 Oct 2014 11:17:32 +1100 Subject: [PATCH 4/5] Added teleport for map parser Fixed new method in UtilFirework always being BALL_LARGE Updated lazer --- .../core/common/util/UtilFirework.java | 4 +- .../src/mineplex/mapparser/MapParser.java | 46 ++++++++----------- .../game/arcade/kit/perks/PerkLazer.java | 4 +- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java index 23cd659b5..78b1595a2 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java @@ -60,8 +60,8 @@ public class UtilFirework firework.remove(); } - public static void playFirework(Location loc, Type ballLarge, Color color, boolean flicker, boolean trail) + public static void playFirework(Location loc, Type type, Color color, boolean flicker, boolean trail) { - playFirework(loc, FireworkEffect.builder().flicker(false).withColor(color).with(Type.BALL_LARGE).trail(false).build()); + playFirework(loc, FireworkEffect.builder().flicker(false).withColor(color).with(type).trail(false).build()); } } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index 39d89eff2..949bb2637 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -40,6 +40,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -525,41 +526,30 @@ public class MapParser extends JavaPlugin implements Listener { event.setQuitMessage(F.sys("Player Quit", event.getPlayer().getName())); } - - @EventHandler - public void damage(EntityDamageByEntityEvent event) - { - Entity ent = UtilEvent.GetDamagerEntity(event, false); - if (ent != null && ent instanceof Player) - System.out.println("DAMAGE"); - } - - @EventHandler - public void interactent(PlayerInteractEntityEvent event) - { - System.out.println("ENT INTERACT"); - System.out.println(event.getPlayer().getTargetBlock(null, 0)); - } - - @EventHandler - public void interact(PlayerInteractEvent event) - { - System.out.println("INTERACT"); - } - - @EventHandler - public void debug(PlayerCommandPreprocessEvent event) + @EventHandler(priority = EventPriority.LOWEST) + public void TeleportCommand(PlayerCommandPreprocessEvent event) { + if (!event.getMessage().toLowerCase().startsWith("/tp")) + return; + + event.setCancelled(true); + Player player = event.getPlayer(); + + String[] tokens = event.getMessage().split(" "); - if (event.getMessage().contains("sheep")) + if (tokens.length != 2) { - player.setPassenger(player.getWorld().spawn(player.getLocation(), Sheep.class)); + UtilPlayer.message(player, F.main("Game", "Invalid Input. " + F.elem("/tp ") + ".")); + return; } - if (event.getMessage().contains("drop")) + + Player target = UtilPlayer.searchOnline(player, tokens[1], true); + if (target != null) { - player.eject(); + UtilPlayer.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + ".")); + player.teleport(target); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java index 4bc4d0bfd..56c3009a8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java @@ -100,7 +100,7 @@ public class PerkLazer extends Perk if (player.isBlocking()) { - player.setExp(Math.min(0.999f, player.getExp() + 0.03f)); + player.setExp(Math.min(0.999f, player.getExp() + 0.035f)); player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 0.25f + player.getExp(), 0.75f + player.getExp()); @@ -183,7 +183,7 @@ public class PerkLazer extends Perk UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1); //Firework - UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.YELLOW, false, false); + UtilFirework.playFirework(player.getLocation().add(player.getLocation().getDirection().multiply(Math.max(0, curRange - 0.6))), Type.BURST, Color.YELLOW, false, false); for (LivingEntity other : UtilEnt.getInRadius(target, 5).keySet()) { From 5cf3e6c3a1dfce1a75f2bed49383053bc03ba2ac Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 24 Oct 2014 19:36:22 -0500 Subject: [PATCH 5/5] Fix for arcade custom tags --- .../src/mineplex/core/CustomTagFix.java | 9 ++- .../mineplex/core/event/CustomTagEvent.java | 55 +++++++++++++++ .../arcade/managers/GameLobbyManager.java | 67 ++++++++++++++++--- 3 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/event/CustomTagEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index 0fe952a89..ca530deee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -6,6 +6,7 @@ import java.util.List; import mineplex.core.common.DummyEntity; import mineplex.core.common.util.NautHashMap; +import mineplex.core.event.CustomTagEvent; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.common.util.UtilEnt; import mineplex.core.packethandler.PacketHandler; @@ -334,8 +335,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler } } - private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, final String entityName, final PacketVerifier packetList) + private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName, final PacketVerifier packetList) { + CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName); + _plugin.getServer().getPluginManager().callEvent(event); + final String finalEntityName = event.getCustomName(); + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable() { public void run() @@ -412,7 +417,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler watcher.watch(10, Byte.valueOf(b1)); - watcher.watch(2, entityName); + watcher.watch(2, finalEntityName); watcher.watch(3, Byte.valueOf((byte)1)); packet.l = watcher; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/event/CustomTagEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/event/CustomTagEvent.java new file mode 100644 index 000000000..a19d0c7bd --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/event/CustomTagEvent.java @@ -0,0 +1,55 @@ +package mineplex.core.event; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * Created by Shaun on 10/24/2014. + */ +public class CustomTagEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private int _entityId; + private String _customName; + + public CustomTagEvent(Player player, int entityId, String customName) + { + _player = player; + _entityId = entityId; + _customName = customName; + } + + public Player getPlayer() + { + return _player; + } + + public String getCustomName() + { + return _customName; + } + + public void setCustomName(String customName) + { + _customName = customName; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public int getEntityId() + { + return _entityId; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 2df45d1e9..7bc6fa1da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -45,6 +45,7 @@ import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText.TextAlign; @@ -52,6 +53,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.event.ActivateGemBoosterEvent; import mineplex.core.donation.Donor; +import mineplex.core.event.CustomTagEvent; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketVerifier; @@ -69,7 +71,9 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitSorter; import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_7_R4.WatchableObject; public class GameLobbyManager implements Listener, IPacketHandler { @@ -1087,21 +1091,47 @@ public class GameLobbyManager implements Listener, IPacketHandler return entityName; } + @EventHandler + public void customEntityName(CustomTagEvent event) + { + // TODO: This needs to be changed when removing CustomTagFix + + if (Manager.GetGame() != null) + { + String customName = null; + + for (LobbyEnt ent : _kits.values()) + { + if (ent.GetEnt().getEntityId() == event.getEntityId()) + { + customName = GetKitCustomName(event.getPlayer(), Manager.GetGame(), ent); + break; + } + } + + if (customName != null) + { + event.setCustomName(customName); + } + } + } + @SuppressWarnings("unchecked") public void handle(PacketInfo packetInfo) { - if (_handlingPacket) + // This only applies to 1.7 clients currently, 1.8 custom names are handled by customEntityName(CustomTagEvent event) + if (_handlingPacket || UtilPlayer.is1_8(packetInfo.getPlayer())) return; Packet packet = packetInfo.getPacket(); Player owner = packetInfo.getPlayer(); PacketVerifier packetVerifier = packetInfo.getVerifier(); - + int entityId = -1; - if (packet instanceof PacketPlayOutSpawnEntityLiving) + if (packet instanceof PacketPlayOutEntityMetadata) { - entityId = ((PacketPlayOutSpawnEntityLiving)packet).a; + entityId = ((PacketPlayOutEntityMetadata)packet).a; } if (entityId != -1) @@ -1122,16 +1152,37 @@ public class GameLobbyManager implements Listener, IPacketHandler { try { - if (packet instanceof PacketPlayOutSpawnEntityLiving) + if (packet instanceof PacketPlayOutEntityMetadata) { - ((PacketPlayOutSpawnEntityLiving)packet).l.watch(2, customName); - ((PacketPlayOutSpawnEntityLiving)packet).l.watch(10, customName); + List watchables = new ArrayList(); + + for (WatchableObject watchableObject : (List)((PacketPlayOutEntityMetadata) packet).b) + { + WatchableObject newWatch = new WatchableObject(watchableObject.c(), watchableObject.a(), watchableObject.b()); + + if (newWatch.a() == 10) + { + newWatch.a(customName); + } + + watchables.add(newWatch); + } + + PacketPlayOutEntityMetadata newPacket = new PacketPlayOutEntityMetadata(); + newPacket.a = entityId; + newPacket.b = watchables; + + _handlingPacket = true; + packetVerifier.process(newPacket); + _handlingPacket = false; + + packetInfo.setCancelled(true); } } catch (IllegalArgumentException e) { e.printStackTrace(); - } + } } } }