Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/gem-hunters

This commit is contained in:
Sam 2016-12-28 22:33:04 +00:00
commit 0ba22f9201
50 changed files with 831 additions and 199 deletions

View File

@ -1,5 +1,21 @@
package mineplex.core.cosmetic;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.boosters.BoosterManager;
@ -10,6 +26,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.MorphDinnerbone;
import mineplex.core.gadget.gadgets.outfit.OutfitTeam;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
@ -18,15 +35,6 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.mount.MountManager;
import mineplex.core.pet.PetManager;
import mineplex.core.treasure.TreasureManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class CosmeticManager extends MiniPlugin
{
@ -138,6 +146,30 @@ public class CosmeticManager extends MiniPlugin
}
}
// Allows player to open cosmetic shop while carrying armor stand
// Also calls PlayerInteractEvent to open other menus
@EventHandler
public void openShop(PlayerInteractAtEntityEvent event)
{
if (!_showInterface)
return;
Player player = event.getPlayer();
if (!(_gadgetManager.getActive(player, GadgetType.MORPH) instanceof MorphDinnerbone))
return;
if (!event.getRightClicked().getType().equals(EntityType.ARMOR_STAND))
return;
Block block = event.getRightClicked().getLocation().getBlock();
Action action = Action.RIGHT_CLICK_AIR;
BlockFace blockFace = BlockFace.SOUTH;
ItemStack item = player.getItemInHand();
PlayerInteractEvent playerInteractEvent = new PlayerInteractEvent(player, action, item, block, blockFace);
Bukkit.getPluginManager().callEvent(playerInteractEvent);
}
public GadgetManager getGadgetManager()
{
return _gadgetManager;

View File

@ -50,11 +50,11 @@ public class CostumePage extends GadgetPage
slot = offset + 1 + 18; //1 buffer to left, 18 = 2 lines down
if (outfitGadget.getSlot() == OutfitGadget.ArmorSlot.Chest)
if (outfitGadget.getSlot() == OutfitGadget.ArmorSlot.CHEST)
slot += 9;
else if (outfitGadget.getSlot() == OutfitGadget.ArmorSlot.Legs)
else if (outfitGadget.getSlot() == OutfitGadget.ArmorSlot.LEGS)
slot += 18;
else if (outfitGadget.getSlot() == OutfitGadget.ArmorSlot.Boots)
else if (outfitGadget.getSlot() == OutfitGadget.ArmorSlot.BOOTS)
slot += 27;
addGadget(gadget, slot);

View File

@ -8,22 +8,17 @@ import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.account.CoreClientManager;
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.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.banner.CountryFlag;
@ -34,10 +29,6 @@ import mineplex.core.cosmetic.ui.button.activate.ActivateGadgetButton;
import mineplex.core.cosmetic.ui.button.deactivate.DeactivateGadgetButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger;
import mineplex.core.gadget.gadgets.morph.MorphWitch;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuit;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitHelmet;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.HatGadget;
@ -317,7 +308,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
if (gadget.ownsGadget(getPlayer()))
{
ItemStack gadgetItemStack;
if (gadget instanceof MorphWitch)
/*if (gadget instanceof MorphWitch)
{
gadgetItemStack = ((MorphWitch) gadget).getWitchItem();
}
@ -335,6 +326,14 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) gadgetItemStack.getItemMeta();
leatherArmorMeta.setColor(Color.fromRGB(129, 212, 250));
gadgetItemStack.setItemMeta(leatherArmorMeta);
}*/
if (gadget.hasDisplayItem())
{
gadgetItemStack = gadget.getDisplayItem();
}
else
{
gadgetItemStack = new ItemStack(gadget.getDisplayMaterial(), 1, gadget.getDisplayData());
}
ItemMeta meta = gadgetItemStack.getItemMeta();

View File

@ -528,6 +528,31 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), r, pDisguise.getShowInTabListDelay());
}
}
else
{
if (!pDisguise.replaceOriginalName())
{
Runnable r = () ->
{
PacketPlayOutPlayerInfo playerInfoPacketRemove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER);
PacketPlayOutPlayerInfo.PlayerInfoData dataRemove = playerInfoPacketRemove.new PlayerInfoData(pDisguise.getProfile(), 0, WorldSettings.EnumGamemode.SURVIVAL, null);
playerInfoPacketRemove.b.add(dataRemove);
handlePacket(playerInfoPacketRemove, packetVerifier);
PacketPlayOutPlayerInfo playerInfoPacketAdd = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
PacketPlayOutPlayerInfo.PlayerInfoData dataAdd = playerInfoPacketRemove.new PlayerInfoData(pDisguise.getOriginalProfile(), 0, WorldSettings.EnumGamemode.SURVIVAL, null);
playerInfoPacketAdd.b.add(dataAdd);
handlePacket(playerInfoPacketAdd, packetVerifier);
};
if (pDisguise.replaceOriginalNameDelay() == 0)
{
r.run();
}
else
{
Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), r, pDisguise.replaceOriginalNameDelay());
}
}
}
}
else
{

View File

@ -6,14 +6,30 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.UtilMath;
import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager;
import mineplex.core.thread.ThreadPool;
import mineplex.core.utils.UtilGameProfile;
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_8_R3.AttributeInstance;
import net.minecraft.server.v1_8_R3.AttributeMapServer;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.IInventory;
import net.minecraft.server.v1_8_R3.ITileEntityContainer;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MobEffect;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutAbilities;
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEffect;
import net.minecraft.server.v1_8_R3.PacketPlayOutExperience;
import net.minecraft.server.v1_8_R3.PacketPlayOutHeldItemSlot;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import net.minecraft.server.v1_8_R3.PacketPlayOutPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes;
import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateHealth;
import net.minecraft.server.v1_8_R3.WorldSettings;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory;
import org.bukkit.entity.Entity;
@ -21,6 +37,14 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.UtilMath;
import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager;
import mineplex.core.thread.ThreadPool;
import mineplex.core.utils.UtilGameProfile;
public class DisguisePlayer extends DisguiseHuman
{
private String _requestedUsername;
@ -36,7 +60,9 @@ public class DisguisePlayer extends DisguiseHuman
private boolean _sendSkinToSelf = true;
private boolean _showInTabList = false;
private boolean _replaceOriginalName = true;
private int _showInTabListDelay = 30;
private int _replaceOriginalNameDelay;
private DisguisePlayer(Entity entity)
{
@ -64,7 +90,7 @@ public class DisguisePlayer extends DisguiseHuman
/**
* @param username The username to disguise this entity as
* @param skin The username of the player whose skin will be used
* @param skin The username of the player whose skin will be used
*/
public DisguisePlayer(Entity entity, String username, String skin)
{
@ -86,7 +112,6 @@ public class DisguisePlayer extends DisguiseHuman
* If this DisguisePlayer has been initialized with a requested username and requested skin, it must be initialized
*
* @param onComplete The Runnable which will be run once initialized. Can be null. It will be run on a separate thread if initialization took place, and the current thread if not
*
* @returns A Future which, upon completion, implies the task is done
*/
public Future<Object> initialize(Runnable onComplete)
@ -435,6 +460,22 @@ public class DisguisePlayer extends DisguiseHuman
return selfProfile;
}
public boolean replaceOriginalName()
{
return this._replaceOriginalName;
}
public int replaceOriginalNameDelay()
{
return this._replaceOriginalNameDelay;
}
public void setReplaceOriginalName(boolean b, int delay)
{
this._replaceOriginalName = b;
this._replaceOriginalNameDelay = delay;
}
private UUID getOriginalUUID()
{
if (this._originalProfile.getProperties().containsKey(PlayerDisguiseManager.ORIGINAL_UUID_KEY))

View File

@ -116,6 +116,7 @@ import mineplex.core.gadget.gadgets.morph.MorphChicken;
import mineplex.core.gadget.gadgets.morph.MorphChristmasKing;
import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphCreeper;
import mineplex.core.gadget.gadgets.morph.MorphDinnerbone;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphGrimReaper;
import mineplex.core.gadget.gadgets.morph.MorphMetalMan;
@ -362,10 +363,10 @@ public class GadgetManager extends MiniPlugin
addGadget(new OutfitFreezeSuitLeggings(this));
addGadget(new OutfitFreezeSuitBoots(this));
addGadget(new OutfitTeam(this, "Team Helmet", -1, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0));
addGadget(new OutfitTeam(this, "Team Shirt", -1, ArmorSlot.Chest, Material.LEATHER_CHESTPLATE, (byte)0));
addGadget(new OutfitTeam(this, "Team Pants", -1, ArmorSlot.Legs, Material.LEATHER_LEGGINGS, (byte)0));
addGadget(new OutfitTeam(this, "Team Boots", -1, ArmorSlot.Boots, Material.LEATHER_BOOTS, (byte)0));
addGadget(new OutfitTeam(this, "Team Helmet", -1, ArmorSlot.HELMET, Material.LEATHER_HELMET, (byte)0));
addGadget(new OutfitTeam(this, "Team Shirt", -1, ArmorSlot.CHEST, Material.LEATHER_CHESTPLATE, (byte)0));
addGadget(new OutfitTeam(this, "Team Pants", -1, ArmorSlot.LEGS, Material.LEATHER_LEGGINGS, (byte)0));
addGadget(new OutfitTeam(this, "Team Boots", -1, ArmorSlot.BOOTS, Material.LEATHER_BOOTS, (byte)0));
// Morphs
addGadget(new MorphVillager(this));
@ -393,6 +394,7 @@ public class GadgetManager extends MiniPlugin
// Not in this update
//addGadget(new MorphStray(this));
addGadget(new MorphSanta(this));
addGadget(new MorphDinnerbone(this));
// Particles
addGadget(new ParticleFoot(this));
@ -1110,6 +1112,17 @@ public class GadgetManager extends MiniPlugin
event.setCancelled(true);
player.sendMessage(F.main("Cosmetics", "You cannot enable particles while vanished!"));
}
if (event.getGadget().getGadgetType() == GadgetType.MORPH)
{
if (event.getGadget() instanceof MorphDinnerbone)
{
if (_mountManager.getActive(player) != null)
{
event.setCancelled(true);
UtilPlayer.message(player, F.main("Cosmetics", "You cannot morph into " + event.getGadget().getName() + " with an active mount!"));
}
}
}
}
@EventHandler
@ -1220,15 +1233,25 @@ public class GadgetManager extends MiniPlugin
if (!SwimManager.isSwimming(uuid))
{
SwimManager.addPlayer(uuid);
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), true));
SwimManager.removePlayerLava(uuid);
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), true, false));
}
}
else if (material == Material.LAVA || material == Material.STATIONARY_LAVA)
{
if (!SwimManager.isInLava(uuid))
{
SwimManager.addPlayerLava(uuid);
SwimManager.removePlayer(uuid);
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), true, false));
}
}
else
{
if (SwimManager.isSwimming(uuid))
if (SwimManager.isSwimming(uuid) || SwimManager.isInLava(uuid))
{
SwimManager.removePlayer(uuid);
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), false));
SwimManager.removeLavaAndWater(uuid);
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), false, false));
}
}
}

