Achievement Kits
This commit is contained in:
parent
115b4487ea
commit
23373834a2
@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.condition.ConditionFactory;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
@ -20,6 +21,7 @@ import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.castlesiegenew.kits.KitHumanKnight;
|
||||
import nautilus.game.arcade.game.games.castlesiegenew.kits.KitHumanMarksman;
|
||||
import nautilus.game.arcade.game.games.castlesiegenew.kits.KitHumanPaladin;
|
||||
import nautilus.game.arcade.game.games.castlesiegenew.kits.KitHumanWolf;
|
||||
import nautilus.game.arcade.game.games.castlesiegenew.kits.KitUndeadArcher;
|
||||
import nautilus.game.arcade.game.games.castlesiegenew.kits.KitUndeadGhoul;
|
||||
@ -43,6 +45,8 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@ -101,6 +105,7 @@ public class CastleSiegeNew extends TeamGame
|
||||
new KitHumanWolf(manager),
|
||||
new KitHumanMarksman(manager),
|
||||
new KitHumanKnight(manager),
|
||||
new KitHumanPaladin(manager),
|
||||
new NullKit(manager),
|
||||
new KitUndeadGhoul(manager),
|
||||
new KitUndeadArcher(manager),
|
||||
@ -119,6 +124,8 @@ public class CastleSiegeNew extends TeamGame
|
||||
BlockPlaceAllow.add(Material.FENCE.getId());
|
||||
InventoryClick = true;
|
||||
|
||||
manager.GetCreature().SetDisableCustomDrops(true);
|
||||
|
||||
registerChatStats(
|
||||
Kills,
|
||||
Deaths,
|
||||
@ -477,6 +484,30 @@ public class CastleSiegeNew extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleResistance(CustomDamageEvent event)
|
||||
{
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
|
||||
if (damagee == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (PotionEffect effect : damagee.getActivePotionEffects())
|
||||
{
|
||||
if (effect.getType().toString().equals(PotionEffectType.DAMAGE_RESISTANCE.toString()))
|
||||
{
|
||||
event.AddMod("Resistance", (effect.getAmplifier() + 1) * -0.2 * event.GetDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWolf(Player player)
|
||||
{
|
||||
return _wolves.contains(player);
|
||||
}
|
||||
|
||||
public GameTeam getDefenders()
|
||||
{
|
||||
return _defenders;
|
||||
|
@ -168,7 +168,7 @@ public class CastleSiegeTNTManager implements Listener
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
detonate(player);
|
||||
detonate(player, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -186,7 +186,7 @@ public class CastleSiegeTNTManager implements Listener
|
||||
|
||||
if (timeLeft < 0)
|
||||
{
|
||||
detonate(entry.getKey());
|
||||
detonate(entry.getKey(), false);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -211,16 +211,16 @@ public class CastleSiegeTNTManager implements Listener
|
||||
@EventHandler
|
||||
public void playerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
detonate(event.getEntity());
|
||||
detonate(event.getEntity(), false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
detonate(event.getPlayer());
|
||||
detonate(event.getPlayer(), false);
|
||||
}
|
||||
|
||||
private void detonate(Player player)
|
||||
private void detonate(Player player, boolean triggered)
|
||||
{
|
||||
if (!_tntCarrier.containsKey(player) || !Recharge.Instance.use(player, "Prevent Double Detonation", 1000, false, false))
|
||||
{
|
||||
@ -233,7 +233,15 @@ public class CastleSiegeTNTManager implements Listener
|
||||
{
|
||||
if (UtilMath.offsetSquared(location, playerLocation) < TOO_FAR_FROM_CASTLE_SQUARED)
|
||||
{
|
||||
player.sendMessage(F.main("Game", "You cannot " + F.skill("Detonate") + " so far from the Castle."));
|
||||
if (triggered)
|
||||
{
|
||||
player.sendMessage(F.main("Game", "You cannot " + F.skill("Detonate") + " so far from the Castle."));
|
||||
}
|
||||
else
|
||||
{
|
||||
_tntCarrier.remove(player);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class KitHumanKnight extends KitCastleSiege
|
||||
{
|
||||
|
||||
private static final String[] DESCRIPTION = {
|
||||
"Robust knight, also able to construct defenses.",
|
||||
"Master fencer at your service; both the sport, and the job..",
|
||||
"",
|
||||
receiveItem("Fence", 1, 40, 2),
|
||||
"Take " + C.cGreen + "85%" + C.cWhite + " knockback",
|
||||
@ -40,15 +40,15 @@ public class KitHumanKnight extends KitCastleSiege
|
||||
},
|
||||
{
|
||||
new PerkMammoth(),
|
||||
new PerkConstructor("Constructor", 40, 2, Material.FENCE, "Castle Barricade", true)
|
||||
new PerkConstructor("Constructor", 40, 3, Material.FENCE, "Castle Barricade", true)
|
||||
},
|
||||
{
|
||||
new PerkMammoth(),
|
||||
new PerkConstructor("Constructor", 40, 2, Material.FENCE, "Castle Barricade", true)
|
||||
new PerkConstructor("Constructor", 40, 3, Material.FENCE, "Castle Barricade", true)
|
||||
},
|
||||
{
|
||||
new PerkMammoth(),
|
||||
new PerkConstructor("Constructor", 40, 2, Material.FENCE, "Castle Barricade", true)
|
||||
new PerkConstructor("Constructor", 40, 3, Material.FENCE, "Castle Barricade", true)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,150 @@
|
||||
package nautilus.game.arcade.game.games.castlesiegenew.kits;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.castlesiegenew.perks.PerkPaladinBoost;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import nautilus.game.arcade.kit.perks.PerkIronSkin;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class KitHumanPaladin extends KitCastleSiege
|
||||
{
|
||||
|
||||
private static final String[] DESCRIPTION = {
|
||||
"Stand your ground, we got this!",
|
||||
"",
|
||||
click(false, "your sword") + " to give buffs to nearby humans and wolves",
|
||||
"Wolves receive " + C.cGreen + "Speed I" + C.cWhite + " and Humans receive " + C.cGreen + "Resistance I",
|
||||
"Take " + C.cGreen + "20%" + C.cWhite + " less damage from attacks",
|
||||
};
|
||||
|
||||
private static final String BOOST = C.cGreen + "Morale Royale" + C.cWhite;
|
||||
private static final int EIGHT_TICKS = 8 * 20;
|
||||
private static final int TEN_TICKS = 8 * 20;
|
||||
private static final int TWELEVE_TICKS = 8 * 20;
|
||||
private static final Perk[][] PERKS = {
|
||||
{
|
||||
new PerkIronSkin(0.2, true),
|
||||
new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(28),
|
||||
new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, EIGHT_TICKS, 0, false, false)
|
||||
)
|
||||
},
|
||||
{
|
||||
new PerkIronSkin(0.2, true),
|
||||
new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(28),
|
||||
new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, TEN_TICKS, 0, false, false),
|
||||
new PotionEffect(PotionEffectType.REGENERATION, TEN_TICKS, 0, false, false)
|
||||
)
|
||||
},
|
||||
{
|
||||
new PerkIronSkin(0.2, true),
|
||||
new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(26),
|
||||
new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, TEN_TICKS, 0, false, false),
|
||||
new PotionEffect(PotionEffectType.REGENERATION, TEN_TICKS, 0, false, false),
|
||||
new PotionEffect(PotionEffectType.HEALTH_BOOST, TEN_TICKS, 0, false, false)
|
||||
)
|
||||
},
|
||||
{
|
||||
new PerkIronSkin(0.2, true),
|
||||
new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(26),
|
||||
new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, TWELEVE_TICKS, 0, false, false),
|
||||
new PotionEffect(PotionEffectType.REGENERATION, TWELEVE_TICKS, 1, false, false),
|
||||
new PotionEffect(PotionEffectType.HEALTH_BOOST, TWELEVE_TICKS, 0, false, false)
|
||||
)
|
||||
},
|
||||
{
|
||||
new PerkIronSkin(0.2, true),
|
||||
new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(24),
|
||||
new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, TWELEVE_TICKS, 1, false, false),
|
||||
new PotionEffect(PotionEffectType.REGENERATION, TWELEVE_TICKS, 1, false, false),
|
||||
new PotionEffect(PotionEffectType.HEALTH_BOOST, TWELEVE_TICKS, 0, false, false)
|
||||
)
|
||||
},
|
||||
{
|
||||
new PerkIronSkin(0.4, true),
|
||||
new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(24),
|
||||
new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, TWELEVE_TICKS, 1, false, false),
|
||||
new PotionEffect(PotionEffectType.REGENERATION, TWELEVE_TICKS, 1, false, false),
|
||||
new PotionEffect(PotionEffectType.HEALTH_BOOST, TWELEVE_TICKS, 1, false, false)
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
private static String giveEffect(String effect)
|
||||
{
|
||||
return BOOST + " gives " + C.cGreen + effect;
|
||||
}
|
||||
|
||||
private static final String REDUCE_COOLDOWN = reduceCooldown(BOOST, 2);
|
||||
private static final String INCREASE_LENGTH = increaseNumber(BOOST, "Buff Length", 2, "seconds");
|
||||
|
||||
private static final String[][] UPGRADES = {
|
||||
{
|
||||
INCREASE_LENGTH,
|
||||
giveEffect("Regeneration I")
|
||||
},
|
||||
{
|
||||
REDUCE_COOLDOWN,
|
||||
giveEffect("Health Boost I")
|
||||
},
|
||||
{
|
||||
INCREASE_LENGTH,
|
||||
giveEffect("Regeneration II")
|
||||
},
|
||||
{
|
||||
REDUCE_COOLDOWN,
|
||||
giveEffect("Resistance II")
|
||||
},
|
||||
{
|
||||
"Take " + C.cGreen + "40%" + C.cWhite + " less damage from attacks",
|
||||
giveEffect("Health Boost II")
|
||||
}
|
||||
};
|
||||
|
||||
private static final ItemStack[] PLAYER_ITEMS = {
|
||||
ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD),
|
||||
ItemStackFactory.Instance.CreateStack(Material.BOW),
|
||||
ItemStackFactory.Instance.CreateStack(Material.ARROW, 64),
|
||||
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
|
||||
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
|
||||
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
|
||||
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)
|
||||
};
|
||||
|
||||
private static final ItemStack[] ARMOR = {
|
||||
ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS),
|
||||
ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS),
|
||||
ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE),
|
||||
ItemStackFactory.Instance.CreateStack(Material.GOLD_HELMET)
|
||||
};
|
||||
|
||||
public static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD);
|
||||
|
||||
public KitHumanPaladin(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Castle Paladin", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.ZOMBIE, IN_HAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
player.getInventory().addItem(PLAYER_ITEMS);
|
||||
player.getInventory().setArmorContents(ARMOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpawnCustom(LivingEntity ent)
|
||||
{
|
||||
ent.getEquipment().setArmorContents(ARMOR);
|
||||
}
|
||||
}
|
@ -28,7 +28,9 @@ public class KitHumanWolf extends KitCastleSiege
|
||||
{
|
||||
|
||||
private static final String[] DESCRIPTION = {
|
||||
"My bark is as strong as my bite."
|
||||
"My bark is as strong as my bite.",
|
||||
"",
|
||||
C.cWhiteB + "THIS KIT IS GIVEN TO DEFENDERS WHEN THEY " + C.cRedB + "DIE"
|
||||
};
|
||||
|
||||
private static final Perk[][] PERKS = {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package nautilus.game.arcade.game.games.castlesiegenew.kits;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.disguise.disguises.DisguisePigZombie;
|
||||
import mineplex.core.disguise.disguises.DisguiseSkeleton;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
@ -9,8 +8,6 @@ import nautilus.game.arcade.game.games.castlesiegenew.perks.MobPotion;
|
||||
import nautilus.game.arcade.game.games.castlesiegenew.perks.PerkMobPotions;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import nautilus.game.arcade.kit.perks.PerkLeap;
|
||||
import nautilus.game.arcade.kit.perks.PerkSpeed;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,56 +15,68 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class KitUndeadSummoner extends KitCastleSiege
|
||||
{
|
||||
|
||||
private static final String[] DESCRIPTION = {
|
||||
"The walls thought they were too high for me; I proved them wrong.",
|
||||
"I hope I’m not bugging you.",
|
||||
"",
|
||||
click(false, "your axe to use " + C.cGreen + "Ghoul Leap"),
|
||||
};
|
||||
|
||||
private static final String LEAP = "Ghoul Leap";
|
||||
private static final String REDUCE_COOLDOWN = reduceCooldown("Undead Potions", 2);
|
||||
|
||||
private static final MobPotion SILVER_FISH = new MobPotion(
|
||||
new ItemBuilder(Material.POTION)
|
||||
.setTitle(C.cGreen + "Silver Fish Potion")
|
||||
.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 0, 0))
|
||||
.build(), EntityType.SILVERFISH);
|
||||
.build(), EntityType.SILVERFISH, 3);
|
||||
private static final MobPotion ZOMBIE = new MobPotion(
|
||||
new ItemBuilder(Material.POTION)
|
||||
.setTitle(C.cGreen + "Zombie Potion")
|
||||
.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 0, 0))
|
||||
.build(), EntityType.ZOMBIE, 1);
|
||||
private static final MobPotion SPIDER = new MobPotion(
|
||||
new ItemBuilder(Material.POTION)
|
||||
.setTitle(C.cGreen + "Spider Potion")
|
||||
.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 0, 0))
|
||||
.build(), EntityType.SPIDER, 1);
|
||||
|
||||
private static final Perk[][] PERKS = {
|
||||
{
|
||||
new PerkMobPotions(SILVER_FISH),
|
||||
new PerkMobPotions(TimeUnit.SECONDS.toMillis(32), SILVER_FISH),
|
||||
},
|
||||
{
|
||||
new PerkMobPotions(SILVER_FISH),
|
||||
new PerkMobPotions(TimeUnit.SECONDS.toMillis(32), SILVER_FISH, ZOMBIE),
|
||||
},
|
||||
{
|
||||
new PerkMobPotions(SILVER_FISH),
|
||||
new PerkMobPotions(TimeUnit.SECONDS.toMillis(32), SILVER_FISH, ZOMBIE, SPIDER),
|
||||
},
|
||||
{
|
||||
new PerkMobPotions(SILVER_FISH),
|
||||
new PerkMobPotions(TimeUnit.SECONDS.toMillis(30), SILVER_FISH, ZOMBIE, SPIDER),
|
||||
},
|
||||
{
|
||||
new PerkMobPotions(SILVER_FISH),
|
||||
new PerkMobPotions(TimeUnit.SECONDS.toMillis(28), SILVER_FISH, ZOMBIE, SPIDER),
|
||||
},
|
||||
{
|
||||
new PerkMobPotions(SILVER_FISH),
|
||||
new PerkMobPotions(TimeUnit.SECONDS.toMillis(28), SILVER_FISH, ZOMBIE, SPIDER),
|
||||
}
|
||||
};
|
||||
|
||||
private static final String[][] UPGRADES = {
|
||||
{
|
||||
reduceCooldown(LEAP, 1)
|
||||
receiveItem("Zombie Potion", 1)
|
||||
},
|
||||
{
|
||||
reduceCooldown(LEAP, 1)
|
||||
receiveItem("Spider Potion", 1)
|
||||
},
|
||||
{
|
||||
reduceCooldown(LEAP, 1)
|
||||
REDUCE_COOLDOWN
|
||||
},
|
||||
{
|
||||
reduceCooldown(LEAP, 1)
|
||||
REDUCE_COOLDOWN
|
||||
},
|
||||
{
|
||||
REPLACE_AXE
|
||||
@ -89,6 +98,15 @@ public class KitUndeadSummoner extends KitCastleSiege
|
||||
giveItems(player);
|
||||
disguise(player, DisguiseSkeleton.class);
|
||||
|
||||
player.getInventory().addItem(SILVER_FISH.getItemStack());
|
||||
int level = getUpgradeLevel(player.getUniqueId());
|
||||
Perk[] perks = PERKS[level];
|
||||
|
||||
for (Perk perk : perks)
|
||||
{
|
||||
for (MobPotion potion : ((PerkMobPotions) perk).getMobPotions())
|
||||
{
|
||||
player.getInventory().addItem(potion.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,13 @@ public class MobPotion
|
||||
|
||||
private final ItemStack _itemStack;
|
||||
private final EntityType _entityType;
|
||||
private final int _amount;
|
||||
|
||||
public MobPotion(ItemStack itemStack, EntityType entityType)
|
||||
public MobPotion(ItemStack itemStack, EntityType entityType, int amount)
|
||||
{
|
||||
_itemStack = itemStack;
|
||||
_entityType = entityType;
|
||||
_amount = amount;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
@ -24,4 +26,9 @@ public class MobPotion
|
||||
{
|
||||
return _entityType;
|
||||
}
|
||||
|
||||
public int getAmount()
|
||||
{
|
||||
return _amount;
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,29 @@
|
||||
package nautilus.game.arcade.game.games.castlesiegenew.perks;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
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.GameTeam;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -30,15 +35,18 @@ public class PerkMobPotions extends Perk
|
||||
{
|
||||
|
||||
private static final long MAX_TIME = TimeUnit.SECONDS.toMillis(16);
|
||||
private static final PotionEffect SPEED = new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, false, false);
|
||||
|
||||
private final MobPotion[] _mobPotions;
|
||||
private final Map<ThrownPotion, Pair<Player, MobPotion>> _thrownPotions = new HashMap<>();
|
||||
private final Set<SummonedEntity> _entities = new HashSet<>();
|
||||
private final long _cooldown;
|
||||
|
||||
public PerkMobPotions(MobPotion... mobPotions)
|
||||
public PerkMobPotions(long cooldown, MobPotion... mobPotions)
|
||||
{
|
||||
super("Mob Potions", new String[0]);
|
||||
super("Mob Potions");
|
||||
|
||||
_cooldown = cooldown;
|
||||
_mobPotions = mobPotions;
|
||||
}
|
||||
|
||||
@ -74,7 +82,7 @@ public class PerkMobPotions extends Perk
|
||||
}
|
||||
}
|
||||
|
||||
if (clickedPotion == null)
|
||||
if (clickedPotion == null || !Recharge.Instance.use(player, ChatColor.stripColor(clickedPotion.getItemStack().getItemMeta().getDisplayName()), _cooldown, true, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -89,14 +97,14 @@ public class PerkMobPotions extends Perk
|
||||
|
||||
_thrownPotions.put(potion, Pair.create(player, clickedPotion));
|
||||
|
||||
if (itemStack.getAmount() > 1)
|
||||
{
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setItemInHand(null);
|
||||
}
|
||||
// if (itemStack.getAmount() > 1)
|
||||
// {
|
||||
// itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// player.setItemInHand(null);
|
||||
// }
|
||||
|
||||
Manager.GetGame().CreatureAllowOverride = false;
|
||||
}
|
||||
@ -117,11 +125,13 @@ public class PerkMobPotions extends Perk
|
||||
|
||||
Manager.GetGame().CreatureAllowOverride = true;
|
||||
|
||||
Monster entity = (Monster) potion.getWorld().spawnEntity(potion.getLocation(), mobPotion.getEntityType());
|
||||
for (int i = 0; i < mobPotion.getAmount(); i++)
|
||||
{
|
||||
Monster entity = (Monster) potion.getWorld().spawnEntity(potion.getLocation(), mobPotion.getEntityType());
|
||||
entity.addPotionEffect(SPEED);
|
||||
|
||||
//UtilEnt.vegetate(entity);
|
||||
|
||||
_entities.add(new SummonedEntity(entity, player));
|
||||
_entities.add(new SummonedEntity(entity, player));
|
||||
}
|
||||
|
||||
Manager.GetGame().CreatureAllowOverride = false;
|
||||
}
|
||||
@ -134,27 +144,67 @@ public class PerkMobPotions extends Perk
|
||||
return;
|
||||
}
|
||||
|
||||
_entities.removeIf(entity -> entity.Summoned.isDead());
|
||||
|
||||
for (SummonedEntity entity : _entities)
|
||||
_entities.removeIf(entity ->
|
||||
{
|
||||
if (UtilTime.elapsed(entity.SpawnedAt, MAX_TIME))
|
||||
{
|
||||
entity.Summoned.setHealth(0);
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
|
||||
LivingEntity target = entity.Summoned.getTarget();
|
||||
return entity.Summoned.isDead();
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void entityTarget(EntityTargetEvent event)
|
||||
{
|
||||
for (SummonedEntity entity : _entities)
|
||||
{
|
||||
if (!event.getEntity().equals(entity.Summoned))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
LivingEntity target = getNewTarget(entity);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
Player newTarget = UtilPlayer.getClosest(entity.Summoned.getLocation(), 10, entity.OwnerTeam.GetPlayers(true));
|
||||
|
||||
entity.Summoned.setTarget(newTarget);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setTarget(target);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void entityTarget(EntityDeathEvent event)
|
||||
{
|
||||
for (SummonedEntity entity : _entities)
|
||||
{
|
||||
if (!event.getEntity().equals(entity.Summoned))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setDroppedExp(0);
|
||||
event.getDrops().clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public MobPotion[] getMobPotions()
|
||||
{
|
||||
return _mobPotions;
|
||||
}
|
||||
|
||||
private LivingEntity getNewTarget(SummonedEntity entity)
|
||||
{
|
||||
return UtilPlayer.getClosest(entity.Summoned.getLocation(), 10, entity.OwnerTeam.GetPlayers(true));
|
||||
}
|
||||
|
||||
private class SummonedEntity
|
||||
{
|
||||
|
||||
|
@ -0,0 +1,84 @@
|
||||
package nautilus.game.arcade.game.games.castlesiegenew.perks;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
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.recharge.Recharge;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class PerkPaladinBoost extends Perk
|
||||
{
|
||||
|
||||
private static final int RADIUS = 6;
|
||||
|
||||
private final long _cooldown;
|
||||
private final PotionEffect[] _effects;
|
||||
|
||||
public PerkPaladinBoost(long cooldown, PotionEffect... effects)
|
||||
{
|
||||
super("Morale Royale");
|
||||
|
||||
_cooldown = cooldown;
|
||||
_effects = effects;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void interact(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
|
||||
if (!hasPerk(player) || !UtilItem.isSword(itemStack) || !Recharge.Instance.use(player, GetName(), _cooldown, true, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CastleSiegeNew game = (CastleSiegeNew) Manager.GetGame();
|
||||
GameTeam team = game.GetTeam(player);
|
||||
|
||||
player.sendMessage(F.main("Game", "You used " + F.name(GetName()) + "."));
|
||||
|
||||
for (Player nearby : UtilPlayer.getNearby(player.getLocation(), RADIUS))
|
||||
{
|
||||
if (player.equals(nearby) || !team.HasPlayer(nearby))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HEART, nearby.getLocation().add(0, 1, 0), 1, 1, 1, 0.01F, 8, ViewDist.LONG);
|
||||
nearby.playSound(nearby.getLocation(), Sound.ZOMBIE_REMEDY, 1, 0.6F);
|
||||
nearby.sendMessage(F.main("Game", "Paladin " + F.name(player.getName()) + " has given you buffs!"));
|
||||
|
||||
boolean wolf = game.isWolf(nearby);
|
||||
|
||||
for (PotionEffect effect : _effects)
|
||||
{
|
||||
if (effect.getType() == PotionEffectType.DAMAGE_RESISTANCE && wolf)
|
||||
{
|
||||
effect = new PotionEffect(PotionEffectType.SPEED, effect.getDuration(), 0, effect.isAmbient(), effect.hasParticles());
|
||||
}
|
||||
|
||||
nearby.addPotionEffect(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -104,7 +104,7 @@ public class SpawnShieldModule extends Module
|
||||
|
||||
if (UtilMath.offsetSquared(player.getLocation(), shield.Center) < _damageRadiusSquared)
|
||||
{
|
||||
getGame().Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, _damage, false, true, true, getGame().GetName(), "Spawn Shield");
|
||||
getGame().Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, _damage, false, true, true, getGame().GetName(), "Spawn Shield");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -157,17 +157,19 @@ public class SpawnShieldModule extends Module
|
||||
@EventHandler
|
||||
public void onCustomDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamageeEntity() instanceof Player)
|
||||
{
|
||||
Player player = event.GetDamageePlayer();
|
||||
Player player = event.GetDamageePlayer();
|
||||
|
||||
for (Shield shield : _shields)
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Shield shield : _shields)
|
||||
{
|
||||
if (shield.ShouldNotAffect.test(player) && UtilMath.offsetSquared(player.getLocation(), shield.Center) < _damageRadiusSquared)
|
||||
{
|
||||
if (shield.ShouldNotAffect.test(player) && UtilMath.offsetSquared(player.getLocation(), shield.Center) < _damageRadiusSquared)
|
||||
{
|
||||
event.SetCancelled("Spawn Shield");
|
||||
return;
|
||||
}
|
||||
event.SetCancelled("Spawn Shield");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class PerkConstructor extends Perk
|
||||
|
||||
for (Player cur : UtilServer.getPlayers())
|
||||
{
|
||||
if (!Kit.HasKit(cur))
|
||||
if (!hasPerk(cur))
|
||||
continue;
|
||||
|
||||
if (!Manager.GetGame().IsAlive(cur))
|
||||
|
@ -33,71 +33,27 @@ public class PerkIronSkin extends Perk
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void DamageDecrease(CustomDamageEvent event)
|
||||
public void damageDecrease(CustomDamageEvent event)
|
||||
{
|
||||
if (event.IsCancelled())
|
||||
return;
|
||||
|
||||
if (event.GetCause() == DamageCause.FIRE_TICK)
|
||||
return;
|
||||
|
||||
if (event.GetDamage() <= 1)
|
||||
if (event.IsCancelled() || event.GetCause() == DamageCause.FIRE_TICK || event.GetDamage() <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
if (damagee == null) return;
|
||||
|
||||
if (!Kit.HasKit(damagee))
|
||||
return;
|
||||
|
||||
if (!hasPerk(damagee))
|
||||
|
||||
if (damagee == null || !hasPerk(damagee))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_percentage)
|
||||
{
|
||||
event.AddMult(damagee.getName(), GetName(), _reduction, false);
|
||||
event.AddMod(damagee.getName(), GetName(), -_reduction * event.GetDamage(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
event.AddMod(damagee.getName(), GetName(), -_reduction, false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void damageDecrease(EntityDamageEvent event)
|
||||
{
|
||||
if (Managers.get(DamageManager.class).IsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCause() == DamageCause.FIRE_TICK)
|
||||
return;
|
||||
|
||||
if (event.getDamage() <= 1)
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
Player damagee = (Player) event.getEntity();
|
||||
|
||||
if (!Kit.HasKit(damagee))
|
||||
return;
|
||||
|
||||
if (!hasPerk(damagee))
|
||||
return;
|
||||
|
||||
if (!Manager.IsAlive(damagee))
|
||||
return;
|
||||
|
||||
if (_percentage)
|
||||
{
|
||||
event.setDamage(event.getDamage() * _reduction);
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setDamage(event.getDamage() - _reduction);
|
||||
}
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class PerkKnockbackGive extends Perk
|
||||
Player damager = event.GetDamagerPlayer(false);
|
||||
if (damager == null) return;
|
||||
|
||||
if (!Kit.HasKit(damager))
|
||||
if (!hasPerk(damager))
|
||||
return;
|
||||
|
||||
if (!Manager.IsAlive(damager))
|
||||
|
@ -1,17 +1,7 @@
|
||||
package nautilus.game.arcade.kit.perks;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
@ -20,8 +10,19 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import nautilus.game.arcade.kit.perks.event.PerkLeapEvent;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PerkLeap extends Perk
|
||||
{
|
||||
private String _name;
|
||||
@ -30,7 +31,7 @@ public class PerkLeap extends Perk
|
||||
private long _recharge;
|
||||
private int _maxUses;
|
||||
|
||||
private NautHashMap<String, Integer> _uses = new NautHashMap<String, Integer>();
|
||||
private Map<String, Integer> _uses = new HashMap<>();
|
||||
|
||||
public PerkLeap(String name, double power, double heightLimit, long recharge)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ public class PerkMammoth extends Perk
|
||||
Player damager = event.GetDamagerPlayer(false);
|
||||
if (damager == null) return;
|
||||
|
||||
if (!Kit.HasKit(damager))
|
||||
if (!hasPerk(damager))
|
||||
return;
|
||||
|
||||
event.AddKnockback(GetName(), 1.15d);
|
||||
@ -42,7 +42,7 @@ public class PerkMammoth extends Perk
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
if (damagee == null) return;
|
||||
|
||||
if (!Kit.HasKit(damagee))
|
||||
if (!hasPerk(damagee))
|
||||
return;
|
||||
|
||||
event.AddKnockback(GetName(), 0.85d);
|
||||
|
@ -33,7 +33,7 @@ public class PerkRegeneration extends Perk
|
||||
|
||||
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
if (!Kit.HasKit(player))
|
||||
if (!hasPerk(player))
|
||||
continue;
|
||||
|
||||
Manager.GetCondition().Factory().Regen(GetName(), player, player, 8, _level, false, false, true);
|
||||
|
Loading…
Reference in New Issue
Block a user