Added lore and icon for the Santa Morph

This commit is contained in:
LCastr0 2016-12-01 01:54:53 -06:00 committed by cnr
parent 420a74a33d
commit e503654114

View File

@ -6,6 +6,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import mineplex.core.common.util.*;
import mineplex.core.recharge.Recharge;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@ -24,17 +26,6 @@ import com.mojang.authlib.GameProfile;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.SantaPresent;
@ -49,12 +40,20 @@ public class MorphSanta extends MorphGadget
{
private HashMap<Item, SantaPresent> _items = new HashMap<>();
// For some reason, present.getTicksLived() is not doing the right job here
private HashMap<Item, Long> _spawnTime = new HashMap<>();
private static final int SHARD_CHARGE = 50;
public MorphSanta(GadgetManager manager)
{
super(manager, "Santa Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER));
super(manager, "Santa Morph", UtilText.splitLinesToArray(new String[]{
C.cGray + "We're all Santa now this Holiday Season!",
"",
C.cWhite + "Left click to deliver a random gift for players who have been Naughty or Nice!",
"",
C.cRedB + "WARNING: " + ChatColor.RESET + "Delivering a gift uses shards!"
}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER));
}
@Override
@ -79,8 +78,6 @@ public class MorphSanta extends MorphGadget
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
// PRESENT
@EventHandler
public void throwPresent(PlayerInteractEvent event)
{
@ -102,9 +99,6 @@ public class MorphSanta extends MorphGadget
if (player.getItemInHand().getType() != Material.AIR)
return;
//if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics"))
//return;
if (type == 0)
{
int shards = UtilMath.rRange(250, 500);
@ -115,8 +109,11 @@ public class MorphSanta extends MorphGadget
return;
}
if (!Recharge.Instance.use(player, "Hide Gift", 30000, true, false, "Cosmetics"))
return;
Item present = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),
SkinData.PRESENT.getSkull("Present " + System.currentTimeMillis(), new ArrayList<>()));
SkinData.PRESENT.getSkull("Hidden Present " + System.currentTimeMillis(), new ArrayList<>()));
UtilAction.velocity(present, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
Manager.getDonationManager().RewardCoinsLater(this.getName() + " Present Hide", player, -(shards + SHARD_CHARGE));
@ -124,6 +121,7 @@ public class MorphSanta extends MorphGadget
present.setPickupDelay(40);
_items.put(present, new SantaPresent(player.getName(), SantaPresent.PresentType.PRESENT, shards));
_spawnTime.put(present, System.currentTimeMillis());
//Announce
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
@ -137,6 +135,9 @@ public class MorphSanta extends MorphGadget
}
else
{
if (!Recharge.Instance.use(player, "Hide Gift", 30000, true, false, "Cosmetics"))
return;
ItemStack coalStack = ItemStackFactory.Instance.CreateStack(Material.COAL, (byte)0, 1, "Hidden Coal" + System.currentTimeMillis());
Item coal = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), coalStack);
UtilAction.velocity(coal, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
@ -146,6 +147,7 @@ public class MorphSanta extends MorphGadget
coal.setPickupDelay(40);
_items.put(coal, new SantaPresent(player.getName(), SantaPresent.PresentType.COAL, coals));
_spawnTime.put(coal, System.currentTimeMillis());
//Announce
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
@ -167,6 +169,7 @@ public class MorphSanta extends MorphGadget
SantaPresent santaPresent = _items.get(event.getItem());
_items.remove(event.getItem());
_spawnTime.remove(event.getItem());
event.setCancelled(true);
event.getItem().remove();
@ -225,7 +228,7 @@ public class MorphSanta extends MorphGadget
{
Item presentItem = presentIter.next();
if (!presentItem.isValid() || presentItem.getTicksLived() > 24000)
if (!presentItem.isValid() || UtilTime.elapsed(_spawnTime.get(presentItem), 60 * 10000))
{
SantaPresent santaPresent = _items.get(presentItem);
@ -273,7 +276,7 @@ public class MorphSanta extends MorphGadget
}
@EventHandler
public void presentDespawnCancel(ItemDespawnEvent event)
public void cancelDespawn(ItemDespawnEvent event)
{
if (_items.containsKey(event.getEntity()))
event.setCancelled(true);