diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index e772427cc..a569b9612 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -4,11 +4,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; + import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutEntity; @@ -16,8 +19,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; public class Hologram { @@ -313,7 +314,7 @@ public class Hologram */ public Hologram removePlayer(Player player) { - return addPlayer(player.getName()); + return removePlayer(player.getName()); } /** diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java index ef2f17d9b..8f2788e66 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java @@ -3,8 +3,6 @@ package mineplex.minecraft.game.core.damage; import java.util.ArrayList; import java.util.HashMap; -import mineplex.core.common.util.C; - import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -15,6 +13,8 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.core.common.util.C; + public class CustomDamageEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); @@ -43,6 +43,7 @@ public class CustomDamageEvent extends Event implements Cancellable private boolean _knockback = true; private boolean _damageeBrute = false; private boolean _damageToLevel = true; + private boolean _arrowShow = true; public CustomDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile projectile, Location knockbackOrigin, DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor, String initialSource, @@ -167,6 +168,16 @@ public class CustomDamageEvent extends Event implements Cancellable { return _projectile; } + + public void setShowArrows(boolean show) + { + _arrowShow = show; + } + + public boolean getShowArrows() + { + return _arrowShow; + } public DamageCause GetCause() { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index af1525e2a..8d3d35d16 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -378,7 +378,7 @@ public class DamageManager extends MiniPlugin event.GetDamageeEntity().playEffect(EntityEffect.HURT); //Sticky Arrow - if (event.GetCause() == DamageCause.PROJECTILE && event.GetProjectile() != null && event.GetProjectile() instanceof Arrow) + if (event.GetCause() == DamageCause.PROJECTILE && event.GetProjectile() != null && event.GetProjectile() instanceof Arrow && event.getShowArrows()) ((CraftLivingEntity)event.GetDamageeEntity()).getHandle().o(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().bv() + 1); //Knockback 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 ec8a80299..d345843d0 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 @@ -33,8 +33,11 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.potion.PotionEffectType; +import org.bukkit.scoreboard.NameTagVisibility; +import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; @@ -45,6 +48,7 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.hologram.Hologram.HologramTarget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; @@ -116,6 +120,14 @@ public class Paintball extends TeamGame this.GetTeamList().get(1).SetColor(ChatColor.RED); this.GetTeamList().get(1).SetName("Nether"); } + + @EventHandler + public void onNameTag(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Prepare) + for (Team team : Scoreboard.GetScoreboard().getTeams()) + team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); + } @EventHandler(priority = EventPriority.HIGHEST) public void ColorArmor(PlayerPrepareTeleportEvent event) @@ -170,6 +182,8 @@ public class Paintball extends TeamGame if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + + event.getEntity().remove(); } }, 1); } @@ -188,7 +202,10 @@ public class Paintball extends TeamGame if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + + event.getEntity().remove(); } + } } @@ -202,6 +219,7 @@ public class Paintball extends TeamGame PlayerCopyPaintball copy = _doubles.remove(player); copy.GetEntity().remove(); copy.GetHolo().stop(); + copy.GetSaveMe().stop(); } } @@ -235,6 +253,8 @@ public class Paintball extends TeamGame event.AddMod("Paintball", "Paintball", 2, true); event.AddKnockback("Paintball", 2); + + event.setShowArrows(false); Player damagee = event.GetDamageePlayer(); if (damagee == null) @@ -487,6 +507,7 @@ public class Paintball extends TeamGame //Remove Copy copy.GetEntity().remove(); copy.GetHolo().stop(); + copy.GetSaveMe().stop(); } }, 4); } @@ -542,4 +563,69 @@ public class Paintball extends TeamGame { event.setCancelled(true); } + + @EventHandler + public void updateCloneHolograms(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (PlayerCopyPaintball clone : _doubles.values()) + { + if (clone.GetHolo().getHologramTarget() == HologramTarget.WHITELIST) + { + //Other team blacklist + clone.GetHolo().setHologramTarget(HologramTarget.BLACKLIST); + + for (Player cur : GetPlayers(false)) + { + if (!IsAlive(cur)) + { + if (clone.GetHolo().containsPlayer(cur)) + clone.GetHolo().removePlayer(cur); + } + else + { + if (GetTeam(cur) != GetTeam(clone.GetPlayer())) + { + if (!clone.GetHolo().containsPlayer(cur)) + clone.GetHolo().addPlayer(cur); + } + else if (clone.GetHolo().containsPlayer(cur)) + { + clone.GetHolo().removePlayer(cur); + } + } + } + clone.GetHolo().start(); + } + + clone.setSaveMeFlop(!clone.getSaveMeFlop()); + clone.GetSaveMe().setText((clone.getSaveMeFlop() ? C.cRedB : C.cWhiteB) + "SAVE ME!"); + + for (Player player : GetTeam(clone.GetPlayer()).GetPlayers(false)) + { + if (!IsAlive(player)) // Remove if it's not alive + { + if (clone.GetSaveMe().containsPlayer(player)) + clone.GetSaveMe().removePlayer(player); + } + else + { + boolean hasPotion = UtilInv.contains(player, Material.POTION, (byte) -1, 1); + if (clone.GetSaveMe().containsPlayer(player)) + { + if (!hasPotion) // No potions left + { + clone.GetSaveMe().removePlayer(player); + } + } + else if (hasPotion) + { + clone.GetSaveMe().addPlayer(player); + } + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java index 595aa9889..f89e0c66d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java @@ -14,6 +14,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.Hologram.HologramTarget; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.game.Game; @@ -25,6 +26,9 @@ public class PlayerCopyPaintball private ArmorStand _ent; private Hologram _holo; + private Hologram _saveMe; + + private boolean _saveMeFlop = false; public PlayerCopyPaintball(Game host, Player owner, Player paintedBy, ChatColor nameColor) { @@ -69,9 +73,16 @@ public class PlayerCopyPaintball _ent.setHelmet(skull); //Name - _holo = new Hologram(host.Manager.getHologramManager(), _ent.getEyeLocation().clone().add(0, .5, 0)); + _holo = new Hologram(host.Manager.getHologramManager(), _ent.getLocation().clone().add(0, 2.2, 0)); _holo.setText(C.cWhite + C.Bold + C.Scramble + "XX" + ChatColor.RESET + " " + nameColor + owner.getName() + " " + C.cWhite + C.Bold + C.Scramble + "XX", C.cWhite + "Painted by " + host.GetTeam(paintedBy).GetColor() + paintedBy.getName()); + _holo.setHologramTarget(HologramTarget.WHITELIST); _holo.start(); + + //Save me + _saveMe = new Hologram(host.Manager.getHologramManager(), _ent.getLocation().clone().add(0, 2.8, 0)); + _saveMe.setText(C.cRedB + "SAVE ME!"); + _saveMe.setHologramTarget(HologramTarget.WHITELIST); + _saveMe.start(); } public LivingEntity GetEntity() @@ -88,4 +99,19 @@ public class PlayerCopyPaintball { return _holo; } + + public Hologram GetSaveMe() + { + return _saveMe; + } + + public boolean getSaveMeFlop() + { + return _saveMeFlop; + } + + public void setSaveMeFlop(boolean flop) + { + _saveMeFlop = flop; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java index 657f2e3d7..320a71a1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -1,13 +1,16 @@ package nautilus.game.arcade.game.games.paintball.kits.perks; import java.util.ArrayList; -import java.util.HashMap; +import java.util.HashSet; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; @@ -27,6 +30,8 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargedEvent; import mineplex.core.updater.UpdateType; @@ -36,9 +41,10 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.kit.Perk; import net.md_5.bungee.api.ChatColor; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_8_R3.EntityArrow; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; -public class PerkPaintballSniper extends Perk +public class PerkPaintballSniper extends Perk implements IPacketHandler { /** * Created by: Mysticate @@ -47,15 +53,18 @@ public class PerkPaintballSniper extends Perk private static class Bullet { + public Player Shooter; public int Damage; public Location LastSeen; } - private HashMap _crouching = new HashMap(); + private HashSet _crouching = new HashSet(); private NautHashMap _fired = new NautHashMap(); private double _velocity = 15; + private boolean _spawning = false; + public PerkPaintballSniper() { super("Sniper Rifle", new String[] @@ -63,7 +72,14 @@ public class PerkPaintballSniper extends Perk C.cYellow + "Crouch" + C.cGray + " to use " + C.cGreen + "Scope", C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Sniper Rifle", "Experience Bar represents damage." - }); + }); + } + + @SuppressWarnings("unchecked") + @Override + public void registeredEvents() + { + Manager.getPacketHandler().addPacketHandler(this, PacketPlayOutSpawnEntity.class); } @EventHandler @@ -107,17 +123,25 @@ public class PerkPaintballSniper extends Perk if (!Recharge.Instance.use(player, GetName(), 1000, true, true)) return; - Arrow proj = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection().clone().multiply(_velocity)); + net.minecraft.server.v1_8_R3.World world = ((CraftWorld) player.getWorld()).getHandle(); + EntityArrow launch = new EntityArrow(world, ((CraftPlayer) player).getHandle(), 0F); + Location location = player.getEyeLocation(); - PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(); - packet.a = new int[]{proj.getEntityId()}; + launch.projectileSource = player; + launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - for (Player viewer : UtilServer.getPlayers()) - UtilPlayer.sendPacket(viewer, packet); - + ((Projectile) launch.getBukkitEntity()).setVelocity(player.getEyeLocation().getDirection().clone().multiply(_velocity)); + + _spawning = true; + world.addEntity(launch); + _spawning = false; + + Arrow proj = (Arrow) launch.getBukkitEntity(); + proj.setMetadata("color", new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetColor().ordinal())); Bullet bullet = new Bullet(); + bullet.Shooter = player; bullet.Damage = getPaintDamage(player); bullet.LastSeen = proj.getLocation(); @@ -140,11 +164,9 @@ public class PerkPaintballSniper extends Perk if (!Manager.GetGame().IsLive()) return; - + //Cleanup check - HashMap copyMap = new HashMap(); - copyMap.putAll(_crouching); - for (Player player : copyMap.keySet()) + for (Player player : new HashSet(_crouching)) { boolean remove = false; if (!player.isOnline()) @@ -167,7 +189,7 @@ public class PerkPaintballSniper extends Perk if (remove) { - if (_crouching.containsKey(player)) + if (_crouching.contains(player)) _crouching.remove(player); player.setExp(0F); @@ -193,10 +215,10 @@ public class PerkPaintballSniper extends Perk if (!UtilInv.IsItem(player.getItemInHand(), Material.STONE_HOE, (byte) -1)) continue; - if (_crouching.containsKey(player)) + if (_crouching.contains(player)) continue; - _crouching.put(player, System.currentTimeMillis()); + _crouching.add(player); // Zoom addEffects(player); @@ -212,10 +234,10 @@ public class PerkPaintballSniper extends Perk if (!Kit.HasKit(player)) continue; - if (!_crouching.containsKey(player)) + if (!_crouching.contains(player)) continue; - player.setExp((float) Math.min(.999F, player.getExp() + .0125)); + player.setExp((float) Math.min(.999F, player.getExp() + .01666)); } } @@ -238,10 +260,13 @@ public class PerkPaintballSniper extends Perk while (curRange <= distance) { Location newTarget = bullet.LastSeen.add(UtilAlg.getTrajectory(bullet.LastSeen, proj.getLocation()).multiply(curRange)); - + //Progress Forwards curRange += 0.8; + if (UtilMath.offset(bullet.Shooter.getLocation(), newTarget) < 2) + continue; + ChatColor color = ChatColor.values()[proj.getMetadata("color").get(0).asInt()]; if (color == ChatColor.BLUE || color == ChatColor.AQUA) { @@ -266,17 +291,19 @@ public class PerkPaintballSniper extends Perk } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void removeEffects(GameStateChangeEvent event) + public void clean(GameStateChangeEvent event) { if (event.GetState() != GameState.End) return; - for (Player player : _crouching.keySet()) + for (Player player : _crouching) { removeEffects(player); } _crouching.clear(); + + Manager.getPacketHandler().removePacketHandler(this); } private void removeEffects(Player player) @@ -293,7 +320,7 @@ public class PerkPaintballSniper extends Perk { // Zoom if (!Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) - Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 8, false, false, false, false); + Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 8, false, false, false, true); } public int getPaintDamage(Arrow proj) @@ -306,9 +333,18 @@ public class PerkPaintballSniper extends Perk private int getPaintDamage(Player player) { - if (!_crouching.containsKey(player)) + if (!_crouching.contains(player)) return 1; - return (int) Math.max(1, Math.min(4, Math.floor((System.currentTimeMillis() - _crouching.get(player)) / 1000))); + return 1 + (int) Math.floor(player.getExp() * 10 / 3); + } + + @Override + public void handle(PacketInfo packetInfo) + { + if (!_spawning) + return; + + packetInfo.setCancelled(true); } } \ No newline at end of file