View File

@ -1,18 +1,21 @@
package mineplex.core.gadget.event;
import mineplex.core.gadget.types.ItemGadget;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class ItemGadgetUseEvent extends Event
import mineplex.core.gadget.types.ItemGadget;
public class ItemGadgetUseEvent extends Event implements Cancellable
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private ItemGadget _gadget;
private int _count;
private boolean _cancelled;
private String _cancelledMessage = "";
public ItemGadgetUseEvent(Player player, ItemGadget gadget, int count)
{
@ -45,4 +48,26 @@ public class ItemGadgetUseEvent extends Event
{
return _player;
}
@Override
public boolean isCancelled()
{
return _cancelled;
}
@Override
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public String getCancelledMessage()
{
return _cancelledMessage;
}
public void setCancelledMessage(String cancelledMessage)
{
_cancelledMessage = cancelledMessage;
}
}

View File

@ -10,9 +10,9 @@ public class PlayerToggleSwimEvent extends Event
private static final HandlerList handlers = new HandlerList();
private Player _player;
private boolean _swimming;
private boolean _swimming, _lava;
public PlayerToggleSwimEvent(Player player, boolean swimming)
public PlayerToggleSwimEvent(Player player, boolean swimming, boolean lava)
{
_player = player;
_swimming = swimming;
@ -28,6 +28,11 @@ public class PlayerToggleSwimEvent extends Event
return _swimming;
}
public boolean isInLava()
{
return _lava;
}
public HandlerList getHandlers()
{
return handlers;

View File

@ -1,18 +1,20 @@
package mineplex.core.gadget.gadgets.arrowtrail.freedom;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.particleeffects.BabyFireworkEffect;
import mineplex.core.gadget.types.ArrowEffectGadget;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.banner.CountryFlag;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ArrowEffectGadget;
import mineplex.core.particleeffects.BabyFireworkEffect;
public class ArrowTrailFreedom extends ArrowEffectGadget
{
@ -25,6 +27,7 @@ public class ArrowTrailFreedom extends ArrowEffectGadget
ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE),
-8, Material.WOOL,
(byte) 0);
setDisplayItem(CountryFlag.USA.getBanner());
}
@Override

View File

