Complete Biff

This commit is contained in:
Sam 2017-06-08 16:09:32 +01:00
parent a767135ce0
commit 9844ca338a
13 changed files with 367 additions and 132 deletions

View File

@ -100,7 +100,7 @@ public class CustomDamageEvent extends Event implements Cancellable
public void AddMod(String source, double mod)
{
AddMod(source, new String(), mod, false);
AddMod(source, "", mod, false);
}
public void AddMod(String source, String reason, double mod, boolean useAttackName)

View File

@ -15,6 +15,7 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.moba.boss.BossManager;
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
import nautilus.game.arcade.game.games.moba.buff.BuffManager;
import nautilus.game.arcade.game.games.moba.fountain.MobaFountain;
import nautilus.game.arcade.game.games.moba.general.ArrowKBManager;
import nautilus.game.arcade.game.games.moba.general.EnderPearlManager;
@ -36,7 +37,6 @@ import nautilus.game.arcade.game.games.moba.recall.Recall;
import nautilus.game.arcade.game.games.moba.shop.MobaShop;
import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager;
import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager;
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import nautilus.game.arcade.game.modules.CustomScoreboardModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
@ -53,7 +53,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.ArrayList;
import java.util.Arrays;
@ -84,6 +83,7 @@ public class Moba extends TeamGame
private final TowerManager _tower;
private final CapturePointManager _capturePoint;
private final ArrowKBManager _arrowKb;
private final BuffManager _buffs;
public Moba(ArcadeManager manager)
{
@ -139,6 +139,9 @@ public class Moba extends TeamGame
// Ender Pearls
registerManager(new EnderPearlManager());
// Buffs
_buffs = registerManager(new BuffManager());
new CompassModule()
.setGiveCompass(true)
.setGiveCompassToSpecs(true)
@ -664,4 +667,9 @@ public class Moba extends TeamGame
{
return _arrowKb;
}
public BuffManager getBuffManager()
{
return _buffs;
}
}

View File

@ -17,7 +17,6 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilVariant;
import mineplex.minecraft.game.core.condition.ConditionFactory;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
@ -25,9 +24,10 @@ import nautilus.game.arcade.game.games.moba.ai.MobaAI;
import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod;
import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod;
import nautilus.game.arcade.game.games.moba.boss.MobaBoss;
import nautilus.game.arcade.game.games.moba.buff.BuffManager;
import nautilus.game.arcade.game.games.moba.buff.buffs.BuffPumpkinKing;
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -35,7 +35,6 @@ import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
@ -44,10 +43,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@ -62,9 +59,6 @@ public class PumpkinBoss extends MobaBoss
private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN);
private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD);
private static final String DAMAGE_REASON = "Pumpkin King";
private static final String CONDITION_REASON = DAMAGE_REASON + " Buff";
private static final int CONDITION_LENGTH = 60;
private static final double CONDITION_DAMAGE_FACTOR = 1.5;
private static final int DAMAGE_RADIUS = 2;
private static final int DAMAGE_RANGE = 2;
private static final int DAMAGE_DIRECT = 6;
@ -80,14 +74,12 @@ public class PumpkinBoss extends MobaBoss
private MobaAI _ai;
private boolean _initialSpawn;
private final Set<Block> _changed;
private final Set<Player> _buffs;
public PumpkinBoss(Moba host, Location location)
{
super(host, location, RESPAWN_TIME);
_changed = new HashSet<>();
_buffs = new HashSet<>();
}
@Override
@ -223,8 +215,6 @@ public class PumpkinBoss extends MobaBoss
return;
}
giveBuffs(team);
_host.Announce(F.main("Game", team.GetFormattedName() + C.mBody + " killed the " + C.cDRedB + DAMAGE_REASON), false);
UtilTextMiddle.display("", team.GetFormattedName() + C.cWhite + " killed the " + C.cDRedB + DAMAGE_REASON, 10, 40, 10);
@ -235,6 +225,18 @@ public class PumpkinBoss extends MobaBoss
event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.EXPLODE, 1, 0.2F);
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getEntity().getEyeLocation(), 1, 1, 1, 0.1F, 3, ViewDist.LONG);
// Give the team members the buff
BuffManager buffManager = _host.getBuffManager();
for (Player teamMember : team.GetPlayers(true))
{
if (UtilPlayer.isSpectator(teamMember))
{
continue;
}
buffManager.apply(new BuffPumpkinKing(_host, teamMember));
}
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -302,86 +304,4 @@ public class PumpkinBoss extends MobaBoss
{
_entity.setCustomName(MobaUtil.getHealthBar(_entity, 20));
}
private void giveBuffs(GameTeam team)
{
ConditionFactory factory = _host.getArcadeManager().GetCondition().Factory();
for (Player player : team.GetPlayers(true))
{
factory.Regen(CONDITION_REASON, player, null, CONDITION_LENGTH, 1, false, true, false);
UtilParticle.PlayParticleToAll(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG);
player.playSound(player.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F);
player.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!"));
_buffs.add(player);
sendFakeHelmet(player);
}
}
@EventHandler
public void updateFakeHelmet(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
{
return;
}
Iterator<Player> iterator = _buffs.iterator();
while (iterator.hasNext())
{
Player player = iterator.next();
if (!player.hasPotionEffect(PotionEffectType.REGENERATION))
{
if (player.isOnline())
{
player.getInventory().setHelmet(player.getInventory().getHelmet());
}
iterator.remove();
continue;
}
sendFakeHelmet(player);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damageIncrease(CustomDamageEvent event)
{
if (event.isCancelled())
{
return;
}
LivingEntity damagee = event.GetDamageeEntity();
Player damager = event.GetDamagerPlayer(true);
if (damager == null || !_buffs.contains(damager))
{
return;
}
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 10, 1, ViewDist.NORMAL);
event.AddMod(CONDITION_REASON, CONDITION_DAMAGE_FACTOR);
}
private void sendFakeHelmet(Player player)
{
// Magic number 4 means helmet
PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(HELMET));
for (Player other : Bukkit.getOnlinePlayers())
{
// Don't send wearer their own data
if (other.equals(player))
{
continue;
}
UtilPlayer.sendPacket(other, packet);
}
}
}

