2013-08-27 17:14:08 +02:00
|
|
|
|
package nautilus.game.arcade.kit;
|
|
|
|
|
|
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
|
import mineplex.core.common.util.UtilEnt;
|
|
|
|
|
import mineplex.core.common.util.UtilInv;
|
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
|
import nautilus.game.arcade.ArcadeFormat;
|
|
|
|
|
import nautilus.game.arcade.ArcadeManager;
|
|
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
import org.bukkit.Location;
|
2013-09-03 21:13:15 +02:00
|
|
|
|
import org.bukkit.Material;
|
2013-08-31 01:37:21 +02:00
|
|
|
|
import org.bukkit.entity.Entity;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
import org.bukkit.entity.EntityType;
|
2013-08-31 05:15:16 +02:00
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
import org.bukkit.entity.Player;
|
2013-09-02 06:40:06 +02:00
|
|
|
|
import org.bukkit.entity.Skeleton;
|
|
|
|
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
|
|
public abstract class Kit implements Listener
|
|
|
|
|
{
|
|
|
|
|
public ArcadeManager Manager;
|
|
|
|
|
|
|
|
|
|
private String _kitName;
|
|
|
|
|
private String[] _kitDesc;
|
|
|
|
|
private KitAvailability _kitAvailability;
|
|
|
|
|
|
|
|
|
|
private Perk[] _kitPerks;
|
|
|
|
|
|
|
|
|
|
protected EntityType _entityType;
|
|
|
|
|
protected ItemStack _itemInHand;
|
|
|
|
|
|
2013-09-03 21:13:15 +02:00
|
|
|
|
protected Material _displayItem;
|
|
|
|
|
|
2013-09-04 03:55:19 +02:00
|
|
|
|
public Kit(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
|
2013-08-27 17:14:08 +02:00
|
|
|
|
{
|
|
|
|
|
Manager = manager;
|
|
|
|
|
|
|
|
|
|
_kitName = name;
|
|
|
|
|
_kitDesc = kitDesc;
|
|
|
|
|
_kitPerks = kitPerks;
|
|
|
|
|
|
|
|
|
|
for (Perk perk : _kitPerks)
|
|
|
|
|
perk.SetHost(this);
|
|
|
|
|
|
|
|
|
|
_kitAvailability = kitAvailability;
|
|
|
|
|
|
|
|
|
|
_entityType = entityType;
|
|
|
|
|
_itemInHand = itemInHand;
|
2013-09-04 03:55:19 +02:00
|
|
|
|
|
|
|
|
|
_displayItem = Material.BOOK;
|
|
|
|
|
if (itemInHand != null)
|
|
|
|
|
_displayItem = itemInHand.getType();
|
2013-08-27 17:14:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String GetFormattedName()
|
|
|
|
|
{
|
|
|
|
|
return GetAvailability().GetColor() + "<EFBFBD>l" + _kitName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String GetName()
|
|
|
|
|
{
|
|
|
|
|
return _kitName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ItemStack GetItemInHand()
|
|
|
|
|
{
|
|
|
|
|
return _itemInHand;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public KitAvailability GetAvailability()
|
|
|
|
|
{
|
|
|
|
|
return _kitAvailability;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String[] GetDesc()
|
|
|
|
|
{
|
|
|
|
|
return _kitDesc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Perk[] GetPerks()
|
|
|
|
|
{
|
|
|
|
|
return _kitPerks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean HasKit(Player player)
|
|
|
|
|
{
|
|
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return Manager.GetGame().HasKit(player, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ApplyKit(Player player)
|
|
|
|
|
{
|
|
|
|
|
UtilInv.Clear(player);
|
|
|
|
|
|
|
|
|
|
for (Perk perk : _kitPerks)
|
|
|
|
|
perk.Apply(player);
|
|
|
|
|
|
|
|
|
|
GiveItems(player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract void GiveItems(Player player);
|
|
|
|
|
|
2013-08-31 01:37:21 +02:00
|
|
|
|
public Entity SpawnEntity(Location loc)
|
2013-08-27 17:14:08 +02:00
|
|
|
|
{
|
|
|
|
|
EntityType type = _entityType;
|
|
|
|
|
if (type == EntityType.PLAYER)
|
|
|
|
|
type = EntityType.ZOMBIE;
|
2013-09-11 04:22:55 +02:00
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
2013-08-31 01:37:21 +02:00
|
|
|
|
LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type);
|
2013-08-31 05:41:58 +02:00
|
|
|
|
|
2013-08-31 01:37:21 +02:00
|
|
|
|
entity.setRemoveWhenFarAway(false);
|
|
|
|
|
entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit" + (GetAvailability() == KitAvailability.Blue ? ChatColor.GRAY + " (" + ChatColor.WHITE + "Ultra" + ChatColor.GRAY + ")" : ""));
|
|
|
|
|
entity.setCustomNameVisible(true);
|
|
|
|
|
entity.getEquipment().setItemInHand(_itemInHand);
|
2013-09-02 06:40:06 +02:00
|
|
|
|
|
2013-09-11 04:22:55 +02:00
|
|
|
|
if (type == EntityType.SKELETON && (GetName().contains("Wither") || GetName().contains("Alpha")))
|
2013-09-02 06:40:06 +02:00
|
|
|
|
{
|
|
|
|
|
Skeleton skel = (Skeleton)entity;
|
|
|
|
|
skel.setSkeletonType(SkeletonType.WITHER);
|
|
|
|
|
}
|
2013-08-31 01:37:21 +02:00
|
|
|
|
|
|
|
|
|
UtilEnt.Vegetate(entity);
|
2013-12-12 11:19:58 +01:00
|
|
|
|
UtilEnt.ghost(entity, true);
|
2013-08-31 05:41:58 +02:00
|
|
|
|
|
2013-08-31 01:37:21 +02:00
|
|
|
|
SpawnCustom(entity);
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
2013-08-31 01:37:21 +02:00
|
|
|
|
return entity;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-31 05:15:16 +02:00
|
|
|
|
public void SpawnCustom(LivingEntity ent) { }
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
|
|
public void DisplayDesc(Player player)
|
|
|
|
|
{
|
|
|
|
|
for (int i=0 ; i<3 ; i++)
|
|
|
|
|
UtilPlayer.message(player, "");
|
|
|
|
|
|
|
|
|
|
UtilPlayer.message(player, ArcadeFormat.Line);
|
|
|
|
|
|
|
|
|
|
UtilPlayer.message(player, "<EFBFBD>aKit - <20>f<EFBFBD>l" + GetName());
|
|
|
|
|
|
|
|
|
|
//Desc
|
|
|
|
|
for (String line : GetDesc())
|
|
|
|
|
{
|
|
|
|
|
UtilPlayer.message(player, C.cGray + " " + line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Perk Descs
|
|
|
|
|
for (Perk perk : GetPerks())
|
|
|
|
|
{
|
|
|
|
|
if (!perk.IsVisible())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
UtilPlayer.message(player, "");
|
|
|
|
|
UtilPlayer.message(player, C.cWhite + C.Bold + perk.GetName());
|
|
|
|
|
for (String line : perk.GetDesc())
|
|
|
|
|
{
|
|
|
|
|
UtilPlayer.message(player, C.cGray + " " + line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UtilPlayer.message(player, ArcadeFormat.Line);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetCost()
|
|
|
|
|
{
|
|
|
|
|
return 2000;
|
|
|
|
|
}
|
2013-09-03 21:13:15 +02:00
|
|
|
|
|
|
|
|
|
public Material getDisplayMaterial()
|
|
|
|
|
{
|
|
|
|
|
return _displayItem;
|
|
|
|
|
}
|
2013-10-31 07:35:24 +01:00
|
|
|
|
|
|
|
|
|
public void Deselected(Player player) { }
|
|
|
|
|
|
|
|
|
|
public void Selected(Player player) { }
|
2013-08-27 17:14:08 +02:00
|
|
|
|
}
|