@ -1,17 +1,18 @@
package mineplex.core.gadget.gadgets.death.freedom;
import mineplex.core.blood.BloodEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.DeathEffectGadget;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.blood.BloodEvent;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.banner.CountryFlag;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.DeathEffectGadget;
public class DeathFreedom extends DeathEffectGadget
{
@ -20,6 +21,7 @@ public class DeathFreedom extends DeathEffectGadget
super(manager, "Price of Freedom", UtilText.splitLineToArray(UtilText.colorWords("Freedom isn't always free, Soldier.",
ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE),
-8, Material.WOOL, (byte) 0);
setDisplayItem(CountryFlag.USA.getBanner());
}
@Override

View File

@ -1,13 +1,15 @@
package mineplex.core.gadget.gadgets.doublejump.freedom;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.banner.CountryFlag;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class DoubleJumpFreedom extends DoubleJumpEffectGadget
{
@ -17,13 +19,12 @@ public class DoubleJumpFreedom extends DoubleJumpEffectGadget
super(manager, "Leap of Freedom", UtilText.splitLineToArray(UtilText.colorWords("FREEEEEEEEEEEDOM!",
ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8, Material.WOOL,
(byte) 14);
setDisplayItem(CountryFlag.USA.getBanner());
}
@Override
public void doEffect(Player player)
{
/*FreedomFireworkEffect freedomFireworkEffect = new FreedomFireworkEffect(player, Manager.getPlugin(), 3);
freedomFireworkEffect.start();*/
UtilFirework.playFreedomFirework(player.getLocation());
}

View File

@ -0,0 +1,320 @@
package mineplex.core.gadget.gadgets.morph;
import java.time.Month;
import java.time.YearMonth;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.EntityArmorStand;
import net.minecraft.server.v1_8_R3.EntitySlime;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.World;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.mojang.authlib.GameProfile;
import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.Rank;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.utils.UtilGameProfile;
import static mineplex.core.common.util.UtilServer.runSync;
public class MorphDinnerbone extends MorphGadget implements IPacketHandler
{
private static final String NAME = "Dinnerbone";
private final CoreClientManager _coreClientManager = Managers.require(CoreClientManager.class);
// Maps player to map of player and the id for the armorstand nametag
private final Map<Integer, Map<UUID, Integer>> _armorStandIds = new HashMap<>();
// Maps player to map of player and all ids that it owns
private final Map<Integer, Map<UUID, List<Integer>>> _allIds = new HashMap<>();
public MorphDinnerbone(GadgetManager manager)
{
super(manager, "Over Easy Morph", UtilText.splitLinesToArray(new String[]{
C.cGray + "This morph lets you walk around on your head. But be careful, all the blood might go to your head!",
}, LineFormat.LORE),
-14, Material.EGG, (byte) 0, YearMonth.of(2017, Month.JANUARY));
Managers.require(PacketHandler.class).addPacketHandler(this, PacketHandler.ListenerPriority.LOW, PacketPlayOutNamedEntitySpawn.class, PacketPlayOutEntityDestroy.class);
}
@Override
public void enableCustom(Player player, boolean message)
{
applyArmor(player, message);
GameProfile profile = UtilGameProfile.getGameProfile(player);
try
{
UtilGameProfile.changeName(profile, "Dinnerbone");
}
catch (ReflectiveOperationException e)
{
// Literally should never happen
e.printStackTrace();
}
DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile);
disguisePlayer.setSendSkinDataToSelf(false);
disguisePlayer.setReplaceOriginalName(false, 10);
disguisePlayer.showInTabList(true, 0);
UtilMorph.disguise(player, disguisePlayer, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
removeArmor(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
@Override
public void handle(PacketInfo packetInfo)
{
if (packetInfo.isCancelled())
return;
if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn)
{
PacketPlayOutNamedEntitySpawn packet = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket();
Player owner = (Player) UtilEnt.getEntityById(packet.a);
if (Manager.getActive(owner, GadgetType.MORPH) == this)
{
summonForEntity(packetInfo.getPlayer(), owner);
}
}
else if (packetInfo.getPacket() instanceof PacketPlayOutEntityDestroy)
{
PacketPlayOutEntityDestroy packet = (PacketPlayOutEntityDestroy) packetInfo.getPacket();
for (int id : packet.a)
{
destroyForEntity(packetInfo.getPlayer(), id);
}
}
}
private void summonForEntity(Player receiver, Player player)
{
switch (UtilPlayer.getVersion(receiver))
{
case Version1_9:
summonForEntity19(receiver, player);
break;
case Version1_8:
summonForEntity18(receiver, player);
break;
case ALL:
// do nothing
break;
}
}
private void summonForEntity19(Player receiver, Player player)
{
World world = ((CraftWorld) receiver.getWorld()).getHandle();
DataWatcher armorStandWatcher = getArmorStandWatcher(player);
armorStandWatcher.a(10, (byte) 0x10, EntityArmorStand.META_ARMOR_OPTION, (byte) 0x10); // Small
DataWatcher squidWatcher = new DataWatcher(new DummyEntity(world));
squidWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
PacketPlayOutSpawnEntityLiving spawnSquid = new PacketPlayOutSpawnEntityLiving();
spawnSquid.a = UtilEnt.getNewEntityId();
spawnSquid.b = EntityType.SQUID.getTypeId();
spawnSquid.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
spawnSquid.d = -150;
spawnSquid.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
spawnSquid.i = 0;
spawnSquid.j = 0;
spawnSquid.k = 0;
spawnSquid.f = 0;
spawnSquid.g = 0;
spawnSquid.h = 0;
spawnSquid.uuid = UUID.randomUUID();
spawnSquid.l = squidWatcher;
PacketPlayOutSpawnEntityLiving spawnArmorStand = new PacketPlayOutSpawnEntityLiving();
spawnArmorStand.a = UtilEnt.getNewEntityId();
spawnArmorStand.b = EntityType.ARMOR_STAND.getTypeId();
spawnArmorStand.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
spawnArmorStand.d = -150;
spawnArmorStand.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
spawnArmorStand.i = 0;
spawnArmorStand.j = 0;
spawnArmorStand.k = 0;
spawnArmorStand.f = 0;
spawnArmorStand.g = 0;
spawnArmorStand.h = 0;
spawnArmorStand.uuid = UUID.randomUUID();
spawnArmorStand.l = armorStandWatcher;
PacketPlayOutNewAttachEntity attachSquidtoPlayer = new PacketPlayOutNewAttachEntity(player.getEntityId(), new int[]{spawnSquid.a});
PacketPlayOutNewAttachEntity attachArmorStandToSquid = new PacketPlayOutNewAttachEntity(spawnSquid.a, new int[]{spawnArmorStand.a});
_armorStandIds.computeIfAbsent(player.getEntityId(), key -> new HashMap<>()).put(receiver.getUniqueId(), spawnArmorStand.a);
_allIds.computeIfAbsent(player.getEntityId(), key -> new HashMap<>()).put(receiver.getUniqueId(), Arrays.asList(spawnSquid.a, spawnArmorStand.a));
runSync(() ->
{
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(spawnSquid);
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(spawnArmorStand);
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(attachSquidtoPlayer);
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(attachArmorStandToSquid);
});
}
private void summonForEntity18(Player receiver, Player player)
{
World world = ((CraftWorld) receiver.getWorld()).getHandle();
DataWatcher armorStandWatcher = getArmorStandWatcher(player);
armorStandWatcher.a(10, (byte) 0x10, EntityArmorStand.META_ARMOR_OPTION, (byte) 0x10); // Small
DataWatcher squidWatcher = new DataWatcher(new DummyEntity(world));
squidWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
PacketPlayOutSpawnEntityLiving spawnSquid = new PacketPlayOutSpawnEntityLiving();
spawnSquid.a = UtilEnt.getNewEntityId();
spawnSquid.b = EntityType.WOLF.getTypeId();
spawnSquid.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
spawnSquid.d = -150;
spawnSquid.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
spawnSquid.i = 0;
spawnSquid.j = 0;
spawnSquid.k = 0;
spawnSquid.f = 0;
spawnSquid.g = 0;
spawnSquid.h = 0;
spawnSquid.uuid = UUID.randomUUID();
spawnSquid.l = squidWatcher;
PacketPlayOutSpawnEntityLiving spawnArmorStand = new PacketPlayOutSpawnEntityLiving();
spawnArmorStand.a = UtilEnt.getNewEntityId();
spawnArmorStand.b = EntityType.ARMOR_STAND.getTypeId();
spawnArmorStand.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
spawnArmorStand.d = -150;
spawnArmorStand.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
spawnArmorStand.i = 0;
spawnArmorStand.j = 0;
spawnArmorStand.k = 0;
spawnArmorStand.f = 0;
spawnArmorStand.g = 0;
spawnArmorStand.h = 0;
spawnArmorStand.uuid = UUID.randomUUID();
spawnArmorStand.l = armorStandWatcher;
PacketPlayOutAttachEntity attachSquidtoPlayer = new PacketPlayOutAttachEntity();
attachSquidtoPlayer.a = 0;
attachSquidtoPlayer.b = spawnSquid.a;
attachSquidtoPlayer.c = player.getEntityId();
PacketPlayOutAttachEntity attachArmorStandToSquid = new PacketPlayOutAttachEntity();
attachArmorStandToSquid.a = 0;
attachArmorStandToSquid.b = spawnArmorStand.a;
attachArmorStandToSquid.c = spawnSquid.a;
_armorStandIds.computeIfAbsent(player.getEntityId(), key -> new HashMap<>()).put(receiver.getUniqueId(), spawnArmorStand.a);
_allIds.computeIfAbsent(player.getEntityId(), key -> new HashMap<>()).put(receiver.getUniqueId(), Arrays.asList(spawnSquid.a, spawnArmorStand.a));
runSync(() ->
{
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(spawnSquid);
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(spawnArmorStand);
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(attachSquidtoPlayer);
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(attachArmorStandToSquid);
});
}
private void destroyForEntity(Player receiver, int id)
{
Map<UUID, Integer> innerMap = _armorStandIds.get(id);
if (innerMap != null)
{
innerMap.remove(receiver.getUniqueId());
if (innerMap.isEmpty())
{
_armorStandIds.remove(id);
}
}
Map<UUID, List<Integer>> allIdsMap = _allIds.get(id);
if (allIdsMap != null)
{
List<Integer> ids = allIdsMap.remove(receiver.getUniqueId());
if (ids != null)
{
int[] idsArr = ids.stream().mapToInt(Integer::intValue).toArray();
PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(idsArr);
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(destroy);
}
if (allIdsMap.isEmpty())
{
_allIds.remove(id);
}
}
}
private DataWatcher getArmorStandWatcher(Player ownerOfTrack)
{
Rank rank = _coreClientManager.Get(ownerOfTrack).getRealOrDisguisedRank();
String name = ownerOfTrack.getName();
if (rank != null)
{
if (rank.has(Rank.ULTRA))
{
name = rank.getTag(true, true) + " " + ChatColor.RESET + name;
}
}
World world = ((CraftWorld) ownerOfTrack.getWorld()).getHandle();
DataWatcher armorStandWatcher = new DataWatcher(new DummyEntity(world));
armorStandWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
armorStandWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 0);
armorStandWatcher.a(2, name, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, name);
armorStandWatcher.a(3, (byte) 1, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME_VISIBLE, true);
return armorStandWatcher;
}
}

View File

@ -55,7 +55,7 @@ public class MorphSquid extends MorphGadget implements IThrown
applyArmor(player, message);
DisguiseSquid disguiseSquid = new DisguiseSquid(player);
UtilMorph.disguise(player, disguiseSquid, Manager);
onToggleSwim(new PlayerToggleSwimEvent(player, SwimManager.isSwimming(player.getUniqueId())));
onToggleSwim(new PlayerToggleSwimEvent(player, SwimManager.isSwimming(player.getUniqueId()), SwimManager.isInLava(player.getUniqueId())));
}
@Override
@ -89,7 +89,7 @@ public class MorphSquid extends MorphGadget implements IThrown
if (event.isSwimming())
{
// Removes any costume player could be wearing
Manager.removeOutfit(event.getPlayer(), OutfitGadget.ArmorSlot.Boots);
Manager.removeOutfit(event.getPlayer(), OutfitGadget.ArmorSlot.BOOTS);
// Adds enchanted boot
ItemStack enchantedBoot = new ItemStack(Material.DIAMOND_BOOTS, 1);

View File

@ -8,6 +8,7 @@ public class SwimManager
{
private static List<UUID> _swimming = new ArrayList<>();
private static List<UUID> _lava = new ArrayList<>();
public static void addPlayer(UUID uuid)
{
@ -22,9 +23,33 @@ public class SwimManager
}
}
public static void addPlayerLava(UUID uuid)
{
_lava.add(uuid);
}
public static void removePlayerLava(UUID uuid)
{
if (_lava.contains(uuid))
{
_lava.remove(uuid);
}
}
public static void removeLavaAndWater(UUID uuid)
{
removePlayerLava(uuid);
removePlayer(uuid);
}
public static boolean isSwimming(UUID uuid)
{
return _swimming.contains(uuid);
}
public static boolean isInLava(UUID uuid)
{
return _lava.contains(uuid);
}
}

View File

@ -63,16 +63,16 @@ public class OutfitTeam extends OutfitGadget
_active.add(player);
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(
if (_slot == ArmorSlot.HELMET) player.getInventory().setHelmet(
ItemStackFactory.Instance.CreateStack(getDisplayMaterial().getId(), getDisplayData(), 1, getName()));
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(
else if (_slot == ArmorSlot.CHEST) player.getInventory().setChestplate(
ItemStackFactory.Instance.CreateStack(getDisplayMaterial().getId(), getDisplayData(), 1, getName()));
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(
else if (_slot == ArmorSlot.LEGS) player.getInventory().setLeggings(
ItemStackFactory.Instance.CreateStack(getDisplayMaterial().getId(), getDisplayData(), 1, getName()));
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(
else if (_slot == ArmorSlot.BOOTS) player.getInventory().setBoots(
ItemStackFactory.Instance.CreateStack(getDisplayMaterial().getId(), getDisplayData(), 1, getName()));
}
@ -82,10 +82,10 @@ public class OutfitTeam extends OutfitGadget
if (!_active.remove(player))
return;
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null);
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null);
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null);
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null);
if (_slot == ArmorSlot.HELMET) player.getInventory().setHelmet(null);
else if (_slot == ArmorSlot.CHEST) player.getInventory().setChestplate(null);
else if (_slot == ArmorSlot.LEGS) player.getInventory().setLeggings(null);
else if (_slot == ArmorSlot.BOOTS) player.getInventory().setBoots(null);
}
@Override
@ -124,7 +124,7 @@ public class OutfitTeam extends OutfitGadget
//Will only display the message once
if (getSlot() == ArmorSlot.Legs)
if (getSlot() == ArmorSlot.LEGS)
{
if (!Recharge.Instance.use(player, "Set Team Color", 20000, true, false))
return;
@ -140,28 +140,28 @@ public class OutfitTeam extends OutfitGadget
{
_colorSetting.put(player.getName(), Color.RED);
if (getSlot() == ArmorSlot.Legs) //Only Display Once
if (getSlot() == ArmorSlot.LEGS) //Only Display Once
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cRed + "Red Team Outfit") + "!"));
}
else if (args[1].equals("yellow"))
{
_colorSetting.put(player.getName(), Color.YELLOW);
if (getSlot() == ArmorSlot.Legs) //Only Display Once
if (getSlot() == ArmorSlot.LEGS) //Only Display Once
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cYellow + "Yellow Team Outfit") + "!"));
}
else if (args[1].equals("green"))
{
_colorSetting.put(player.getName(), Color.LIME);
if (getSlot() == ArmorSlot.Legs) //Only Display Once
if (getSlot() == ArmorSlot.LEGS) //Only Display Once
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cGreen + "Green Team Outfit") + "!"));
}
else if (args[1].equals("blue"))
{
_colorSetting.put(player.getName(), Color.AQUA);
if (getSlot() == ArmorSlot.Legs) //Only Display Once
if (getSlot() == ArmorSlot.LEGS) //Only Display Once
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cAqua + "Blue Team Outfit") + "!"));
}
else
@ -180,7 +180,7 @@ public class OutfitTeam extends OutfitGadget
//Get Item
ItemStack stack;
if (getSlot() == ArmorSlot.Helmet)
if (getSlot() == ArmorSlot.HELMET)
{
stack = player.getInventory().getHelmet();
@ -190,7 +190,7 @@ public class OutfitTeam extends OutfitGadget
return;
}
}
else if (getSlot() == ArmorSlot.Chest)
else if (getSlot() == ArmorSlot.CHEST)
{
stack = player.getInventory().getChestplate();
@ -200,7 +200,7 @@ public class OutfitTeam extends OutfitGadget
return;
}
}
else if (getSlot() == ArmorSlot.Legs)
else if (getSlot() == ArmorSlot.LEGS)
{
stack = player.getInventory().getLeggings();
@ -210,7 +210,7 @@ public class OutfitTeam extends OutfitGadget
return;
}
}
else if (getSlot() == ArmorSlot.Boots)
else if (getSlot() == ArmorSlot.BOOTS)
{
stack = player.getInventory().getBoots();

View File

@ -15,6 +15,8 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
@ -48,6 +50,22 @@ public class OutfitFreezeSuit extends OutfitGadget
"survive the coldest of weather! Press sneak to generate your ice bridge.", LineFormat.LORE),
cost, slot, mat, data);
setColor(Color.fromRGB(129, 212, 250));
// Sets the display item
if (slot.equals(ArmorSlot.HELMET))
{
setDisplayItem(new ItemStack(mat, 1, data));
}
else
{
ItemStack displayItem = new ItemStack(mat, 1, data);
if (displayItem.getItemMeta() instanceof LeatherArmorMeta)
{
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) displayItem.getItemMeta();
leatherArmorMeta.setColor(Color.fromRGB(129, 212, 250));
displayItem.setItemMeta(leatherArmorMeta);
}
setDisplayItem(displayItem);
}
}
@Override
@ -66,7 +84,7 @@ public class OutfitFreezeSuit extends OutfitGadget
public void activateBridge(PlayerToggleSneakEvent event)
{
// Prevents running event 4 times
if (getSlot() != ArmorSlot.Helmet)
if (getSlot() != ArmorSlot.HELMET)
return;
if (!setActive(event.getPlayer()))
@ -90,7 +108,7 @@ public class OutfitFreezeSuit extends OutfitGadget
public void snowAura(UpdateEvent event)
{
// Prevents running event 4 times
if (getSlot() != ArmorSlot.Helmet)
if (getSlot() != ArmorSlot.HELMET)
return;
if (event.getType() != UpdateType.FAST)
@ -141,7 +159,7 @@ public class OutfitFreezeSuit extends OutfitGadget
public void icePath(UpdateEvent event)
{
// Prevents running event 4 times
if (getSlot() != ArmorSlot.Helmet)
if (getSlot() != ArmorSlot.HELMET)
return;
if (event.getType() != UpdateType.TICK)

View File

@ -9,7 +9,7 @@ public class OutfitFreezeSuitBoots extends OutfitFreezeSuit
public OutfitFreezeSuitBoots(GadgetManager manager)
{
super(manager, "Freeze Boots", -16, ArmorSlot.Boots, Material.LEATHER_BOOTS, (byte) 0);
super(manager, "Freeze Boots", -16, ArmorSlot.BOOTS, Material.LEATHER_BOOTS, (byte) 0);
}
}

View File

@ -9,7 +9,7 @@ public class OutfitFreezeSuitChestplate extends OutfitFreezeSuit
public OutfitFreezeSuitChestplate(GadgetManager manager)
{
super(manager, "Freeze Chest", -16, ArmorSlot.Chest, Material.LEATHER_CHESTPLATE, (byte) 0);
super(manager, "Freeze Chest", -16, ArmorSlot.CHEST, Material.LEATHER_CHESTPLATE, (byte) 0);
}
}

View File

@ -9,7 +9,7 @@ public class OutfitFreezeSuitHelmet extends OutfitFreezeSuit
public OutfitFreezeSuitHelmet(GadgetManager manager)
{
super(manager, "Freeze Helmet", -16, ArmorSlot.Helmet, Material.ICE, (byte) 0);
super(manager, "Freeze Helmet", -16, ArmorSlot.HELMET, Material.ICE, (byte) 0);
}
}

