Fix Zombie's Deaths Grasp hitting spectating players
This commit is contained in:
parent
b89e3c4abc
commit
41b7e4bf38
@ -1,23 +1,11 @@
|
||||
package nautilus.game.arcade.game.games.smash.kits;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguiseEnderman;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
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.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats;
|
||||
@ -31,6 +19,13 @@ import nautilus.game.arcade.kit.Perk;
|
||||
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
|
||||
import nautilus.game.arcade.kit.perks.event.PerkBlockGrabEvent;
|
||||
import nautilus.game.arcade.kit.perks.event.PerkBlockThrowEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class KitEnderman extends SmashKit
|
||||
{
|
||||
@ -82,8 +77,6 @@ public class KitEnderman extends SmashKit
|
||||
};
|
||||
|
||||
|
||||
public HashMap<Player, DisguiseEnderman> _disguises = new HashMap<Player, DisguiseEnderman>();
|
||||
|
||||
public KitEnderman(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Enderman", KitAvailability.Gem, 3000, PERKS, EntityType.ENDERMAN, IN_HAND, DisguiseEnderman.class);
|
||||
@ -93,9 +86,7 @@ public class KitEnderman extends SmashKit
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
disguise(player);
|
||||
|
||||
_disguises.put(player, (DisguiseEnderman) Manager.GetDisguise().getActiveDisguise(player));
|
||||
|
||||
|
||||
UtilInv.Clear(player);
|
||||
|
||||
player.getInventory().addItem(PLAYER_ITEMS[0], PLAYER_ITEMS[1]);
|
||||
@ -111,54 +102,45 @@ public class KitEnderman extends SmashKit
|
||||
@EventHandler
|
||||
public void BlockGrab(PerkBlockGrabEvent event)
|
||||
{
|
||||
SetBlock(_disguises.get(event.GetPlayer()), event.GetId(), event.GetData());
|
||||
setBlock(event.GetPlayer(), event.GetId(), event.GetData());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BlockThrow(PerkBlockThrowEvent event)
|
||||
{
|
||||
SetBlock(_disguises.get(event.GetPlayer()), 0, (byte) 0);
|
||||
setBlock(event.GetPlayer(), 0, (byte) 0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Death(PlayerDeathEvent event)
|
||||
{
|
||||
SetBlock(_disguises.get(event.getEntity()), 0, (byte) 0);
|
||||
}
|
||||
|
||||
public void SetBlock(DisguiseEnderman disguise, int id, byte data)
|
||||
{
|
||||
if (disguise == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
disguise.SetCarriedId(id);
|
||||
disguise.SetCarriedData(data);
|
||||
|
||||
Manager.GetDisguise().updateDisguise(disguise);
|
||||
setBlock(event.getEntity(), 0, (byte) 0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void cleanDisguises(UpdateEvent event)
|
||||
public void damage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Iterator<Entry<Player, DisguiseEnderman>> iterator = _disguises.entrySet().iterator(); iterator.hasNext();)
|
||||
{
|
||||
Entry<Player, DisguiseEnderman> current = iterator.next();
|
||||
Player player = event.GetDamageePlayer();
|
||||
DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player);
|
||||
|
||||
if (!Manager.GetDisguise().isDisguised(current.getKey()))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
else if (Manager.GetDisguise().getActiveDisguise(current.getKey()) != current.getValue())
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
if (player != null && disguise != null && disguise instanceof DisguiseEnderman)
|
||||
{
|
||||
// Endermen drop their held block when damaged. This means the client renders it this way, so we need to resend the correct data on the next tick.
|
||||
Manager.runSyncLater(() -> Manager.GetDisguise().updateDisguise(disguise), 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlock(Player player, int id, byte data)
|
||||
{
|
||||
DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player);
|
||||
|
||||
if (player != null && disguise != null && disguise instanceof DisguiseEnderman)
|
||||
{
|
||||
DisguiseEnderman disguiseEnderman = (DisguiseEnderman) disguise;
|
||||
disguiseEnderman.SetCarriedId(id);
|
||||
disguiseEnderman.SetCarriedData(data);
|
||||
|
||||
Manager.GetDisguise().updateDisguise(disguiseEnderman);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,8 @@ public class PerkCreeperExplode extends SmashPerk
|
||||
UtilAction.zeroVelocity(player);
|
||||
|
||||
// Sound
|
||||
player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, (float) (0.5 + elapsed), (float) (0.5 + elapsed));
|
||||
float volume = (float) 0.5F + elapsed / 1000F;
|
||||
player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, volume, volume);
|
||||
|
||||
IncreaseSize(player);
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class PerkDeathsGrasp extends Perk
|
||||
List<Player> team = TeamSuperSmash.getTeam(Manager, player, true);
|
||||
for (Player other : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
if(team.contains(other))
|
||||
if(UtilPlayer.isSpectator(player) || team.contains(other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user