More changes

This commit is contained in:
Sam 2017-07-10 21:59:34 +01:00
parent 7544ff98ae
commit c18c6cfc6a
6 changed files with 239 additions and 17 deletions

View File

@ -23,6 +23,7 @@ import nautilus.game.arcade.game.games.castlesiegenew.kits.KitHumanMarksman;
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;
import nautilus.game.arcade.game.games.castlesiegenew.kits.KitUndeadSummoner;
import nautilus.game.arcade.game.games.castlesiegenew.kits.KitUndeadZombie;
import nautilus.game.arcade.game.modules.SpawnShieldModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
@ -104,6 +105,7 @@ public class CastleSiegeNew extends TeamGame
new KitUndeadGhoul(manager),
new KitUndeadArcher(manager),
new KitUndeadZombie(manager),
new KitUndeadSummoner(manager)
}, DESCRIPTION);
@ -318,7 +320,7 @@ public class CastleSiegeNew extends TeamGame
if (kit instanceof KitHumanWolf)
{
SetKit(player, GetKits()[0], false);
SetKit(player, GetKits()[1], false);
}
}
}

View File

@ -241,7 +241,7 @@ public class CastleSiegeTNTManager implements Listener
// Handle Weaknesses
for (Location location : _tntWeaknesses)
{
if (UtilMath.offsetSquared(player.getLocation(), location) < TNT_WEAKNESS_DISTANCE_SQUARED)
if (UtilMath.offsetSquared(playerLocation, location) < TNT_WEAKNESS_DISTANCE_SQUARED)
{
for (int i = 0; i < 10; i++)
{

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.castlesiegenew.kits;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.KitAvailability;
@ -11,6 +12,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
@ -52,6 +54,13 @@ public abstract class KitCastleSiege extends ProgressingKit
disguise.showArmor();
disguise.setCustomNameVisible(true);
if (_witherSkeleton)
{
DisguiseSkeleton disguiseSkeleton = (DisguiseSkeleton) disguise;
disguiseSkeleton.SetSkeletonType(SkeletonType.WITHER);
}
disguiseManager.disguise(disguise);
}
catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e)

View File

@ -2,7 +2,11 @@ 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;
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;
@ -11,6 +15,8 @@ import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class KitUndeadSummoner extends KitCastleSiege
{
@ -22,30 +28,30 @@ public class KitUndeadSummoner extends KitCastleSiege
};
private static final String LEAP = "Ghoul Leap";
private static final MobPotion SILVER_FISH = new MobPotion(
new ItemBuilder(Material.POTION)
.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 0, 0))
.build(), EntityType.SILVERFISH);
private static final Perk[][] PERKS = {
{
new PerkLeap(LEAP, 1.2, 0.8, 8000),
new PerkSpeed(0)
new PerkMobPotions(SILVER_FISH),
},
{
new PerkLeap(LEAP, 1.2, 0.8, 7500),
new PerkSpeed(0)
new PerkMobPotions(SILVER_FISH),
},
{
new PerkLeap(LEAP, 1.2, 0.8, 7000),
new PerkSpeed(0)
new PerkMobPotions(SILVER_FISH),
},
{
new PerkLeap(LEAP, 1.2, 0.8, 6500),
new PerkSpeed(0)
new PerkMobPotions(SILVER_FISH),
},
{
new PerkLeap(LEAP, 1.2, 0.8, 6000),
new PerkSpeed(0)
new PerkMobPotions(SILVER_FISH),
},
{
new PerkLeap(LEAP, 1.2, 0.8, 6000),
new PerkSpeed(0)
new PerkMobPotions(SILVER_FISH),
}
};
@ -67,11 +73,11 @@ public class KitUndeadSummoner extends KitCastleSiege
}
};
private static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE);
private static final ItemStack IN_HAND = new ItemStack(Material.POTION);
public KitUndeadSummoner(ArcadeManager manager)
{
super(manager, "Undead Ghoul", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.SKELETON, IN_HAND);
super(manager, "Undead Summoner", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.SKELETON, IN_HAND);
_witherSkeleton = true;
}
@ -80,6 +86,8 @@ public class KitUndeadSummoner extends KitCastleSiege
public void GiveItems(Player player)
{
giveItems(player);
disguise(player, DisguisePigZombie.class);
disguise(player, DisguiseSkeleton.class);
player.getInventory().addItem(SILVER_FISH.getItemStack());
}
}