View File

@ -9,7 +9,7 @@ public class OutfitFreezeSuitLeggings extends OutfitFreezeSuit
public OutfitFreezeSuitLeggings(GadgetManager manager)
{
super(manager, "Freeze Leggings", -16, ArmorSlot.Legs, Material.LEATHER_LEGGINGS, (byte) 0);
super(manager, "Freeze Leggings", -16, ArmorSlot.LEGS, Material.LEATHER_LEGGINGS, (byte) 0);
}
}

View File

@ -64,7 +64,7 @@ public class OutfitRaveSuit extends OutfitGadget
//Get Item
ItemStack stack;
if (getSlot() == ArmorSlot.Helmet)
if (getSlot() == ArmorSlot.HELMET)
{
stack = player.getInventory().getHelmet();
@ -74,7 +74,7 @@ public class OutfitRaveSuit extends OutfitGadget
continue;
}
}
else if (getSlot() == ArmorSlot.Chest)
else if (getSlot() == ArmorSlot.CHEST)
{
stack = player.getInventory().getChestplate();
@ -84,7 +84,7 @@ public class OutfitRaveSuit extends OutfitGadget
continue;
}
}
else if (getSlot() == ArmorSlot.Legs)
else if (getSlot() == ArmorSlot.LEGS)
{
stack = player.getInventory().getLeggings();
@ -94,7 +94,7 @@ public class OutfitRaveSuit extends OutfitGadget
continue;
}
}
else if (getSlot() == ArmorSlot.Boots)
else if (getSlot() == ArmorSlot.BOOTS)
{
stack = player.getInventory().getBoots();
@ -168,7 +168,7 @@ public class OutfitRaveSuit extends OutfitGadget
if (event.getType() != UpdateType.FAST)
return;
if (getSlot() != ArmorSlot.Helmet)
if (getSlot() != ArmorSlot.HELMET)
return;
for (Player player : UtilServer.getPlayers())

View File

@ -9,7 +9,7 @@ public class OutfitRaveSuitBoots extends OutfitRaveSuit
public OutfitRaveSuitBoots(GadgetManager manager)
{
super(manager, "Rave Boots", -2, ArmorSlot.Boots, Material.LEATHER_BOOTS, (byte)0);
super(manager, "Rave Boots", -2, ArmorSlot.BOOTS, Material.LEATHER_BOOTS, (byte)0);
}
}

