Creeper Sulphur Bomb changes

This commit is contained in:
Sam 2017-05-01 11:10:29 +01:00
parent 1cc9888e58
commit 9c9200605a

View File

@ -1,5 +1,17 @@
package nautilus.game.arcade.game.games.smash.perks.creeper; package nautilus.game.arcade.game.games.smash.perks.creeper;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.perks.SmashPerk;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -9,35 +21,94 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C; import java.util.HashMap;
import mineplex.core.common.util.F; import java.util.Map;
import mineplex.core.common.util.UtilAction; import java.util.UUID;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
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.UtilServer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.perks.SmashPerk;
public class PerkCreeperSulphurBomb extends SmashPerk implements IThrown public class PerkCreeperSulphurBomb extends SmashPerk
{ {
private static ItemStack POWDER = new ItemStack(Material.SULPHUR);
private int _cooldown; private int _cooldown;
private float _damage; private float _damage;
private float _knockbackMagnitude; private float _knockbackMagnitude;
private float _damagePowder;
private final IThrown _sulphurThrown = new IThrown()
{
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
Explode(data);
if (target == null)
{
return;
}
// Damage Event
Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, _damage, true, true, false, UtilEnt.getName(data.getThrower()), GetName());
}
@Override
public void Idle(ProjectileUser data)
{
Explode(data);
}
@Override
public void Expire(ProjectileUser data)
{
Explode(data);
}
private void Explode(ProjectileUser data)
{
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.getThrown().getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers());
data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.EXPLODE, 1f, 1.5f);
data.getThrown().remove();
}
};
private final IThrown _powderThrown = new IThrown()
{
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
Explode(data);
if (target == null)
{
return;
}
// Damage Event
Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, _damagePowder, false, true, false, UtilEnt.getName(data.getThrower()), GetName());
}
@Override
public void Idle(ProjectileUser data)
{
Explode(data);
}
@Override
public void Expire(ProjectileUser data)
{
Explode(data);
}
private void Explode(ProjectileUser data)
{
UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, data.getThrown().getLocation(), 0, 0, 0, 0, 1, ViewDist.LONG);
data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.EXPLODE, 1f, 2f);
data.getThrown().remove();
}
};
private Map<UUID, Item> _sulphur = new HashMap<>();
public PerkCreeperSulphurBomb() public PerkCreeperSulphurBomb()
{ {
@ -50,6 +121,7 @@ public class PerkCreeperSulphurBomb extends SmashPerk implements IThrown
_cooldown = getPerkTime("Cooldown"); _cooldown = getPerkTime("Cooldown");
_damage = getPerkFloat("Damage"); _damage = getPerkFloat("Damage");
_knockbackMagnitude = getPerkFloat("Knockback Magnitude"); _knockbackMagnitude = getPerkFloat("Knockback Magnitude");
_damagePowder = getPerkFloat("Damage Powder");
} }
@EventHandler @EventHandler
@ -98,9 +170,10 @@ public class PerkCreeperSulphurBomb extends SmashPerk implements IThrown
Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.COAL, (byte) 0)); Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.COAL, (byte) 0));
UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false); _sulphur.put(player.getUniqueId(), ent);
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, true, null, 1f, 1f, null, 1, UpdateType.SLOW, 0.6f); UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false);
Manager.GetProjectile().AddThrow(ent, player, _sulphurThrown, -1, true, true, true, true, null, 1f, 1f, null, 1, UpdateType.SLOW, 0.6f);
// Inform // Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
@ -109,37 +182,27 @@ public class PerkCreeperSulphurBomb extends SmashPerk implements IThrown
player.getWorld().playSound(player.getLocation(), Sound.CREEPER_DEATH, 2f, 1.5f); player.getWorld().playSound(player.getLocation(), Sound.CREEPER_DEATH, 2f, 1.5f);
} }
@Override @EventHandler
public void Collide(LivingEntity target, Block block, ProjectileUser data) public void dropPowder(UpdateEvent event)
{ {
Explode(data); if (event.getType() != UpdateType.FASTER)
if (target == null)
{ {
return; return;
} }
// Damage Event for (Map.Entry<UUID, Item> entry : _sulphur.entrySet())
Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, _damage, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); {
} Player player = UtilPlayer.searchExact(entry.getKey());
@Override if (player == null)
public void Idle(ProjectileUser data) {
{ continue;
Explode(data); }
}
@Override Item item = entry.getValue();
public void Expire(ProjectileUser data) Item powder = item.getWorld().dropItem(item.getLocation(), POWDER);
{ Manager.GetProjectile().AddThrow(powder, player, _powderThrown, -1, true, true, true, true, 1F);
Explode(data); }
}
public void Explode(ProjectileUser data)
{
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.getThrown().getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers());
data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.EXPLODE, 1f, 1.5f);
data.getThrown().remove();
} }
@EventHandler @EventHandler