View File

@ -0,0 +1,27 @@
package nautilus.game.arcade.game.games.castlesiegenew.perks;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
public class MobPotion
{
private final ItemStack _itemStack;
private final EntityType _entityType;
public MobPotion(ItemStack itemStack, EntityType entityType)
{
_itemStack = itemStack;
_entityType = entityType;
}
public ItemStack getItemStack()
{
return _itemStack;
}
public EntityType getEntityType()
{
return _entityType;
}
}

View File

@ -0,0 +1,176 @@
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.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Perk;
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.PotionSplashEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
public class PerkMobPotions extends Perk
{
private static final long MAX_TIME = TimeUnit.SECONDS.toMillis(16);
private final MobPotion[] _mobPotions;
private final Map<ThrownPotion, Pair<Player, MobPotion>> _thrownPotions = new HashMap<>();
private final Set<SummonedEntity> _entities = new HashSet<>();
public PerkMobPotions(MobPotion... mobPotions)
{
super("Mob Potions", new String[0]);
_mobPotions = mobPotions;
}
@EventHandler
public void interact(PlayerInteractEvent event)
{
if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R))
{
return;
}
Player player = event.getPlayer();
if (!hasPerk(player))
{
return;
}
MobPotion clickedPotion = null;
ItemStack itemStack = player.getItemInHand();
if (itemStack == null)
{
return;
}
for (MobPotion potion : _mobPotions)
{
if (potion.getItemStack().isSimilar(itemStack))
{
clickedPotion = potion;
break;
}
}
if (clickedPotion == null)
{
return;
}
event.setCancelled(true);
Manager.GetGame().CreatureAllowOverride = true;
Location location = player.getEyeLocation();
ThrownPotion potion = player.getWorld().spawn(location.add(location.getDirection()), ThrownPotion.class);
potion.setVelocity(location.getDirection());
_thrownPotions.put(potion, Pair.create(player, clickedPotion));
if (itemStack.getAmount() > 1)
{
itemStack.setAmount(itemStack.getAmount() - 1);
}
else
{
player.setItemInHand(null);
}
Manager.GetGame().CreatureAllowOverride = false;
}
@EventHandler
public void splash(PotionSplashEvent event)
{
ThrownPotion potion = event.getEntity();
if (!_thrownPotions.containsKey(potion))
{
return;
}
Pair<Player, MobPotion> pair = _thrownPotions.remove(potion);
Player player = pair.getLeft();
MobPotion mobPotion = pair.getRight();
Manager.GetGame().CreatureAllowOverride = true;
Monster entity = (Monster) potion.getWorld().spawnEntity(potion.getLocation(), mobPotion.getEntityType());
UtilEnt.vegetate(entity);
_entities.add(new SummonedEntity(entity, player));
Manager.GetGame().CreatureAllowOverride = false;
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
_entities.removeIf(entity -> entity.Summoned.isDead());
for (SummonedEntity entity : _entities)
{
if (UtilTime.elapsed(entity.SpawnedAt, MAX_TIME))
{
entity.Summoned.setHealth(0);
break;
}
LivingEntity target = entity.Summoned.getTarget();
if (target == null)
{
Player newTarget = UtilPlayer.getClosest(entity.Summoned.getLocation(), 10, entity.OwnerTeam.GetPlayers(true));
entity.Summoned.setTarget(newTarget);
}
}
}
private class SummonedEntity
{
Monster Summoned;
Player Owner;
GameTeam OwnerTeam;
long SpawnedAt;
SummonedEntity(Monster summoned, Player owner)
{
Summoned = summoned;
Owner = owner;
OwnerTeam = Manager.GetGame().GetTeam(owner);
SpawnedAt = System.currentTimeMillis();
}
}
}