View File

@ -9,7 +9,7 @@ public class OutfitRaveSuitChestplate extends OutfitRaveSuit
public OutfitRaveSuitChestplate(GadgetManager manager)
{
super(manager, "Rave Shirt", -2, ArmorSlot.Chest, Material.LEATHER_CHESTPLATE, (byte)0);
super(manager, "Rave Shirt", -2, ArmorSlot.CHEST, Material.LEATHER_CHESTPLATE, (byte)0);
}
}

View File

@ -9,7 +9,7 @@ public class OutfitRaveSuitHelmet extends OutfitRaveSuit
public OutfitRaveSuitHelmet(GadgetManager manager)
{
super(manager, "Rave Hat", -2, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0);
super(manager, "Rave Hat", -2, ArmorSlot.HELMET, Material.LEATHER_HELMET, (byte)0);
}
}

View File

@ -9,7 +9,7 @@ public class OutfitRaveSuitLeggings extends OutfitRaveSuit
public OutfitRaveSuitLeggings(GadgetManager manager)
{
super(manager, "Rave Pants", -2, ArmorSlot.Legs, Material.LEATHER_LEGGINGS, (byte)0);
super(manager, "Rave Pants", -2, ArmorSlot.LEGS, Material.LEATHER_LEGGINGS, (byte)0);
}
}

