Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java

228 lines
4.9 KiB
Java
Raw Normal View History

2013-08-27 17:14:08 +02:00
package nautilus.game.arcade.kit;
import org.bukkit.Location;
2013-09-03 21:13:15 +02:00
import org.bukkit.Material;
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;
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;
import mineplex.core.achievement.Achievement;
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 mineplex.core.common.util.UtilServer;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.PlayerKitGiveEvent;
2013-08-27 17:14:08 +02:00
public abstract class Kit implements Listener
{
public ArcadeManager Manager;
private String _kitName;
private String[] _kitDesc;
private KitAvailability _kitAvailability;
private int _cost;
2013-08-27 17:14:08 +02:00
private Perk[] _kitPerks;
protected EntityType _entityType;
protected ItemStack _itemInHand;
2013-09-03 21:13:15 +02:00
protected Material _displayItem;
protected Achievement[] _achivementCategory;
public Kit(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
{
2014-08-04 06:31:55 +02:00
this(manager, name, kitAvailability, 2000, kitDesc, kitPerks, entityType, itemInHand);
}
public Kit(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
2013-08-27 17:14:08 +02:00
{
Manager = manager;
_kitName = name;
_kitDesc = kitDesc;
_kitPerks = kitPerks;
2013-08-27 17:14:08 +02:00
for (Perk perk : _kitPerks)
perk.SetHost(this);
_kitAvailability = kitAvailability;
_cost = cost;
2013-08-27 17:14:08 +02:00
_entityType = entityType;
_itemInHand = itemInHand;
_displayItem = Material.BOOK;
if (itemInHand != null)
_displayItem = itemInHand.getType();
2013-08-27 17:14:08 +02:00
}
public String GetFormattedName()
{
return GetAvailability().GetColor() + "§l" + _kitName;
2013-08-27 17:14:08 +02:00
}
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);
}
2013-08-27 17:14:08 +02:00
public void ApplyKit(Player player)
{
UtilInv.Clear(player);
for (Perk perk : _kitPerks)
perk.Apply(player);
GiveItemsCall(player);
2014-03-13 08:18:22 +01:00
UtilInv.Update(player);
2013-08-27 17:14:08 +02:00
}
public void GiveItemsCall(Player player)
{
GiveItems(player);
//Event
PlayerKitGiveEvent kitEvent = new PlayerKitGiveEvent(Manager.GetGame(), this, player);
UtilServer.getServer().getPluginManager().callEvent(kitEvent);
}
2013-08-27 17:14:08 +02:00
public abstract void GiveItems(Player player);
public Entity SpawnEntity(Location loc)
2013-08-27 17:14:08 +02:00
{
EntityType type = _entityType;
if (type == EntityType.PLAYER)
type = EntityType.ZOMBIE;
2013-08-27 17:14:08 +02:00
LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type);
Merge commit '13110356aabbcc69d83ce29d8f9e5bec27812009' Conflicts: Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/deathtag/kits/KitArcher.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/dragons/kits/KitCoward.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/dragons/kits/KitMarksman.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/dragons/kits/KitPyrotechnic.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/horsecharge/kits/KitDefenceArcher.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/horsecharge/kits/KitHorseKnight.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/quiver/kits/KitBrawler.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/quiver/kits/KitElementalist.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/quiver/kits/KitLeaper.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/turfforts/kits/KitInfiltrator.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/turfforts/kits/KitMarksman.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/turfforts/kits/KitShredder.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/castlesiege/kits/KitHumanElementalist.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/castlesiege/kits/KitHumanKnight.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/castlesiege/kits/KitHumanMarksman.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/castlesiege/kits/KitHumanPeasant.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/zombiesurvival/kits/KitSurvivorArcher.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/zombiesurvival/kits/KitSurvivorKnight.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/zombiesurvival/kits/KitSurvivorRogue.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/zombiesurvival/kits/KitUndeadAlpha.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java
2013-08-31 05:41:58 +02:00
entity.setRemoveWhenFarAway(false);
2014-08-04 06:31:55 +02:00
entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit");
entity.setCustomNameVisible(true);
entity.getEquipment().setItemInHand(_itemInHand);
if (type == EntityType.SKELETON && (GetName().contains("Wither") || GetName().contains("Alpha")))
{
Skeleton skel = (Skeleton)entity;
skel.setSkeletonType(SkeletonType.WITHER);
}
UtilEnt.Vegetate(entity);
UtilEnt.silence(entity, true);
UtilEnt.ghost(entity, true, false);
Merge commit '13110356aabbcc69d83ce29d8f9e5bec27812009' Conflicts: Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/deathtag/kits/KitArcher.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/dragons/kits/KitCoward.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/dragons/kits/KitMarksman.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/dragons/kits/KitPyrotechnic.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/horsecharge/kits/KitDefenceArcher.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/horsecharge/kits/KitHorseKnight.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/quiver/kits/KitBrawler.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/quiver/kits/KitElementalist.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/quiver/kits/KitLeaper.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/turfforts/kits/KitInfiltrator.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/turfforts/kits/KitMarksman.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/minigames/turfforts/kits/KitShredder.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/castlesiege/kits/KitHumanElementalist.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/castlesiege/kits/KitHumanKnight.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/castlesiege/kits/KitHumanMarksman.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/castlesiege/kits/KitHumanPeasant.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/zombiesurvival/kits/KitSurvivorArcher.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/zombiesurvival/kits/KitSurvivorKnight.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/zombiesurvival/kits/KitSurvivorRogue.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/standalone/zombiesurvival/kits/KitUndeadAlpha.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java
2013-08-31 05:41:58 +02:00
SpawnCustom(entity);
2013-08-27 17:14:08 +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, "§aKit - §f§l" + GetName());
2013-08-27 17:14:08 +02:00
//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 _cost;
2013-08-27 17:14:08 +02:00
}
2013-09-03 21:13:15 +02:00
public Material getDisplayMaterial()
{
return _displayItem;
}
public void Deselected(Player player) { }
public void Selected(Player player) { }
public void setEntityType(EntityType entityType)
{
_entityType = entityType;
}
public void setAchievementRequirements(Achievement[] category)
{
_achivementCategory = category;
}
public Achievement[] getAchievementRequirement()
{
return _achivementCategory;
}
public boolean isYoutuber(Player player)
{
return Manager.isYoutuber(player);
}
2013-08-27 17:14:08 +02:00
}