View File

@ -1,20 +1,57 @@
package nautilus.game.arcade.game.games.moba.buff;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.common.util.UtilServer;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
public abstract class Buff
public abstract class Buff<T extends LivingEntity> implements Listener
{
private final LivingEntity _entity;
protected final Moba _host;
protected final BuffManager _manager;
protected final T _entity;
private final long _duration;
public Buff(LivingEntity entity)
private long _start;
public Buff(Moba host, T entity, long duration)
{
_host = host;
_manager = host.getBuffManager();
_entity = entity;
_duration = duration;
}
public abstract void onApply(Player player);
public abstract void onApply();
public abstract void onUpdate(UpdateEvent event);
public abstract void onExpire();
final void apply()
{
_start = System.currentTimeMillis();
UtilServer.RegisterEvents(this);
onApply();
}
final void expire()
{
UtilServer.Unregister(this);
onExpire();
}
public final T getEntity()
{
return _entity;
}
public final long getDuration()
{
return _duration;
}
public final long getStart()
{
return _start;
}
}

View File

@ -1,16 +1,71 @@
package nautilus.game.arcade.game.games.moba.buff;
import mineplex.minecraft.game.core.condition.Condition;
import nautilus.game.arcade.game.games.moba.Moba;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class BuffManager implements Listener
{
private final Moba _host;
private final Map<LivingEntity, List<Buff<? extends LivingEntity>>> _buffs;
public BuffManager(Moba host)
public BuffManager()
{
_host = host;
_buffs = new HashMap<>();
}
public void apply(Buff<? extends LivingEntity> buff)
{
_buffs.putIfAbsent(buff.getEntity(), new ArrayList<>(3));
_buffs.get(buff.getEntity()).add(buff);
buff.apply();
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
Iterator<LivingEntity> iterator = _buffs.keySet().iterator();
while (iterator.hasNext())
{
LivingEntity entity = iterator.next();
List<Buff<? extends LivingEntity>> buffs = _buffs.get(entity);
if (entity.isDead() || !entity.isValid() || UtilPlayer.isSpectator(entity) || entity instanceof Player && !((Player) entity).isOnline())
{
buffs.forEach(Buff::expire);
iterator.remove();
continue;
}
Iterator<Buff<? extends LivingEntity>> buffIterator = buffs.iterator();
while (buffIterator.hasNext())
{
Buff buff = buffIterator.next();
if (UtilTime.elapsed(buff.getStart(), buff.getDuration()))
{
buff.expire();
buffIterator.remove();
}
}
}
}
}

View File