View File

@ -43,7 +43,7 @@ public class OutfitSpaceSuit extends OutfitGadget
if (event.getType() != UpdateType.FAST)
return;
if (getSlot() != ArmorSlot.Helmet)
if (getSlot() != ArmorSlot.HELMET)
return;
for (Player player : UtilServer.getPlayers())

View File

@ -9,7 +9,7 @@ public class OutfitSpaceSuitBoots extends OutfitSpaceSuit
public OutfitSpaceSuitBoots(GadgetManager manager)
{
super(manager, "Space Boots", -2, ArmorSlot.Boots, Material.GOLD_BOOTS, (byte)0);
super(manager, "Space Boots", -2, ArmorSlot.BOOTS, Material.GOLD_BOOTS, (byte)0);
}
}

View File

@ -9,7 +9,7 @@ public class OutfitSpaceSuitChestplate extends OutfitSpaceSuit
public OutfitSpaceSuitChestplate(GadgetManager manager)
{
super(manager, "Space Jacket", -2, ArmorSlot.Chest, Material.GOLD_CHESTPLATE, (byte)0);
super(manager, "Space Jacket", -2, ArmorSlot.CHEST, Material.GOLD_CHESTPLATE, (byte)0);
}
}

View File

@ -9,7 +9,7 @@ public class OutfitSpaceSuitHelmet extends OutfitSpaceSuit
public OutfitSpaceSuitHelmet(GadgetManager manager)
{
super(manager, "Space Helmet", -2, ArmorSlot.Helmet, Material.GLASS, (byte)0);
super(manager, "Space Helmet", -2, ArmorSlot.HELMET, Material.GLASS, (byte)0);
}
}

View File

@ -9,7 +9,7 @@ public class OutfitSpaceSuitLeggings extends OutfitSpaceSuit
public OutfitSpaceSuitLeggings(GadgetManager manager)
{
super(manager, "Space Pants", -2, ArmorSlot.Legs, Material.GOLD_LEGGINGS, (byte)0);
super(manager, "Space Pants", -2, ArmorSlot.LEGS, Material.GOLD_LEGGINGS, (byte)0);
}
}

View File

@ -230,19 +230,19 @@ public class OutfitWindUpSuit extends OutfitGadget
{
ItemStack stack;
if(getSlot() == ArmorSlot.Helmet)
if(getSlot() == ArmorSlot.HELMET)
{
stack = player.getInventory().getHelmet();
}
else if (getSlot() == ArmorSlot.Chest)
else if (getSlot() == ArmorSlot.CHEST)
{
stack = player.getInventory().getChestplate();
}
else if (getSlot() == ArmorSlot.Legs)
else if (getSlot() == ArmorSlot.LEGS)
{
stack = player.getInventory().getLeggings();
}
else if (getSlot() == ArmorSlot.Boots)
else if (getSlot() == ArmorSlot.BOOTS)
{
stack = player.getInventory().getBoots();
}

View File

@ -8,7 +8,7 @@ public class OutfitWindUpSuitBoots extends OutfitWindUpSuit
public OutfitWindUpSuitBoots(GadgetManager manager)
{
super(manager, "Wind Up Boots", -2, ArmorSlot.Boots, Material.LEATHER_BOOTS, (byte)0, manager.getBoosterManager());
super(manager, "Wind Up Boots", -2, ArmorSlot.BOOTS, Material.LEATHER_BOOTS, (byte)0, manager.getBoosterManager());
}
}

View File

@ -8,7 +8,7 @@ public class OutfitWindUpSuitChestplate extends OutfitWindUpSuit
public OutfitWindUpSuitChestplate(GadgetManager manager)
{
super(manager, "Wind Up Shirt", -2, ArmorSlot.Chest, Material.LEATHER_CHESTPLATE, (byte)0, manager.getBoosterManager());
super(manager, "Wind Up Shirt", -2, ArmorSlot.CHEST, Material.LEATHER_CHESTPLATE, (byte)0, manager.getBoosterManager());
}
}

View File

@ -8,7 +8,7 @@ public class OutfitWindUpSuitHelmet extends OutfitWindUpSuit
public OutfitWindUpSuitHelmet(GadgetManager manager)
{
super(manager, "Wind Up Hat", -2, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0, manager.getBoosterManager());
super(manager, "Wind Up Hat", -2, ArmorSlot.HELMET, Material.LEATHER_HELMET, (byte)0, manager.getBoosterManager());
}
}

View File

@ -8,7 +8,7 @@ public class OutfitWindUpSuitLeggings extends OutfitWindUpSuit
public OutfitWindUpSuitLeggings(GadgetManager manager)
{
super(manager, "Wind Up Pants", -2, ArmorSlot.Legs, Material.LEATHER_LEGGINGS, (byte)0, manager.getBoosterManager());
super(manager, "Wind Up Pants", -2, ArmorSlot.LEGS, Material.LEATHER_LEGGINGS, (byte)0, manager.getBoosterManager());
}
}

View File

@ -4,16 +4,18 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.particleeffects.FreedomFireworkEffect;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.banner.CountryFlag;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.particleeffects.FreedomFireworkEffect;
import mineplex.core.updater.event.UpdateEvent;
public class ParticleFreedom extends ParticleGadget
{
@ -24,6 +26,7 @@ public class ParticleFreedom extends ParticleGadget
super(manager, "Freedom Aura", UtilText.splitLineToArray(UtilText.colorWords("Do you hear that? It's the sound of Freedom swirling around you.",
ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8,
Material.WOOL, (byte) 11);
setDisplayItem(CountryFlag.USA.getBanner());
}
@Override

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
@ -34,6 +35,8 @@ public abstract class Gadget extends SalesPackageBase implements Listener
private boolean _free;
private YearMonth _yearMonth = null;
private ItemStack _displayItem = null;
public Gadget(GadgetManager manager, GadgetType gadgetType, String name, String[] desc, int cost, Material mat, byte data)
{
@ -208,4 +211,19 @@ public abstract class Gadget extends SalesPackageBase implements Listener
{
return _alternativePackageNames;
}
public void setDisplayItem(ItemStack displayItem)
{
_displayItem = displayItem;
}
public boolean hasDisplayItem()
{
return _displayItem != null;
}
public ItemStack getDisplayItem()
{
return _displayItem;
}
}

View File

@ -20,7 +20,7 @@ public abstract class HatGadget extends OutfitGadget
public HatGadget(GadgetManager manager, HatType type)
{
super(manager, type.getName(), type.getLore(), type.getCost(), ArmorSlot.Helmet, type.getHat().getType(), type.getHat().getData().getData(), type.getAltNames());
super(manager, type.getName(), type.getLore(), type.getCost(), ArmorSlot.HELMET, type.getHat().getType(), type.getHat().getData().getData(), type.getAltNames());
_hat = type.getHat();
_hatType = type;
@ -31,7 +31,7 @@ public abstract class HatGadget extends OutfitGadget
public HatGadget(GadgetManager manager, String name, String[] desc, int cost, ItemStack item)
{
super(manager, name, desc, cost, ArmorSlot.Helmet, item.getType(), item.getData().getData());
super(manager, name, desc, cost, ArmorSlot.HELMET, item.getType(), item.getData().getData());
}
public HatGadget(GadgetManager manager, String name, String[] desc, int cost, String playerName)

View File

@ -173,14 +173,20 @@ public abstract class ItemGadget extends Gadget
UtilInv.Update(player);
return;
}
Manager.getInventoryManager().addItemToInventory(player, getName(), -1);
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(getDisplayMaterial(), getDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(getName()) + " " + getName())));
ItemGadgetUseEvent itemGadgetUseEvent = new ItemGadgetUseEvent(player, this, 1);
UtilServer.CallEvent(itemGadgetUseEvent);
if (itemGadgetUseEvent.isCancelled())
{
UtilPlayer.message(player, F.main("Item", itemGadgetUseEvent.getCancelledMessage()));
return;
}
Manager.getInventoryManager().addItemToInventory(player, getName(), -1);
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(getDisplayMaterial(), getDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(getName()) + " " + getName())));
ActivateCustom(event.getPlayer());
}

