Cosmetic Update
+ Added GadgetDisable Event + Renamed GadgetActivateEvent to GadgetEnable event + Added hat framework, and some example hats + Added sets and Frost Lord set + Fixed some imports + Added new way of checking ownership of gadgets + Added some utility methods to GadgetManager + Added support for alternative package name of gadgets + Fixed coal + New Blood Helix particle
This commit is contained in:
parent
b1536547d3
commit
a6a4c8be36
@ -3,11 +3,14 @@ package mineplex.core.cosmetic.ui.page;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
|
import com.sun.org.glassfish.gmbal.ManagedAttribute;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
|
@ -109,7 +109,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
itemLore.add(C.cWhite + "Your Ammo : " + C.cGreen + getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetName()));
|
itemLore.add(C.cWhite + "Your Ammo : " + C.cGreen + getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gadget.IsFree() || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(gadget.GetName()) || getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetName()) > 0)
|
if (gadget.ownsGadget(getPlayer()))
|
||||||
{
|
{
|
||||||
if (gadget.GetActive().contains(getPlayer()))
|
if (gadget.GetActive().contains(getPlayer()))
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,8 @@ import java.util.List;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -13,6 +15,7 @@ import mineplex.core.cosmetic.ui.CosmeticShop;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
|
import mineplex.core.gadget.types.HatGadget;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
|
||||||
@ -37,6 +40,14 @@ public class HatPage extends GadgetPage
|
|||||||
{
|
{
|
||||||
addGadget(gadget, slot);
|
addGadget(gadget, slot);
|
||||||
|
|
||||||
|
ItemStack item = getItem(slot);
|
||||||
|
if(item.getType() == Material.SKULL_ITEM)
|
||||||
|
{
|
||||||
|
SkullMeta data = (SkullMeta) item.getItemMeta();
|
||||||
|
data.setOwner(((SkullMeta)((HatGadget)gadget).getHelmetItem().getItemMeta()).getOwner());
|
||||||
|
item.setItemMeta(data);
|
||||||
|
}
|
||||||
|
|
||||||
if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.Morph) == gadget)
|
if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.Morph) == gadget)
|
||||||
addGlow(slot);
|
addGlow(slot);
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package mineplex.core.gadget;
|
package mineplex.core.gadget;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -38,6 +40,10 @@ import mineplex.core.gadget.gadgets.death.DeathTitan;
|
|||||||
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane;
|
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane;
|
||||||
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord;
|
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord;
|
||||||
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan;
|
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan;
|
||||||
|
import mineplex.core.gadget.gadgets.hat.HatCoal;
|
||||||
|
import mineplex.core.gadget.gadgets.hat.HatPresent;
|
||||||
|
import mineplex.core.gadget.gadgets.hat.HatSanta;
|
||||||
|
import mineplex.core.gadget.gadgets.hat.HatSnowman;
|
||||||
import mineplex.core.gadget.gadgets.item.ItemBatGun;
|
import mineplex.core.gadget.gadgets.item.ItemBatGun;
|
||||||
import mineplex.core.gadget.gadgets.item.ItemCoal;
|
import mineplex.core.gadget.gadgets.item.ItemCoal;
|
||||||
import mineplex.core.gadget.gadgets.item.ItemCoinBomb;
|
import mineplex.core.gadget.gadgets.item.ItemCoinBomb;
|
||||||
@ -83,7 +89,9 @@ import mineplex.core.gadget.gadgets.particle.ParticleHelix;
|
|||||||
import mineplex.core.gadget.gadgets.particle.ParticleLegend;
|
import mineplex.core.gadget.gadgets.particle.ParticleLegend;
|
||||||
import mineplex.core.gadget.gadgets.particle.ParticleRain;
|
import mineplex.core.gadget.gadgets.particle.ParticleRain;
|
||||||
import mineplex.core.gadget.gadgets.particle.ParticleTitan;
|
import mineplex.core.gadget.gadgets.particle.ParticleTitan;
|
||||||
|
import mineplex.core.gadget.set.SetFrostLord;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
|
import mineplex.core.gadget.types.GadgetSet;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
import mineplex.core.gadget.types.ItemGadget;
|
import mineplex.core.gadget.types.ItemGadget;
|
||||||
import mineplex.core.gadget.types.MusicGadget;
|
import mineplex.core.gadget.types.MusicGadget;
|
||||||
@ -113,6 +121,8 @@ public class GadgetManager extends MiniPlugin
|
|||||||
private NautHashMap<Player, Long> _lastMove = new NautHashMap<Player, Long>();
|
private NautHashMap<Player, Long> _lastMove = new NautHashMap<Player, Long>();
|
||||||
private NautHashMap<Player, NautHashMap<GadgetType, Gadget>> _playerActiveGadgetMap = new NautHashMap<Player, NautHashMap<GadgetType, Gadget>>();
|
private NautHashMap<Player, NautHashMap<GadgetType, Gadget>> _playerActiveGadgetMap = new NautHashMap<Player, NautHashMap<GadgetType, Gadget>>();
|
||||||
|
|
||||||
|
private HashSet<GadgetSet> _sets = new HashSet<>();
|
||||||
|
|
||||||
private boolean _hideParticles = false;
|
private boolean _hideParticles = false;
|
||||||
private int _activeItemSlot = 3;
|
private int _activeItemSlot = 3;
|
||||||
|
|
||||||
@ -133,6 +143,12 @@ public class GadgetManager extends MiniPlugin
|
|||||||
_achievementManager = achievementManager;
|
_achievementManager = achievementManager;
|
||||||
|
|
||||||
CreateGadgets();
|
CreateGadgets();
|
||||||
|
createSets();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createSets()
|
||||||
|
{
|
||||||
|
addSet(new SetFrostLord(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateGadgets()
|
private void CreateGadgets()
|
||||||
@ -218,6 +234,11 @@ public class GadgetManager extends MiniPlugin
|
|||||||
addGadget(new DoubleJumpTitan(this));
|
addGadget(new DoubleJumpTitan(this));
|
||||||
addGadget(new DoubleJumpCandyCane(this));
|
addGadget(new DoubleJumpCandyCane(this));
|
||||||
|
|
||||||
|
// Hat
|
||||||
|
addGadget(new HatSanta(this));
|
||||||
|
addGadget(new HatSnowman(this));
|
||||||
|
addGadget(new HatPresent(this));
|
||||||
|
addGadget(new HatCoal(this));
|
||||||
|
|
||||||
// Music
|
// Music
|
||||||
addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000));
|
addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000));
|
||||||
@ -233,6 +254,42 @@ public class GadgetManager extends MiniPlugin
|
|||||||
addGadget(new MusicGadget(this, "Wait Disc", new String[] {""}, -2, 2267, 238000));
|
addGadget(new MusicGadget(this, "Wait Disc", new String[] {""}, -2, 2267, 238000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Gadget getGadget(Class<? extends Gadget> c)
|
||||||
|
{
|
||||||
|
for(GadgetType type : GadgetType.values())
|
||||||
|
{
|
||||||
|
for(Gadget gadget : getGadgets(type))
|
||||||
|
{
|
||||||
|
if(gadget.getClass().equals(c)) return gadget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<GadgetSet> getSets(Gadget gadget)
|
||||||
|
{
|
||||||
|
HashSet<GadgetSet> hset = new HashSet<>();
|
||||||
|
for(GadgetSet set : _sets)
|
||||||
|
{
|
||||||
|
if(set.isPartOfSet(gadget)) hset.add(set);
|
||||||
|
}
|
||||||
|
return hset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GadgetSet getGadgetSet(Class<? extends GadgetSet> c)
|
||||||
|
{
|
||||||
|
for(GadgetSet set : _sets)
|
||||||
|
{
|
||||||
|
if(set.getClass().equals(c)) return set;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addSet(GadgetSet set)
|
||||||
|
{
|
||||||
|
_sets.add(set);
|
||||||
|
}
|
||||||
|
|
||||||
private void addGadget(Gadget gadget)
|
private void addGadget(Gadget gadget)
|
||||||
{
|
{
|
||||||
if (!_gadgets.containsKey(gadget.getGadgetType()))
|
if (!_gadgets.containsKey(gadget.getGadgetType()))
|
||||||
@ -285,56 +342,6 @@ public class GadgetManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public void RemoveItem(Player player)
|
|
||||||
{
|
|
||||||
for (GadgetType gadgetType : _gadgets.keySet())
|
|
||||||
{
|
|
||||||
for (Gadget gadget : _gadgets.get(gadgetType))
|
|
||||||
{
|
|
||||||
if (gadget instanceof ItemGadget)
|
|
||||||
{
|
|
||||||
ItemGadget item = (ItemGadget) gadget;
|
|
||||||
|
|
||||||
item.RemoveItem(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveParticle(Player player)
|
|
||||||
{
|
|
||||||
for (GadgetType gadgetType : _gadgets.keySet())
|
|
||||||
{
|
|
||||||
for (Gadget gadget : _gadgets.get(gadgetType))
|
|
||||||
{
|
|
||||||
if (gadget instanceof ParticleGadget)
|
|
||||||
{
|
|
||||||
ParticleGadget part = (ParticleGadget) gadget;
|
|
||||||
|
|
||||||
part.Disable(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveMorph(Player player)
|
|
||||||
{
|
|
||||||
for (GadgetType gadgetType : _gadgets.keySet())
|
|
||||||
{
|
|
||||||
for (Gadget gadget : _gadgets.get(gadgetType))
|
|
||||||
{
|
|
||||||
if (gadget instanceof MorphGadget)
|
|
||||||
{
|
|
||||||
MorphGadget part = (MorphGadget) gadget;
|
|
||||||
|
|
||||||
part.Disable(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void removeGadetType(Player player, GadgetType type)
|
public void removeGadetType(Player player, GadgetType type)
|
||||||
{
|
{
|
||||||
List<Gadget> gadgets = _gadgets.get(type);
|
List<Gadget> gadgets = _gadgets.get(type);
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package mineplex.core.gadget.event;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import mineplex.core.gadget.types.Gadget;
|
||||||
|
|
||||||
|
public class GadgetDisableEvent extends Event
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private Player _player;
|
||||||
|
private Gadget _gadget;
|
||||||
|
|
||||||
|
public GadgetDisableEvent(Player player, Gadget gadget)
|
||||||
|
{
|
||||||
|
_player = player;
|
||||||
|
_gadget = gadget;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer()
|
||||||
|
{
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gadget getGadget()
|
||||||
|
{
|
||||||
|
return _gadget;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -7,16 +7,17 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class GadgetActivateEvent extends Event
|
public class GadgetEnableEvent extends Event
|
||||||
{
|
{
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Player _player;
|
private Player _player;
|
||||||
private Gadget _gadget;
|
private Gadget _gadget;
|
||||||
|
|
||||||
|
|
||||||
private boolean _cancelled = false;
|
private boolean _cancelled = false;
|
||||||
|
|
||||||
public GadgetActivateEvent(Player player, Gadget gadget)
|
public GadgetEnableEvent(Player player, Gadget gadget)
|
||||||
{
|
{
|
||||||
_player = player;
|
_player = player;
|
||||||
_gadget = gadget;
|
_gadget = gadget;
|
@ -15,14 +15,14 @@ public class ArrowTrailFrostLord extends ArrowEffectGadget
|
|||||||
{
|
{
|
||||||
public ArrowTrailFrostLord(GadgetManager manager)
|
public ArrowTrailFrostLord(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Frost Lord Arrow Trail", new String[]
|
super(manager, "Arrows of the Frost Lord", new String[]
|
||||||
{
|
{
|
||||||
C.cWhite + "You are a mighty frost lord.",
|
C.cWhite + "You are a mighty frost lord.",
|
||||||
C.cWhite + "Your double jumps and arrows",
|
C.cWhite + "Your double jumps and arrows",
|
||||||
C.cWhite + "are enchanted with snow powers.",
|
C.cWhite + "are enchanted with snow powers.",
|
||||||
},
|
},
|
||||||
10,
|
10,
|
||||||
Material.SNOW_BALL, (byte)0);
|
Material.SNOW_BALL, (byte)0, "Frost Lord");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,7 @@ public class DeathFrostLord extends DeathEffectGadget
|
|||||||
C.cWhite + "are enchanted with snow powers.",
|
C.cWhite + "are enchanted with snow powers.",
|
||||||
},
|
},
|
||||||
10,
|
10,
|
||||||
Material.SNOW_BALL, (byte)0);
|
Material.SNOW_BALL, (byte)0, "Frost Lord");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -2,27 +2,25 @@ package mineplex.core.gadget.gadgets.doublejump;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
|
||||||
|
|
||||||
public class DoubleJumpFrostLord extends DoubleJumpEffectGadget
|
public class DoubleJumpFrostLord extends DoubleJumpEffectGadget
|
||||||
{
|
{
|
||||||
public DoubleJumpFrostLord(GadgetManager manager)
|
public DoubleJumpFrostLord(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Frost Lord Jump Effect", new String[]
|
super(manager, "Boots of the Frost Lord", new String[]
|
||||||
{
|
{
|
||||||
C.cWhite + "More snow incomming.",
|
C.cWhite + "More snow incomming.",
|
||||||
},
|
},
|
||||||
1,
|
1,
|
||||||
Material.SNOW_BALL, (byte)0);
|
Material.SNOW_BALL, (byte)0, "Frost Lord");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package mineplex.core.gadget.gadgets.hat;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.HatGadget;
|
||||||
|
|
||||||
|
public class HatCoal extends HatGadget
|
||||||
|
{
|
||||||
|
|
||||||
|
public HatCoal(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager, "Coal Hat", new String[]{C.cWhite + "Coal Hat"}, 10, new ItemStack(Material.COAL_BLOCK));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package mineplex.core.gadget.gadgets.hat;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.HatGadget;
|
||||||
|
|
||||||
|
public class HatPresent extends HatGadget
|
||||||
|
{
|
||||||
|
|
||||||
|
public HatPresent(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager, "Present Hat", new String[]{C.cWhite + "Present Hat"}, 10, "christmasgift");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package mineplex.core.gadget.gadgets.hat;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.HatGadget;
|
||||||
|
|
||||||
|
public class HatSanta extends HatGadget
|
||||||
|
{
|
||||||
|
|
||||||
|
public HatSanta(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager, "Santa Hat", new String[]{C.cWhite + "Santa Hat"}, 10, "Presents");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package mineplex.core.gadget.gadgets.hat;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.HatGadget;
|
||||||
|
|
||||||
|
public class HatSnowman extends HatGadget
|
||||||
|
{
|
||||||
|
|
||||||
|
public HatSnowman(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager, "Snowman Hat", new String[]{C.cWhite + "Snowman Hat"}, 10, "snowman002");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -58,17 +58,23 @@ public class ItemCoal extends ItemGadget
|
|||||||
{
|
{
|
||||||
if(Manager.getInventoryManager().Get(player).getItemCount(GetName()) >= 1000)
|
if(Manager.getInventoryManager().Get(player).getItemCount(GetName()) >= 1000)
|
||||||
{
|
{
|
||||||
player.sendMessage(F.main("Coal", "You unlocked " + C.cDGray + "COAL FUMES!"));
|
|
||||||
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 0.5, 0), 0.2f, 0.5f, 0.2f, 0, 500, ViewDist.LONG);
|
|
||||||
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, player.getLocation(), 1.5f, 0.0f, 1.5f, 0, 500, ViewDist.LONG);
|
|
||||||
player.getWorld().playSound(player.getLocation(), Sound.WITHER_DEATH, 0.8f, 0);
|
|
||||||
Manager.getInventoryManager().addItemToInventory(new Callback<Boolean>()
|
Manager.getInventoryManager().addItemToInventory(new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run(Boolean data)
|
public void run(Boolean data)
|
||||||
{
|
{
|
||||||
|
if(data)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main("Coal", "You unlocked " + C.cDGray + "COAL FUMES!"));
|
||||||
|
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 0.5, 0), 0.2f, 0.5f, 0.2f, 0, 500, ViewDist.LONG);
|
||||||
|
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, player.getLocation(), 1.5f, 0.0f, 1.5f, 0, 500, ViewDist.LONG);
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.WITHER_DEATH, 0.8f, 0);
|
||||||
|
|
||||||
Manager.getInventoryManager().addItemToInventory(player, GetName(), -1000);
|
Manager.getInventoryManager().addItemToInventory(player, GetName(), -1000);
|
||||||
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())));
|
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())));
|
||||||
|
} else {
|
||||||
|
player.sendMessage("Something went wrong...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, player, "Coal Fumes", 1);
|
}, player, "Coal Fumes", 1);
|
||||||
return;
|
return;
|
||||||
|
@ -19,7 +19,7 @@ import mineplex.core.common.util.F;
|
|||||||
import mineplex.core.common.util.UtilGear;
|
import mineplex.core.common.util.UtilGear;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
import mineplex.core.gadget.types.OutfitGadget;
|
import mineplex.core.gadget.types.OutfitGadget;
|
||||||
import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
|
import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
|
||||||
@ -41,7 +41,7 @@ public class OutfitTeam extends OutfitGadget
|
|||||||
@Override
|
@Override
|
||||||
public void Enable(Player player)
|
public void Enable(Player player)
|
||||||
{
|
{
|
||||||
GadgetActivateEvent gadgetEvent = new GadgetActivateEvent(player, this);
|
GadgetEnableEvent gadgetEvent = new GadgetEnableEvent(player, this);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
|
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
|
||||||
|
|
||||||
if (gadgetEvent.isCancelled())
|
if (gadgetEvent.isCancelled())
|
||||||
|
@ -1,28 +1,25 @@
|
|||||||
package mineplex.core.gadget.gadgets.particle;
|
package mineplex.core.gadget.gadgets.particle;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
|
||||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
|
||||||
|
|
||||||
import mineplex.core.blood.BloodEvent;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.set.SetFrostLord;
|
||||||
|
import mineplex.core.gadget.types.GadgetSet;
|
||||||
import mineplex.core.gadget.types.ParticleGadget;
|
import mineplex.core.gadget.types.ParticleGadget;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
|
||||||
|
|
||||||
public class ParticleFrostLord extends ParticleGadget
|
public class ParticleFrostLord extends ParticleGadget
|
||||||
{
|
{
|
||||||
@ -30,14 +27,14 @@ public class ParticleFrostLord extends ParticleGadget
|
|||||||
|
|
||||||
public ParticleFrostLord(GadgetManager manager)
|
public ParticleFrostLord(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Frost Lord Particle", new String[]
|
super(manager, "Wind of the Frost Lord", new String[]
|
||||||
{
|
{
|
||||||
C.cWhite + "You are a mighty frost lord.",
|
C.cWhite + "You are a mighty frost lord.",
|
||||||
C.cWhite + "Your double jumps and arrows",
|
C.cWhite + "Your double jumps and arrows",
|
||||||
C.cWhite + "are enchanted with snow powers.",
|
C.cWhite + "are enchanted with snow powers.",
|
||||||
},
|
},
|
||||||
10,
|
10,
|
||||||
Material.SNOW_BALL, (byte)0);
|
Material.SNOW_BALL, (byte)0, "Frost Lord");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -62,12 +59,19 @@ public class ParticleFrostLord extends ParticleGadget
|
|||||||
|
|
||||||
double scale = (double)(player.getTicksLived() % 50) / 50d;
|
double scale = (double)(player.getTicksLived() % 50) / 50d;
|
||||||
|
|
||||||
for (int i = 0 ; i < 8 ; i++)
|
int amount = 4;
|
||||||
|
|
||||||
|
GadgetSet set = Manager.getGadgetSet(SetFrostLord.class);
|
||||||
|
if(set.isActive(player)) amount = 6;
|
||||||
|
|
||||||
|
double ang = Math.PI*2/amount;
|
||||||
|
|
||||||
|
for (int i = 0 ; i < amount ; i++)
|
||||||
{
|
{
|
||||||
double r = (1d-scale) * Math.PI * 2;
|
double r = (1d-scale) * Math.PI * 2;
|
||||||
|
|
||||||
double x = Math.sin(r + (i * (Math.PI/4))) * (r%(Math.PI * 4)) * 0.4;
|
double x = Math.sin(r + (i * ang)) * (r%(Math.PI * 4)) * 0.4;
|
||||||
double z = Math.cos(r + (i * (Math.PI/4))) * (r%(Math.PI * 4)) * 0.4;
|
double z = Math.cos(r + (i * ang)) * (r%(Math.PI * 4)) * 0.4;
|
||||||
|
|
||||||
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(x, scale * 3, z), 0f, 0f, 0f, 0, 1,
|
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(x, scale * 3, z), 0f, 0f, 0f, 0, 1,
|
||||||
ViewDist.NORMAL, UtilServer.getPlayers());
|
ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
package mineplex.core.gadget.gadgets.particle;
|
package mineplex.core.gadget.gadgets.particle;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.types.ParticleGadget;
|
import mineplex.core.gadget.types.ParticleGadget;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
|
||||||
|
|
||||||
public class ParticleHelix extends ParticleGadget
|
public class ParticleHelix extends ParticleGadget
|
||||||
{
|
{
|
||||||
@ -49,6 +49,56 @@ public class ParticleHelix extends ParticleGadget
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
int ticks = 10;
|
||||||
|
int hticks = 40;
|
||||||
|
boolean up = player.getTicksLived()%(hticks*2) < hticks;
|
||||||
|
int tick = player.getTicksLived()%ticks;
|
||||||
|
double htick = player.getTicksLived()%hticks;
|
||||||
|
int splits = 4;
|
||||||
|
|
||||||
|
Location loc = player.getLocation().add(0, 2, 0);
|
||||||
|
|
||||||
|
for(double d = tick*(Math.PI*2/splits)/ticks; d < Math.PI*2; d += Math.PI*2/splits)
|
||||||
|
{
|
||||||
|
Vector v = new Vector(Math.sin(d), 0, Math.cos(d));
|
||||||
|
v.normalize().multiply(Math.max(0.2, Math.sin((htick/hticks)*Math.PI)*1.0));
|
||||||
|
v.setY((htick/hticks) * -2);
|
||||||
|
if(up) v.setY(-2 + 2*(htick/hticks));
|
||||||
|
|
||||||
|
|
||||||
|
// v.multiply(2).subtract(v.clone().multiply(htick/hticks));
|
||||||
|
// v.multiply(2*(htick/hticks));
|
||||||
|
|
||||||
|
Location lloc = loc.clone().add(v);
|
||||||
|
|
||||||
|
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, lloc, null, 0f, 2, ViewDist.NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(0, 0.1, 0), 0.5f, 0.1f, 0.5f, 0, 20,
|
||||||
|
// ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* With Flame
|
||||||
|
int ticks = 10;
|
||||||
|
int tick = player.getTicksLived()%ticks;
|
||||||
|
int splits = 3;
|
||||||
|
|
||||||
|
Location loc = player.getLocation().add(0, 3, 0);
|
||||||
|
|
||||||
|
for(double d = tick*(Math.PI*2/splits)/ticks; d < Math.PI*2; d += Math.PI*2/splits)
|
||||||
|
{
|
||||||
|
Vector v = new Vector(Math.sin(d), 0, Math.cos(d));
|
||||||
|
|
||||||
|
v.setY(-1.5);
|
||||||
|
|
||||||
|
UtilParticle.PlayParticleToAll(ParticleType.FLAME, loc, v, 0.1f, 0, ViewDist.NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(0, 0.1, 0), 0.5f, 0.1f, 0.5f, 0, 20,
|
||||||
|
ViewDist.NORMAL, UtilServer.getPlayers());
|
||||||
|
*/
|
||||||
|
/*
|
||||||
for (int height=0 ; height <= 20 ; height++)
|
for (int height=0 ; height <= 20 ; height++)
|
||||||
{
|
{
|
||||||
for (int i=0 ; i < 2 ; i++)
|
for (int i=0 ; i < 2 ; i++)
|
||||||
@ -73,6 +123,7 @@ public class ParticleHelix extends ParticleGadget
|
|||||||
|
|
||||||
//Sound
|
//Sound
|
||||||
player.getWorld().playSound(player.getLocation(), Sound.LAVA, 0.3f, 1f);
|
player.getWorld().playSound(player.getLocation(), Sound.LAVA, 0.3f, 1f);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,10 @@ public class ParticleTitan extends ParticleGadget
|
|||||||
boolean redstone = false;
|
boolean redstone = false;
|
||||||
|
|
||||||
if(Manager.isMoving(player))
|
if(Manager.isMoving(player))
|
||||||
r = 0.5;
|
{
|
||||||
|
UtilParticle.PlayParticleToAll(ParticleType.FLAME, player.getLocation().add(0, 0.1, 0), 0.2f, 0.1f, 0.2f, 0.015f, 3, ViewDist.NORMAL);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < total; i++)
|
for(int i = 0; i < total; i++)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package mineplex.core.gadget.set;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord;
|
||||||
|
import mineplex.core.gadget.gadgets.death.DeathFrostLord;
|
||||||
|
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord;
|
||||||
|
import mineplex.core.gadget.gadgets.particle.ParticleFrostLord;
|
||||||
|
import mineplex.core.gadget.types.GadgetSet;
|
||||||
|
|
||||||
|
public class SetFrostLord extends GadgetSet
|
||||||
|
{
|
||||||
|
|
||||||
|
public SetFrostLord(GadgetManager manager)
|
||||||
|
{
|
||||||
|
super(manager,
|
||||||
|
manager.getGadget(ArrowTrailFrostLord.class),
|
||||||
|
manager.getGadget(DeathFrostLord.class),
|
||||||
|
manager.getGadget(DoubleJumpFrostLord.class),
|
||||||
|
manager.getGadget(ParticleFrostLord.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customEnable(Player player)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main("GadgetSet", "Enabled full set of " + F.elem("Frost Lord")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customDisable(Player player)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main("GadgetSet", "Disabled full set of " + F.elem("Frost Lord")));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,9 +20,9 @@ public abstract class ArrowEffectGadget extends Gadget
|
|||||||
{
|
{
|
||||||
protected HashSet<Arrow> _arrows = new HashSet<Arrow>();
|
protected HashSet<Arrow> _arrows = new HashSet<Arrow>();
|
||||||
|
|
||||||
public ArrowEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data)
|
public ArrowEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String...altNames)
|
||||||
{
|
{
|
||||||
super(manager, GadgetType.ArrowTrail, name, desc, cost, mat, data);
|
super(manager, GadgetType.ArrowTrail, name, desc, cost, mat, data, 1, altNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,9 +9,9 @@ import mineplex.core.gadget.GadgetManager;
|
|||||||
|
|
||||||
public abstract class DeathEffectGadget extends Gadget
|
public abstract class DeathEffectGadget extends Gadget
|
||||||
{
|
{
|
||||||
public DeathEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data)
|
public DeathEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String...altNames)
|
||||||
{
|
{
|
||||||
super(manager, GadgetType.Death, name, desc, cost, mat, data);
|
super(manager, GadgetType.Death, name, desc, cost, mat, data, 1, altNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,18 +6,14 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
|
||||||
public abstract class DoubleJumpEffectGadget extends Gadget
|
public abstract class DoubleJumpEffectGadget extends Gadget
|
||||||
{
|
{
|
||||||
public DoubleJumpEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data)
|
public DoubleJumpEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String...altNames)
|
||||||
{
|
{
|
||||||
super(manager, GadgetType.DoubleJump, name, desc, cost, mat, data);
|
super(manager, GadgetType.DoubleJump, name, desc, cost, mat, data, 1, altNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,7 +7,8 @@ import mineplex.core.common.util.F;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||||
|
import mineplex.core.gadget.event.GadgetDisableEvent;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -25,18 +26,23 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
|||||||
|
|
||||||
protected HashSet<Player> _active = new HashSet<Player>();
|
protected HashSet<Player> _active = new HashSet<Player>();
|
||||||
|
|
||||||
|
private String[] _alternativePackageNames;
|
||||||
|
|
||||||
public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data)
|
public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data)
|
||||||
{
|
{
|
||||||
this(manager, gadgetType, name, desc, cost, mat, data, 1);
|
this(manager, gadgetType, name, desc, cost, mat, data, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data, int quantity)
|
public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data, int quantity, String... alternativesalepackageNames)
|
||||||
{
|
{
|
||||||
super(name, mat, data, desc, cost, quantity);
|
super(name, mat, data, desc, cost, quantity);
|
||||||
|
|
||||||
_gadgetType = gadgetType;
|
_gadgetType = gadgetType;
|
||||||
KnownPackage = false;
|
KnownPackage = false;
|
||||||
|
|
||||||
|
_alternativePackageNames = alternativesalepackageNames;
|
||||||
|
if(_alternativePackageNames == null) _alternativePackageNames = new String[0];
|
||||||
|
|
||||||
Manager = manager;
|
Manager = manager;
|
||||||
|
|
||||||
Manager.getPlugin().getServer().getPluginManager().registerEvents(this, Manager.getPlugin());
|
Manager.getPlugin().getServer().getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||||
@ -65,7 +71,7 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
|||||||
|
|
||||||
public void Enable(Player player)
|
public void Enable(Player player)
|
||||||
{
|
{
|
||||||
GadgetActivateEvent gadgetEvent = new GadgetActivateEvent(player, this);
|
GadgetEnableEvent gadgetEvent = new GadgetEnableEvent(player, this);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
|
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
|
||||||
|
|
||||||
if (gadgetEvent.isCancelled())
|
if (gadgetEvent.isCancelled())
|
||||||
@ -89,7 +95,11 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
|||||||
public void Disable(Player player)
|
public void Disable(Player player)
|
||||||
{
|
{
|
||||||
if (IsActive(player))
|
if (IsActive(player))
|
||||||
|
{
|
||||||
Manager.removeActive(player, this);
|
Manager.removeActive(player, this);
|
||||||
|
GadgetDisableEvent event = new GadgetDisableEvent(player, this);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
DisableCustom(player);
|
DisableCustom(player);
|
||||||
}
|
}
|
||||||
@ -103,5 +113,20 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean ownsGadget(Player player)
|
||||||
|
{
|
||||||
|
if(IsFree()) return true;
|
||||||
|
if(Manager.getDonationManager().Get(player.getName()).OwnsUnknownPackage(GetName())) return true;
|
||||||
|
if(Manager.getInventoryManager().Get(player).getItemCount(GetName()) > 0) return true;
|
||||||
|
|
||||||
|
for(String alt : _alternativePackageNames)
|
||||||
|
{
|
||||||
|
if(Manager.getDonationManager().Get(player.getName()).OwnsUnknownPackage(alt)) return true;
|
||||||
|
if(Manager.getInventoryManager().Get(player).getItemCount(alt) > 0) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
package mineplex.core.gadget.types;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||||
|
import mineplex.core.gadget.event.GadgetDisableEvent;
|
||||||
|
|
||||||
|
public abstract class GadgetSet implements Listener
|
||||||
|
{
|
||||||
|
|
||||||
|
private Gadget[] _gadgets;
|
||||||
|
|
||||||
|
protected GadgetManager Manager;
|
||||||
|
|
||||||
|
HashSet<Player> _active = new HashSet<>();
|
||||||
|
|
||||||
|
public GadgetSet(GadgetManager manager, Gadget... gadgets)
|
||||||
|
{
|
||||||
|
Manager = manager;
|
||||||
|
_gadgets = gadgets;
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkPlayer(Player player, Gadget gadget, boolean enable)
|
||||||
|
{
|
||||||
|
boolean wasActive = isActive(player);
|
||||||
|
|
||||||
|
for(Gadget g : _gadgets)
|
||||||
|
{
|
||||||
|
if(!g.IsActive(player) || g.equals(gadget))
|
||||||
|
{
|
||||||
|
if(enable && g.equals(gadget)) continue;
|
||||||
|
|
||||||
|
_active.remove(player);
|
||||||
|
if(wasActive) customDisable(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_active.add(player);
|
||||||
|
if(!wasActive)
|
||||||
|
{
|
||||||
|
customEnable(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onActivate(GadgetEnableEvent event)
|
||||||
|
{
|
||||||
|
checkPlayer(event.getPlayer(), event.getGadget(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDeativate(GadgetDisableEvent event)
|
||||||
|
{
|
||||||
|
checkPlayer(event.getPlayer(), event.getGadget(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive(Player player)
|
||||||
|
{
|
||||||
|
return _active.contains(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void customEnable(Player player);
|
||||||
|
|
||||||
|
|
||||||
|
public abstract void customDisable(Player player);
|
||||||
|
|
||||||
|
public Gadget[] getGadgets()
|
||||||
|
{
|
||||||
|
Gadget[] array = new Gadget[_gadgets.length];
|
||||||
|
System.arraycopy(_gadgets, 0, array, 0, array.length);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPartOfSet(Gadget gadget)
|
||||||
|
{
|
||||||
|
for(Gadget g : _gadgets)
|
||||||
|
{
|
||||||
|
if(g.equals(gadget)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
package mineplex.core.gadget.types;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
|
||||||
|
public abstract class HatGadget extends OutfitGadget
|
||||||
|
{
|
||||||
|
|
||||||
|
private ItemStack _hat;
|
||||||
|
|
||||||
|
public HatGadget(GadgetManager manager, String name, String[] desc, int cost, ItemStack item)
|
||||||
|
{
|
||||||
|
super(manager, name, desc, cost, ArmorSlot.Helmet, item.getType(), item.getData().getData());
|
||||||
|
_hat = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HatGadget(GadgetManager manager, String name, String[] desc, int cost, String playerName)
|
||||||
|
{
|
||||||
|
this(manager, name, desc, cost, getSkull(playerName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getHelmetItem()
|
||||||
|
{
|
||||||
|
return _hat.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyArmor(Player player)
|
||||||
|
{
|
||||||
|
Manager.removeGadetType(player, GadgetType.Morph);
|
||||||
|
|
||||||
|
Manager.RemoveOutfit(player, _slot);
|
||||||
|
|
||||||
|
_active.add(player);
|
||||||
|
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You put on " + F.elem(GetName()) + "."));
|
||||||
|
|
||||||
|
player.getInventory().setHelmet(getHelmetItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveArmor(Player player)
|
||||||
|
{
|
||||||
|
if (!_active.remove(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(GetName()) + "."));
|
||||||
|
|
||||||
|
player.getInventory().setHelmet(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack getSkull(String playerName)
|
||||||
|
{
|
||||||
|
SkullMeta meta = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.SKULL_ITEM);
|
||||||
|
|
||||||
|
meta.setOwner(playerName);
|
||||||
|
|
||||||
|
ItemStack stack = new ItemStack(Material.SKULL_ITEM,1 , (byte)3);
|
||||||
|
|
||||||
|
stack.setItemMeta(meta);
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GadgetType getGadgetType()
|
||||||
|
{
|
||||||
|
return GadgetType.Hat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EnableCustom(Player player)
|
||||||
|
{
|
||||||
|
ApplyArmor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void DisableCustom(Player player)
|
||||||
|
{
|
||||||
|
RemoveArmor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -8,7 +8,7 @@ import mineplex.core.common.util.UtilBlock;
|
|||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||||
import mineplex.core.gadget.event.GadgetBlockEvent;
|
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||||
import mineplex.core.gadget.gadgets.SongData;
|
import mineplex.core.gadget.gadgets.SongData;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
@ -41,7 +41,7 @@ public class MusicGadget extends Gadget
|
|||||||
@Override
|
@Override
|
||||||
public void Enable(Player player)
|
public void Enable(Player player)
|
||||||
{
|
{
|
||||||
GadgetActivateEvent gadgetEvent = new GadgetActivateEvent(player, this);
|
GadgetEnableEvent gadgetEvent = new GadgetEnableEvent(player, this);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
|
Bukkit.getServer().getPluginManager().callEvent(gadgetEvent);
|
||||||
|
|
||||||
if (gadgetEvent.isCancelled())
|
if (gadgetEvent.isCancelled())
|
||||||
|
@ -9,9 +9,9 @@ import mineplex.core.gadget.GadgetManager;
|
|||||||
|
|
||||||
public abstract class ParticleGadget extends Gadget
|
public abstract class ParticleGadget extends Gadget
|
||||||
{
|
{
|
||||||
public ParticleGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data)
|
public ParticleGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String...altNames)
|
||||||
{
|
{
|
||||||
super(manager, GadgetType.Particle, name, desc, cost, mat, data);
|
super(manager, GadgetType.Particle, name, desc, cost, mat, data, 1, altNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,7 +15,7 @@ import mineplex.core.common.util.UUIDFetcher;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
import mineplex.core.treasure.event.TreasureStartEvent;
|
import mineplex.core.treasure.event.TreasureStartEvent;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
@ -291,7 +291,7 @@ public class DisguiseCommand extends CommandBase<ArcadeManager> implements Liste
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void gadget(GadgetActivateEvent event)
|
public void gadget(GadgetEnableEvent event)
|
||||||
{
|
{
|
||||||
if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph)
|
if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph)
|
||||||
return;
|
return;
|
||||||
|
@ -25,7 +25,7 @@ import mineplex.core.disguise.disguises.DisguiseBat;
|
|||||||
import mineplex.core.disguise.disguises.DisguiseChicken;
|
import mineplex.core.disguise.disguises.DisguiseChicken;
|
||||||
import mineplex.core.disguise.disguises.DisguiseEnderman;
|
import mineplex.core.disguise.disguises.DisguiseEnderman;
|
||||||
import mineplex.core.disguise.disguises.DisguiseWither;
|
import mineplex.core.disguise.disguises.DisguiseWither;
|
||||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
import mineplex.core.give.Give;
|
import mineplex.core.give.Give;
|
||||||
@ -298,7 +298,7 @@ public class EventGame extends Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void gadgetActivate(GadgetActivateEvent event)
|
public void gadgetActivate(GadgetEnableEvent event)
|
||||||
{
|
{
|
||||||
if (!_gadgetsEnabled)
|
if (!_gadgetsEnabled)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -459,7 +459,7 @@ public class EventGame extends Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void gadgetDisable(GadgetActivateEvent event)
|
public void gadgetDisable(GadgetEnableEvent event)
|
||||||
{
|
{
|
||||||
if (_allowAllGadgets)
|
if (_allowAllGadgets)
|
||||||
return;
|
return;
|
||||||
@ -931,7 +931,7 @@ public class EventGame extends Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void activateGadget(GadgetActivateEvent event)
|
public void activateGadget(GadgetEnableEvent event)
|
||||||
{
|
{
|
||||||
for(EventArea area : _customAreas.values())
|
for(EventArea area : _customAreas.values())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user