@ -1,20 +1,104 @@
package nautilus.game.arcade.game.games.moba.buff.buffs;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.buff.Buff;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class BuffPumpkinKing extends Buff
import java.util.concurrent.TimeUnit;
public class BuffPumpkinKing extends Buff<Player>
{
public BuffPumpkinKing(LivingEntity entity)
private static final long DURATION = TimeUnit.MINUTES.toMillis(1);
private static final String DAMAGE_REASON = "Pumpkin King Buff";
private static final double DAMAGE_FACTOR = 1.5;
private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN);
public BuffPumpkinKing(Moba host, Player entity)
{
super(entity);
super(host, entity, DURATION);
}
@Override
public void onUpdate(UpdateEvent event)
public void onApply()
{
_entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60 * 20, 1));
UtilParticle.PlayParticleToAll(ParticleType.LAVA, _entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG);
_entity.playSound(_entity.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F);
_entity.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!"));
}
@Override
public void onExpire()
{
sendFakeHelmet(_entity, _entity.getInventory().getHelmet());
}
@EventHandler
public void updateFakeHelmet(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
{
return;
}
sendFakeHelmet(_entity, HELMET);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damageIncrease(CustomDamageEvent event)
{
if (event.isCancelled())
{
return;
}
LivingEntity damagee = event.GetDamageeEntity();
Player damager = event.GetDamagerPlayer(true);
if (damager == null || !damager.equals(_entity))
{
return;
}
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.NORMAL);
event.AddMod(DAMAGE_REASON, DAMAGE_FACTOR);
}
private void sendFakeHelmet(Player player, ItemStack itemStack)
{
// Magic number 4 means helmet
PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(itemStack));
for (Player other : Bukkit.getOnlinePlayers())
{
// Don't send wearer their own data
if (other.equals(player))
{
continue;
}
UtilPlayer.sendPacket(other, packet);
}
}
}

View File

@ -0,0 +1,78 @@
package nautilus.game.arcade.game.games.moba.buff.buffs;
import mineplex.core.common.events.EntityVelocityChangeEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.buff.Buff;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
public class BuffRooting extends Buff<Player>
{
public BuffRooting(Moba host, Player entity, long duration)
{
super(host, entity, duration);
}
@Override
public void onApply()
{
UtilAction.zeroVelocity(_entity);
UtilTextMiddle.display("", C.cRed + "Rooted", 10, 20, 10, (Player) _entity);
}
@Override
public void onExpire()
{
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
{
return;
}
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _entity.getLocation().add(0, 0.5, 0), 0.5F, 0.2F, 0.5F, 0.1F, 5, ViewDist.LONG);
}
@EventHandler
public void velocityApply(EntityVelocityChangeEvent event)
{
if (event.getEntity().equals(_entity))
{
event.setCancelled(true);
}
}
@EventHandler
public void move(PlayerMoveEvent event)
{
if (!event.getPlayer().equals(_entity))
{
return;
}
Location from = event.getFrom();
Location to = event.getTo();
if (from.getX() == to.getX() && from.getZ() == to.getZ())
{
return;
}
event.setTo(from);
}
}

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.biff;
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.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle;
@ -15,6 +16,8 @@ import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -114,11 +117,22 @@ public class SkillBiffDash extends HeroSkill
}
// They have just activated it
if (!UtilTime.elapsed(start, 1000) || !UtilEnt.isGrounded(player))
if (!UtilTime.elapsed(start, 1000) || player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR)
{
continue;
}
for (Block block : UtilBlock.getBlocksInRadius(player.getLocation(), 5))
{
if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > 0.5)
{
continue;
}
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
}
for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet())
{
if (isTeamDamage(player, entity))

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.moba.kit.biff;
import mineplex.core.common.events.EntityVelocityChangeEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilMath;
@ -50,7 +51,7 @@ public class SkillLeash extends HeroSkill
return;
}
List<Player> nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 5);
List<Player> nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 4);
nearbyPlayers.removeIf(other -> isTeamDamage(other, player));
if (nearbyPlayers.isEmpty())
@ -69,7 +70,7 @@ public class SkillLeash extends HeroSkill
nearby.setShouldBreakLeash(false);
nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you."));
builder.append(F.name(player.getName())).append(", ");
Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false);
Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 1, false, true, true, false);
leashedEntities.add(new LeashedEntity(Manager, nearby, player));
}

View File