View File

@ -14,10 +14,10 @@ public abstract class OutfitGadget extends Gadget
{
public enum ArmorSlot
{
Helmet ("Helmet"),
Chest ("Chestplate"),
Legs ("Leggings"),
Boots ("Boots");
HELMET("Helmet"),
CHEST("Chestplate"),
LEGS("Leggings"),
BOOTS("Boots");
private String _databaseKey;
@ -80,13 +80,13 @@ public abstract class OutfitGadget extends Gadget
}
}
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(itemStack);
if (_slot == ArmorSlot.HELMET) player.getInventory().setHelmet(itemStack);
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(itemStack);
else if (_slot == ArmorSlot.CHEST) player.getInventory().setChestplate(itemStack);
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(itemStack);
else if (_slot == ArmorSlot.LEGS) player.getInventory().setLeggings(itemStack);
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(itemStack);
else if (_slot == ArmorSlot.BOOTS) player.getInventory().setBoots(itemStack);
}
public void removeArmor(Player player, boolean message)
@ -97,9 +97,9 @@ public abstract class OutfitGadget extends Gadget
if (message)
UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(getName()) + "."));
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null);
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null);
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null);
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null);
if (_slot == ArmorSlot.HELMET) player.getInventory().setHelmet(null);
else if (_slot == ArmorSlot.CHEST) player.getInventory().setChestplate(null);
else if (_slot == ArmorSlot.LEGS) player.getInventory().setLeggings(null);
else if (_slot == ArmorSlot.BOOTS) player.getInventory().setBoots(null);
}
}

View File

@ -1,13 +1,13 @@
package mineplex.core.mount.event;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.mount.Mount;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class MountActivateEvent extends Event
import mineplex.core.mount.Mount;
public class MountActivateEvent extends Event implements Cancellable
{
private static final HandlerList handlers = new HandlerList();
@ -42,11 +42,13 @@ public class MountActivateEvent extends Event
return _player;
}
@Override
public void setCancelled(boolean cancel)
{
_cancelled = cancel;
}
@Override
public boolean isCancelled()
{
return _cancelled;

View File

@ -31,7 +31,7 @@ public class PowerPlayClubRewards
.put(YearMonth.of(2016, Month.OCTOBER), new PowerPlayClubItem("Witch Morph", SkinData.WITCH.getSkull()))
.put(YearMonth.of(2016, Month.NOVEMBER), new PowerPlayClubItem("Turkey Morph", SkinData.TURKEY.getSkull()))
.put(YearMonth.of(2016, Month.DECEMBER), new PowerPlayClubItem("Santa Morph", SkinData.SANTA.getSkull()))
.put(YearMonth.of(2017, Month.JANUARY), new PowerPlayClubItem("Chicken Mount", new ItemStack(Material.GLASS)))
.put(YearMonth.of(2017, Month.JANUARY), new PowerPlayClubItem("Over Easy Morph", new ItemStack(Material.EGG)))
.build();
public static class PowerPlayClubItem

View File

@ -744,6 +744,10 @@ public class RewardManager
display = CountryFlag.USA.getBanner();
}
}
if (gadget.hasDisplayItem())
{
display = gadget.getDisplayItem();
}
UnknownPackageReward reward =
new UnknownPackageReward(_donationManager, gadget.getGadgetType().getCategoryType(), displayName,
gadget.getName(), display, rarity,

View File

@ -47,7 +47,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import mineplex.core.Managers;
import mineplex.core.MiniDbClientPlugin;
@ -61,10 +60,11 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
@ -93,6 +93,8 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
private final TrackManager _trackManager = require(TrackManager.class);
private final TitlesRepository _titlesRepository = new TitlesRepository();
private final GadgetManager _gadgetManager = require(GadgetManager.class);
private final BaseComponent[] CLICK_ENABLE_TRACK = new ComponentBuilder("")
.append("Click to enable this track")
.color(ChatColor.GREEN)
@ -699,7 +701,11 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn)
{
PacketPlayOutNamedEntitySpawn packet = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket();
summonForEntity(packetInfo.getPlayer(), (Player) UtilEnt.getEntityById(packet.a));
Player owner = (Player) UtilEnt.getEntityById(packet.a);
if (_gadgetManager.getActive(owner, GadgetType.MORPH) == null)
{
summonForEntity(packetInfo.getPlayer(), owner);
}
}
else if (packetInfo.getPacket() instanceof PacketPlayOutEntityDestroy)
{

View File

@ -89,7 +89,11 @@ public class BuyChestButton implements IButton
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, salesPackage, _page.getDonationManager(), () ->
{
_inventoryManager.addItemToInventory(player, _chestName, 1);
_page.refresh();
player.closeInventory();
TreasurePage page = new TreasurePage(_page.getTreasureManager(), _page.getTreasureShop(), _page.getTreasureLocation(),
_page.getClientManager(), _page.getDonationManager(), _page.getInventoryManager(),
_page.getGadgetManager(), player, _page.getActualPage());
_page.getTreasureShop().openPageForPlayer(player, page);
}), salesPackage.buildIcon()));
}
}

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
package mineplex.core.treasure.gui.pages;
import org.bukkit.entity.Player;
@ -30,3 +31,37 @@ public class NextPageButton implements IButton
_treasurePage.getTreasureShop().openPageForPlayer(player, nextPage);
}
}
=======
package mineplex.core.treasure.gui.pages;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
import mineplex.core.treasure.gui.TreasurePage;
public class NextPageButton implements IButton
{
private TreasurePage _treasurePage;
private Player _player;
public NextPageButton(TreasurePage treasurePage, Player player)
{
_treasurePage = treasurePage;
_player = player;
}
@Override
public void onClick(Player player, ClickType clickType)
{
if (_player != player)
return;
player.closeInventory();
TreasurePage nextPage = new TreasurePage(_treasurePage.getTreasureManager(), _treasurePage.getTreasureShop(), _treasurePage.getTreasureLocation(),
_treasurePage.getClientManager(), _treasurePage.getDonationManager(), _treasurePage.getInventoryManager(),
_treasurePage.getGadgetManager(), _player, _treasurePage.getActualPage() + 1);
_treasurePage.getTreasureShop().openPageForPlayer(player, nextPage);
}
}
>>>>>>> refs/remotes/origin/develop

View File

