2013-08-29 08:20:36 +02:00
|
|
|
package nautilus.game.arcade.kit;
|
|
|
|
|
2015-01-29 01:54:59 +01:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
2013-08-29 08:20:36 +02:00
|
|
|
import mineplex.core.common.util.C;
|
2015-01-29 01:54:59 +01:00
|
|
|
import mineplex.core.common.util.NautHashMap;
|
|
|
|
import mineplex.core.common.util.UtilGear;
|
|
|
|
import mineplex.core.common.util.UtilInv;
|
2013-08-29 08:20:36 +02:00
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
2015-01-29 01:54:59 +01:00
|
|
|
import mineplex.core.common.util.UtilServer;
|
|
|
|
import mineplex.core.common.util.UtilTextMiddle;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
2013-08-29 08:20:36 +02:00
|
|
|
import nautilus.game.arcade.ArcadeFormat;
|
|
|
|
import nautilus.game.arcade.ArcadeManager;
|
|
|
|
|
2015-01-29 01:54:59 +01:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.Sound;
|
2013-08-29 08:20:36 +02:00
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
import org.bukkit.entity.Player;
|
2015-01-29 01:54:59 +01:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
2013-08-29 08:20:36 +02:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
public abstract class SmashKit extends Kit
|
2013-09-04 03:55:19 +02:00
|
|
|
{
|
2015-01-29 01:54:59 +01:00
|
|
|
private NautHashMap<Player, Long> _superActive = new NautHashMap<Player, Long>();
|
|
|
|
|
|
|
|
private int _superCharges = 1;
|
|
|
|
private String _superName;
|
|
|
|
private long _superDuration;
|
|
|
|
private Sound _superSound;
|
|
|
|
|
2013-08-29 08:20:36 +02:00
|
|
|
public SmashKit(ArcadeManager manager, String name,
|
|
|
|
KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks,
|
2015-01-29 01:54:59 +01:00
|
|
|
EntityType entityType, ItemStack itemInHand,
|
|
|
|
String superName, long superDuration, Sound superSound)
|
2013-08-29 08:20:36 +02:00
|
|
|
{
|
2014-08-04 07:31:46 +02:00
|
|
|
super(manager, name, kitAvailability, 3000, kitDesc, kitPerks, entityType, itemInHand);
|
2015-01-29 01:54:59 +01:00
|
|
|
|
|
|
|
_superName = superName;
|
|
|
|
_superDuration = superDuration;
|
|
|
|
_superSound = superSound;
|
2013-08-29 08:20:36 +02:00
|
|
|
}
|
|
|
|
|
2014-08-04 06:31:55 +02:00
|
|
|
public SmashKit(ArcadeManager manager, String name,
|
|
|
|
KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks,
|
2015-01-29 01:54:59 +01:00
|
|
|
EntityType entityType, ItemStack itemInHand,
|
|
|
|
String superName, long superDuration, Sound superSound)
|
2014-08-04 06:31:55 +02:00
|
|
|
{
|
|
|
|
super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand);
|
2015-01-29 01:54:59 +01:00
|
|
|
|
|
|
|
_superName = superName;
|
|
|
|
_superDuration = superDuration;
|
|
|
|
_superSound = superSound;
|
2014-08-04 06:31:55 +02:00
|
|
|
}
|
|
|
|
|
2015-01-29 01:54:59 +01:00
|
|
|
@Override
|
2013-08-29 08:20:36 +02:00
|
|
|
public void DisplayDesc(Player player)
|
|
|
|
{
|
|
|
|
for (int i=0 ; i<3 ; i++)
|
|
|
|
UtilPlayer.message(player, "");
|
2013-09-04 03:55:19 +02:00
|
|
|
|
2013-08-29 08:20:36 +02:00
|
|
|
UtilPlayer.message(player, ArcadeFormat.Line);
|
|
|
|
|
2014-05-26 01:42:39 +02:00
|
|
|
UtilPlayer.message(player, "§aKit - §f§l" + GetName());
|
2013-09-02 06:40:06 +02:00
|
|
|
|
2013-08-29 08:20:36 +02:00
|
|
|
//Desc
|
|
|
|
for (String line : GetDesc())
|
|
|
|
{
|
|
|
|
UtilPlayer.message(player, C.cGray + " " + line);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Perk Descs
|
|
|
|
for (Perk perk : GetPerks())
|
|
|
|
{
|
|
|
|
if (!perk.IsVisible())
|
|
|
|
continue;
|
2013-09-02 06:40:06 +02:00
|
|
|
|
2013-08-29 08:20:36 +02:00
|
|
|
for (String line : perk.GetDesc())
|
|
|
|
{
|
|
|
|
UtilPlayer.message(player, C.cGray + " " + line);
|
|
|
|
}
|
|
|
|
}
|
2013-09-02 06:40:06 +02:00
|
|
|
|
2013-08-29 08:20:36 +02:00
|
|
|
UtilPlayer.message(player, ArcadeFormat.Line);
|
|
|
|
|
|
|
|
}
|
2015-01-29 01:54:59 +01:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void triggerSuper(PlayerInteractEvent event)
|
|
|
|
{
|
2015-01-30 01:08:23 +01:00
|
|
|
if (!Manager.GetGame().IsLive())
|
|
|
|
return;
|
|
|
|
|
2015-01-29 01:54:59 +01:00
|
|
|
if (!HasKit(event.getPlayer()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!UtilGear.isMat(event.getItem(), Material.NETHER_STAR))
|
|
|
|
return;
|
|
|
|
|
2015-01-30 01:08:23 +01:00
|
|
|
if (!Recharge.Instance.use(event.getPlayer(), _superName, 500, true, false))
|
|
|
|
return;
|
|
|
|
|
2015-01-29 01:54:59 +01:00
|
|
|
UtilInv.remove(event.getPlayer(), Material.NETHER_STAR, (byte)0, 1);
|
|
|
|
|
|
|
|
activateSuper(event.getPlayer());
|
|
|
|
|
2015-01-30 04:42:39 +01:00
|
|
|
//Heal
|
|
|
|
event.getPlayer().setHealth(event.getPlayer().getMaxHealth());
|
|
|
|
|
2015-01-29 01:54:59 +01:00
|
|
|
//Inform + Effect
|
|
|
|
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), _superSound, 20f, 1f);
|
2015-01-30 01:08:23 +01:00
|
|
|
|
|
|
|
if (Recharge.Instance.use(event.getPlayer(), _superName + " Announce", 20000, false, false))
|
|
|
|
{
|
|
|
|
Manager.GetGame().Announce(C.Bold + event.getPlayer().getName() + " activated " + C.cGreen + C.Bold + _superName + ChatColor.RESET + C.Bold + "!");
|
|
|
|
UtilTextMiddle.display("Smash Crystal", event.getPlayer().getName() + " used " + C.cGreen + _superName, 5, 50, 5, UtilServer.getPlayers());
|
|
|
|
}
|
2015-01-29 01:54:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void expireSuper(UpdateEvent event)
|
|
|
|
{
|
|
|
|
Iterator<Player> superIter = _superActive.keySet().iterator();
|
|
|
|
|
|
|
|
while (superIter.hasNext())
|
|
|
|
{
|
|
|
|
Player player = superIter.next();
|
|
|
|
|
|
|
|
if (System.currentTimeMillis() > _superActive.get(player))
|
|
|
|
{
|
|
|
|
superIter.remove();
|
|
|
|
deactivateSuper(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void deathSuper(PlayerDeathEvent event)
|
|
|
|
{
|
2015-01-30 01:08:23 +01:00
|
|
|
if (_superActive.remove(event.getEntity()) != null)
|
|
|
|
deactivateSuper(event.getEntity());
|
2015-01-29 01:54:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void activateSuper(Player player)
|
|
|
|
{
|
|
|
|
//Duration Super
|
|
|
|
if (_superDuration > 0)
|
|
|
|
{
|
|
|
|
_superActive.put(player, System.currentTimeMillis() + _superDuration);
|
|
|
|
|
|
|
|
Recharge.Instance.recharge(player, _superName);
|
|
|
|
Recharge.Instance.use(player, _superName, _superDuration, false, false);
|
|
|
|
Recharge.Instance.setDisplayForce(player, _superName, true);
|
|
|
|
Recharge.Instance.setCountdown(player, _superName, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Disable Perks for Duration
|
|
|
|
for (Perk perk : GetPerks())
|
|
|
|
if (perk instanceof SmashPerk)
|
|
|
|
((SmashPerk)perk).addSuperActive(player);
|
|
|
|
|
2015-01-30 01:08:23 +01:00
|
|
|
//Items
|
|
|
|
giveSuperItems(player);
|
|
|
|
|
2015-01-29 01:54:59 +01:00
|
|
|
//Custom
|
|
|
|
activateSuperCustom(player);
|
|
|
|
|
|
|
|
//Deactivate if instant
|
|
|
|
if (_superDuration <= 0)
|
|
|
|
{
|
|
|
|
deactivateSuper(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void activateSuperCustom(Player player)
|
|
|
|
{
|
|
|
|
//Null Default
|
|
|
|
}
|
|
|
|
|
|
|
|
public void deactivateSuper(Player player)
|
|
|
|
{
|
|
|
|
//Perks
|
|
|
|
for (Perk perk : GetPerks())
|
|
|
|
if (perk instanceof SmashPerk)
|
|
|
|
((SmashPerk)perk).removeSuperActive(player);
|
|
|
|
|
2015-01-30 01:08:23 +01:00
|
|
|
//Items
|
|
|
|
giveCoreItems(player);
|
|
|
|
|
2015-01-29 01:54:59 +01:00
|
|
|
//Custom
|
|
|
|
deactivateSuperCustom(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void deactivateSuperCustom(Player player)
|
|
|
|
{
|
|
|
|
//Null Default
|
|
|
|
}
|
|
|
|
|
|
|
|
public Collection<Player> getSuperActive()
|
|
|
|
{
|
|
|
|
return _superActive.keySet();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isSuperActive(Player player)
|
|
|
|
{
|
|
|
|
return _superActive.containsKey(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSuperName()
|
|
|
|
{
|
|
|
|
return _superName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSuperCharges()
|
|
|
|
{
|
|
|
|
return _superCharges;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSuperCharges(int charges)
|
|
|
|
{
|
|
|
|
_superCharges = charges;
|
|
|
|
}
|
2015-01-30 01:08:23 +01:00
|
|
|
|
|
|
|
public abstract void giveCoreItems(Player player);
|
|
|
|
public abstract void giveSuperItems(Player player);
|
2013-08-29 08:20:36 +02:00
|
|
|
}
|