@ -1,22 +1,29 @@
package nautilus.game.arcade.game.games.moba.kit.biff;
import mineplex.core.Managers;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle;
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.UtilTime;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.buff.BuffManager;
import nautilus.game.arcade.game.games.moba.buff.buffs.BuffRooting;
import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.HashSet;
import java.util.Iterator;
@ -32,6 +39,7 @@ public class SkillWarHorse extends HeroSkill
private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR);
private static final ItemStack HORSE_ARMOUR = new ItemStack(Material.IRON_BARDING);
private static final ItemStack SADDLE = new ItemStack(Material.SADDLE);
private final Set<WarHorseData> _data = new HashSet<>();
@ -65,10 +73,16 @@ public class SkillWarHorse extends HeroSkill
Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
horse.setJumpStrength(0);
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, horse.getLocation().add(0, 1, 0), 1, 1, 1, 0.1F, 50, ViewDist.LONG);
horse.getWorld().strikeLightningEffect(horse.getLocation());
horse.getWorld().playSound(horse.getLocation(), Sound.HORSE_DEATH, 1, 1.1F);
horse.setHealth(20);
horse.setMaxHealth(horse.getHealth());
horse.setJumpStrength(1);
horse.setMaxDomestication(1);
horse.setDomestication(horse.getMaxDomestication());
horse.getInventory().setArmor(HORSE_ARMOUR);
horse.getInventory().setSaddle(SADDLE);
horse.setOwner(player);
horse.setPassenger(player);
MobaUtil.setTeamEntity(horse, Manager.GetGame().GetTeam(player));
@ -78,12 +92,13 @@ public class SkillWarHorse extends HeroSkill
_data.add(new WarHorseData(player, horse));
broadcast(player);
useActiveSkill(player, 6000);
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
if (event.getType() != UpdateType.FASTER)
{
return;
}
@ -93,18 +108,32 @@ public class SkillWarHorse extends HeroSkill
while (iterator.hasNext())
{
WarHorseData data = iterator.next();
Player owner = data.Owner;
Horse horse = data.Horse;
if (UtilTime.elapsed(data.Start, 6000))
if (UtilTime.elapsed(data.Start, 6000) || horse.isDead() || !horse.isValid())
{
data.Horse.remove();
horse.getWorld().playSound(horse.getLocation(), Sound.HORSE_BREATHE, 1, 1.1F);
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, horse.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 50, ViewDist.LONG);
horse.remove();
iterator.remove();
}
else
{
Player player = data.Owner;
Location target = player.getLocation().getDirection().multiply(3).toLocation(player.getWorld());
Moba game = (Moba) Manager.GetGame();
BuffManager buffManager = game.getBuffManager();
UtilEnt.CreatureMoveFast(data.Horse, target, 3F);
for (Player player : UtilPlayer.getNearby(horse.getLocation(), 5))
{
if (isTeamDamage(owner, player) || !Recharge.Instance.use(player, GetName() + "Rooting", 2000, false, false))
{
continue;
}
owner.sendMessage(F.main("Game", "You hit " + F.name(player.getName()) + "."));
Manager.GetDamage().NewDamageEvent(player, owner, null, DamageCause.CUSTOM, 10, false, true, false, UtilEnt.getName(owner), GetName());
buffManager.apply(new BuffRooting(game, player, 1000));
}
}
}
}

View File

@ -13,6 +13,7 @@ import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -32,7 +33,6 @@ public class LeashedEntity implements Listener
UtilEnt.vegetate(_fakeLeash);
UtilEnt.silence(_fakeLeash, true);
_fakeLeash.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false));
_fakeLeash.setBaby(true);
_fakeLeash.setLeashHolder(leasher);
manager.GetGame().CreatureAllowOverride = false;
@ -56,7 +56,7 @@ public class LeashedEntity implements Listener
}
Location location = _host.getLocation();
((CraftLivingEntity) _fakeLeash).getHandle().setPosition(location.getX(), location.getY() + 0.8, location.getZ());
((CraftLivingEntity) _fakeLeash).getHandle().setPosition(location.getX(), location.getY(), location.getZ());
}
@EventHandler(priority = EventPriority.LOWEST)
@ -69,6 +69,15 @@ public class LeashedEntity implements Listener
}
}
@EventHandler
public void fakeLeashFire(EntityCombustEvent event)
{
if (event.getEntity().equals(_fakeLeash))
{
event.setCancelled(true);
}
}
public LivingEntity getHost()
{
return _host;

View File

@ -50,7 +50,7 @@ public class SkillInfinity extends HeroSkill
@EventHandler
public void interact(PlayerInteractEvent event)
{
if (!isSkillItem(event))
if (!isSkillItem(event) || _active.contains(event.getPlayer()))
{
return;
}

View File

@ -97,7 +97,7 @@ public class SkillNinjaBlade extends HeroSkill
int i = 0;
for (ItemStack itemStack : inventory.getContents())
{
if (!itemStack.equals(ACTIVE_ITEM) && UtilItem.isSword(itemStack))
if (itemStack != null && !itemStack.equals(ACTIVE_ITEM) && UtilItem.isSword(itemStack))
{
inventory.setItem(i, null);
}