@ -64,6 +64,7 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
@ -1724,6 +1725,11 @@ public class SpeedBuilders extends SoloGame
event.setCancelled(true);
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
{
return;
}
Block block = event.getClickedBlock().getRelative(event.getBlockFace());

View File

@ -59,7 +59,7 @@ public class LootModule extends MiniPlugin
private static final float MAX_CHESTS_FACTOR = 0.25F;
private static final int MAX_SEARCH_ATTEMPTS = 40;
private static final int MAX_CHEST_PLACEMENT_RANGE = 5;
private static final MineplexGoogleSheet CHEST_LOOT_SHEET = MineplexGoogleSheet.GEM_HUNTERS_CHESTS;
private final GoogleSheetsManager _sheets;
@ -68,6 +68,7 @@ public class LootModule extends MiniPlugin
private final Map<String, Set<LootItem>> _chestLoot;
private final List<SpawnedChest> _spawnedChest;
private final Map<String, Set<Integer>> _spawnedIndexes;
private final Set<LootItemReward> _itemRewards;
private LootModule()
{
@ -78,6 +79,7 @@ public class LootModule extends MiniPlugin
_chestLoot = new HashMap<>();
_spawnedChest = new ArrayList<>(200);
_spawnedIndexes = new HashMap<>(15);
_itemRewards = new HashSet<>();
updateChestLoot();
}
@ -102,21 +104,21 @@ public class LootModule extends MiniPlugin
while (iterator.hasNext())
{
SpawnedChest chest = iterator.next();
if (chest.isOpened() && UtilTime.elapsed(chest.getOpenedAt(), CHEST_DESPAWN_TIME_OPENED) || UtilTime.elapsed(chest.getSpawnedAt(), CHEST_DESPAWN_TIME_NATURAL))
{
if (chest.getID() != -1)
{
_spawnedIndexes.get(chest.getColour()).remove(chest.getID());
}
Block block = chest.getLocation().getBlock();
if (block.getState() instanceof Chest)
{
((Chest) block.getState()).getBlockInventory().clear();
}
block.getWorld().playEffect(chest.getLocation(), Effect.STEP_SOUND, block.getType());
block.setType(Material.AIR);
iterator.remove();
@ -126,7 +128,8 @@ public class LootModule extends MiniPlugin
// Spawn new chests
dataPointLoop: for (String key : _worldData.getAllDataLocations().keySet())
{
// Some data points are ignored like the chest loot related to supply drops.
// Some data points are ignored like the chest loot related to
// supply drops.
for (String ignore : IGNORED_COLOURS)
{
if (key.equals(ignore))
@ -211,27 +214,27 @@ public class LootModule extends MiniPlugin
}
public boolean isSuitable(Block block)
{
{
if (block.getType() != Material.AIR)
{
return false;
}
if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR)
{
return false;
}
if (block.getRelative(BlockFace.UP).getType() != Material.AIR)
{
return false;
}
if (Managers.require(SafezoneModule.class).getSafezone(block.getLocation()) != null)
{
return false;
}
return true;
}
@ -342,7 +345,7 @@ public class LootModule extends MiniPlugin
{
_spawnedChest.add(new SpawnedChest(location, colour, -1));
}
public void fillChest(Player player, Block block, String key)
{
Set<Integer> used = new HashSet<>();
@ -372,7 +375,7 @@ public class LootModule extends MiniPlugin
{
UtilFirework.playFirework(block.getLocation().add(0.5, 1, 0.5), UtilFirework.getRandomFireworkEffect(false, 2, 1));
}
inventory.setItem(index, itemStack);
}
}
@ -449,7 +452,7 @@ public class LootModule extends MiniPlugin
{
return;
}
Player player = event.getPlayer();
Block block = event.getClickedBlock();
@ -464,7 +467,7 @@ public class LootModule extends MiniPlugin
}
String key = null;
for (SpawnedChest chest : _spawnedChest)
{
if (UtilMath.offset(chest.getLocation(), block.getLocation()) < 2)
@ -474,7 +477,7 @@ public class LootModule extends MiniPlugin
break;
}
}
if (key == null)
{
event.setCancelled(true);
@ -483,7 +486,7 @@ public class LootModule extends MiniPlugin
fillChest(player, block, key);
}
@EventHandler
public void inventoryClick(InventoryClickEvent event)
{
@ -491,39 +494,56 @@ public class LootModule extends MiniPlugin
{
return;
}
ItemStack itemStack = event.getCurrentItem();
if (itemStack == null)
{
return;
}
LootItem lootItem = fromItemStack(itemStack);
if (lootItem == null || lootItem.getMetadata() == null)
{
Bukkit.broadcastMessage("Metadata null");
return;
}
Player player = (Player) event.getWhoClicked();
LootItemReward reward;
Bukkit.broadcastMessage(lootItem.getMetadata());
switch (lootItem.getMetadata())
{
case "RANK_UPGRADE":
reward = new LootRankReward();
break;
default:
return;
Player player = (Player) event.getWhoClicked();
LootItemReward reward = null;
for (LootItemReward storedReward : _itemRewards)
{
if (storedReward.getItemStack().isSimilar(itemStack))
{
reward = storedReward;
}
}
Bukkit.broadcastMessage("collect");
reward.collectItem(player);
if (reward == null)
{
Bukkit.broadcastMessage(lootItem.getMetadata());
switch (lootItem.getMetadata())
{
case "RANK_UPGRADE":
reward = new LootRankReward(itemStack);
break;
default:
return;
}
reward.setPlayer(player);
_itemRewards.add(reward);
Bukkit.broadcastMessage("collect");
reward.collectItem(player);
}
else
{
reward.setPlayer(player);
}
}
}

View File

@ -1,9 +1,8 @@
package mineplex.gemhunters.loot.rewards;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -11,9 +10,6 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
/**
* @author Sam
*/
public abstract class LootItemReward
{
@ -22,13 +18,15 @@ public abstract class LootItemReward
private long _firstItemPickup;
private long _cashOutDelay;
private UUID _player;
private Player _player;
private ItemStack _itemStack;
public LootItemReward(String name, long cashOutDelay)
public LootItemReward(String name, long cashOutDelay, ItemStack itemStack)
{
_name = name;
_firstItemPickup = 0;
_cashOutDelay = cashOutDelay;
_itemStack = itemStack;
}
public abstract void onCollectItem(Player player);
@ -39,7 +37,7 @@ public abstract class LootItemReward
public final void collectItem(Player player)
{
if (_player.equals(player.getUniqueId()))
if (_player.equals(player))
{
return;
}
@ -75,14 +73,24 @@ public abstract class LootItemReward
}
public final void update()
public boolean isFirstPickup()
{
if (!UtilTime.elapsed(_firstItemPickup, _cashOutDelay))
{
return;
}
return _firstItemPickup == 0;
}
public void setPlayer(Player player)
{
_player = player;
}
public Player getPlayer()
{
return _player;
}
public ItemStack getItemStack()
{
return _itemStack;
}
}

View File

@ -3,6 +3,7 @@ package mineplex.gemhunters.loot.rewards;
import java.util.concurrent.TimeUnit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.account.CoreClient;
@ -16,9 +17,9 @@ public class LootRankReward extends LootItemReward
private final CoreClientManager _clientManager;
public LootRankReward()
public LootRankReward(ItemStack itemStack)
{
super("Rank", CASH_OUT_DELAY);
super("Rank", CASH_OUT_DELAY, itemStack);
_clientManager = Managers.require(CoreClientManager.class);
}