2013-09-21 00:34:07 +02:00
|
|
|
package nautilus.game.arcade.kit.perks;
|
|
|
|
|
2014-05-28 03:38:22 +02:00
|
|
|
import org.bukkit.*;
|
2014-07-31 05:56:40 +02:00
|
|
|
import org.bukkit.entity.*;
|
2013-09-21 00:34:07 +02:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.F;
|
2013-11-15 08:52:46 +01:00
|
|
|
import mineplex.core.common.util.UtilParticle;
|
|
|
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
2013-09-21 00:34:07 +02:00
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
2014-08-22 20:30:41 +02:00
|
|
|
import mineplex.minecraft.game.core.condition.Condition;
|
|
|
|
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
2013-09-21 00:34:07 +02:00
|
|
|
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.kit.Perk;
|
|
|
|
|
2014-05-28 03:38:22 +02:00
|
|
|
import java.util.*;
|
|
|
|
|
2013-09-21 00:34:07 +02:00
|
|
|
public class PerkSmokebomb extends Perk
|
|
|
|
{
|
2014-05-28 03:38:22 +02:00
|
|
|
private final Set<Material> activatorTypes;
|
2014-07-31 04:58:33 +02:00
|
|
|
private final int effectDuration;
|
2014-05-28 03:38:22 +02:00
|
|
|
private final boolean itemConsumed;
|
|
|
|
|
2014-08-05 07:23:24 +02:00
|
|
|
public PerkSmokebomb(Material activatorType, int effectDuration, boolean itemConsumed)
|
2014-05-28 03:38:22 +02:00
|
|
|
{
|
2014-07-31 04:58:33 +02:00
|
|
|
this(activatorType, effectDuration, itemConsumed, C.cYellow + "Right-Click" + C.cGray + " to " + C.cGreen + "Smoke Bomb");
|
2014-05-28 03:38:22 +02:00
|
|
|
}
|
|
|
|
|
2014-07-31 04:58:33 +02:00
|
|
|
public PerkSmokebomb(Material activatorType, int effectDuration, boolean itemConsumed, String... description)
|
2014-05-28 03:38:22 +02:00
|
|
|
{
|
2014-07-31 04:58:33 +02:00
|
|
|
this(EnumSet.of(activatorType), effectDuration, itemConsumed, description);
|
2014-05-28 03:38:22 +02:00
|
|
|
}
|
|
|
|
|
2014-07-31 04:58:33 +02:00
|
|
|
public PerkSmokebomb(Set<Material> activatorTypes, int effectDuration, boolean itemConsumed, String... description)
|
2014-05-28 03:38:22 +02:00
|
|
|
{
|
|
|
|
super("Smoke Bomb", description);
|
|
|
|
|
|
|
|
this.activatorTypes = activatorTypes;
|
2014-07-31 04:58:33 +02:00
|
|
|
this.effectDuration = effectDuration;
|
2014-05-28 03:38:22 +02:00
|
|
|
this.itemConsumed = itemConsumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<Material> getActivatorTypes()
|
2013-09-21 00:34:07 +02:00
|
|
|
{
|
2014-05-28 03:38:22 +02:00
|
|
|
return activatorTypes;
|
|
|
|
}
|
|
|
|
|
2014-07-31 05:56:40 +02:00
|
|
|
public int getEffectDuration()
|
2014-05-28 03:38:22 +02:00
|
|
|
{
|
2014-07-31 04:58:33 +02:00
|
|
|
return effectDuration;
|
2014-05-28 03:38:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isItemConsumed()
|
|
|
|
{
|
|
|
|
return itemConsumed;
|
2013-09-21 00:34:07 +02:00
|
|
|
}
|
2014-08-05 07:23:24 +02:00
|
|
|
|
2013-09-21 00:34:07 +02:00
|
|
|
@EventHandler
|
|
|
|
public void Use(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
return;
|
2014-08-05 07:23:24 +02:00
|
|
|
|
2014-05-28 03:38:22 +02:00
|
|
|
if (!getActivatorTypes().contains(event.getPlayer().getItemInHand().getType()))
|
2014-08-05 07:23:24 +02:00
|
|
|
return;
|
2013-09-21 00:34:07 +02:00
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
2014-08-05 07:23:24 +02:00
|
|
|
if (isItemConsumed())
|
2014-05-28 03:38:22 +02:00
|
|
|
{
|
2014-08-05 07:23:24 +02:00
|
|
|
if (player.getItemInHand().getAmount() > 1)
|
2014-05-28 03:38:22 +02:00
|
|
|
player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
|
|
|
|
else
|
|
|
|
player.setItemInHand(null);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-05 07:23:24 +02:00
|
|
|
if (!Recharge.Instance.use(player, GetName(), GetName(), 20000, true, true))
|
2014-05-28 03:38:22 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-09-21 00:34:07 +02:00
|
|
|
|
2014-08-05 07:23:24 +02:00
|
|
|
//Inform
|
|
|
|
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
|
|
|
|
|
2013-09-21 00:34:07 +02:00
|
|
|
//Action
|
2014-08-10 13:05:41 +02:00
|
|
|
Manager.GetCondition().Factory().Cloak(GetName(), player, player, 1.2, false, false);
|
2014-04-02 06:19:58 +02:00
|
|
|
//Manager.GetCondition().Factory().Vulnerable(GetName(), player, player, 6, 3, false, false, true);
|
2013-09-21 00:34:07 +02:00
|
|
|
|
|
|
|
//Blind
|
2014-08-06 04:23:02 +02:00
|
|
|
for (Entity other : player.getNearbyEntities(5, 5, 5))
|
2013-09-21 00:34:07 +02:00
|
|
|
{
|
2014-07-31 05:56:40 +02:00
|
|
|
if (other.equals(player) || !(other instanceof LivingEntity))
|
2013-09-21 00:34:07 +02:00
|
|
|
continue;
|
2014-08-06 04:23:02 +02:00
|
|
|
|
|
|
|
if (other instanceof Player)
|
|
|
|
if (((Player)other).getGameMode() != GameMode.SURVIVAL)
|
|
|
|
continue;
|
2014-07-31 05:56:40 +02:00
|
|
|
|
2014-08-05 07:23:24 +02:00
|
|
|
LivingEntity living = (LivingEntity) other;
|
2014-08-06 04:23:02 +02:00
|
|
|
|
2014-08-05 07:23:24 +02:00
|
|
|
Manager.GetCondition().Factory().Blind(GetName() + " Effect", living, player, getEffectDuration(), 0, false, false, true);
|
2014-08-06 04:23:02 +02:00
|
|
|
//Manager.GetCondition().Factory().Slow(GetName() + " Effect", living, player, getEffectDuration(), 0, false, false, true, false);
|
2013-09-21 00:34:07 +02:00
|
|
|
}
|
|
|
|
|
2013-11-15 08:52:46 +01:00
|
|
|
//Effects
|
|
|
|
player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 2f, 0.5f);
|
2014-07-31 05:56:40 +02:00
|
|
|
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0f, 0f, 0f, 0, 1);
|
2013-09-21 00:34:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
|
|
public void EndDamager(CustomDamageEvent event)
|
|
|
|
{
|
|
|
|
if (event.IsCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player damager = event.GetDamagerPlayer(true);
|
2014-08-05 07:23:24 +02:00
|
|
|
if (damager == null) return;
|
2013-09-21 00:34:07 +02:00
|
|
|
|
|
|
|
if (!Kit.HasKit(damager))
|
|
|
|
return;
|
|
|
|
|
|
|
|
//End
|
|
|
|
Manager.GetCondition().EndCondition(damager, null, GetName());
|
|
|
|
}
|
2014-08-05 07:23:24 +02:00
|
|
|
|
2013-09-21 00:34:07 +02:00
|
|
|
@EventHandler
|
|
|
|
public void Smoke(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.FAST)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (Player cur : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (!Kit.HasKit(cur))
|
|
|
|
return;
|
2014-08-05 07:23:24 +02:00
|
|
|
|
2013-09-21 00:34:07 +02:00
|
|
|
Condition cond = Manager.GetCondition().GetActiveCondition(cur, ConditionType.CLOAK);
|
2014-08-05 07:23:24 +02:00
|
|
|
if (cond == null) continue;
|
2013-09-21 00:34:07 +02:00
|
|
|
|
|
|
|
if (!cond.GetReason().equals(GetName()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
//Smoke
|
|
|
|
cur.getWorld().playEffect(cur.getLocation(), Effect.SMOKE, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
2014-08-05 07:23:24 +02:00
|
|
|
public void Reset(PlayerDeathEvent event)
|
2013-09-21 00:34:07 +02:00
|
|
|
{
|
|
|
|
//Remove Condition
|
|
|
|
Manager.GetCondition().EndCondition(event.getEntity(), null, GetName());
|
|
|
|
}
|
|
|
|
}
|