From 2504493ebc9cc9b0043d7a64f949f2237ba71381 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Sun, 4 Oct 2015 00:34:00 +0300 Subject: [PATCH] Fixed four super paintball bugs. - Projectiles could paint wool in the waiting lobby. - When players fell in the void, they didn't got killed. - Players that were painted could take off their armor. - Players that were painted could logout and the skeleton would still stay there. --- .../game/games/paintball/Paintball.java | 140 +++++++++++------- 1 file changed, 88 insertions(+), 52 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index 550bdb153..54d387758 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -4,17 +4,44 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.paintball.kits.KitMachineGun; +import nautilus.game.arcade.game.games.paintball.kits.KitRifle; +import nautilus.game.arcade.game.games.paintball.kits.KitShotgun; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.stats.KillFastStatTracker; +import nautilus.game.arcade.stats.LastStandStatTracker; +import nautilus.game.arcade.stats.MedicStatTracker; +import nautilus.game.arcade.stats.WinFastStatTracker; +import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; -import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; @@ -22,9 +49,11 @@ import org.bukkit.entity.ThrownPotion; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; @@ -34,31 +63,6 @@ import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.paintball.kits.*; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.stats.KillFastStatTracker; -import nautilus.game.arcade.stats.LastStandStatTracker; -import nautilus.game.arcade.stats.MedicStatTracker; -import nautilus.game.arcade.stats.WinFastStatTracker; -import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker; - public class Paintball extends TeamGame { public static class ReviveEvent extends PlayerEvent @@ -137,7 +141,6 @@ public class Paintball extends TeamGame this.GetTeamList().get(1).SetName("Nether"); } - @EventHandler(priority = EventPriority.HIGHEST) public void ColorArmor(PlayerPrepareTeleportEvent event) { @@ -161,31 +164,44 @@ public class Paintball extends TeamGame @EventHandler public void Paint(ProjectileHitEvent event) { - if (event.getEntity() instanceof ThrownPotion) - return; + // Fixed projectile wool painting in waiting lobby. - byte color = 3; - if (event.getEntity() instanceof EnderPearl) - color = 14; - - Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity()); - - for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) + if (IsLive() || GetState() == GameState.End) { - if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY) - continue; + if (event.getEntity() instanceof ThrownPotion) + return; + + byte color = 3; + if (event.getEntity() instanceof EnderPearl) + color = 14; + + Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity()); + + for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) + { + if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY) + continue; + + block.setData(color); + } + + if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); + else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); - block.setData(color); } - - if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); - else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); } @EventHandler public void PlayerQuit(PlayerQuitEvent event) { - _doubles.remove(event.getPlayer()); + Player player = event.getPlayer(); + + if (_doubles.containsKey(player)) + { + PlayerCopy copy = _doubles.get(player); + copy.GetEntity().remove(); + _doubles.remove(player); + } } @EventHandler @@ -194,7 +210,9 @@ public class Paintball extends TeamGame if (event.GetDamageePlayer() == null) event.SetCancelled("Not Player"); - if (event.GetProjectile() == null) + // Fixed void damage being blocked from this check. + + if (event.GetProjectile() == null && event.GetCause() != DamageCause.VOID) event.SetCancelled("No Projectile"); } @@ -203,7 +221,7 @@ public class Paintball extends TeamGame { if (!IsLive()) return; - + if (event.GetProjectile() == null) return; @@ -211,23 +229,28 @@ public class Paintball extends TeamGame return; //Negate + event.AddMod("Negate", "Negate", -event.GetDamageInitial(), false); event.AddMod("Paintball", "Paintball", 2, true); event.AddKnockback("Paintball", 2); Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; + if (damagee == null) + return; Player damager = event.GetDamagerPlayer(true); - if (damager == null) return; - + if (damager == null) + return; + GameTeam damageeTeam = GetTeam(damagee); - if (damageeTeam == null) return; + if (damageeTeam == null) + return; GameTeam damagerTeam = GetTeam(damager); - if (damagerTeam == null) return; - + if (damagerTeam == null) + return; + if (damagerTeam.equals(damageeTeam)) return; @@ -257,8 +280,21 @@ public class Paintball extends TeamGame Player player = event.GetDamagerPlayer(true); if (player != null) player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 3f); - } + } + @EventHandler + public void ArmorRemoveCancel(InventoryClickEvent event) + { + HumanEntity player = event.getWhoClicked(); + + // Fixed armor being taken off while spectating after being painted. + + if (!IsAlive(player)) + { + event.setCancelled(true); + } + } + public boolean Color(Player player, int amount) { //Get Non-Coloured