Fixed some drop item stuff.

This commit is contained in:
Jonathan Williams 2013-10-26 12:02:18 -05:00
parent 95449fec26
commit 1781ed15c4
9 changed files with 140 additions and 32 deletions

View File

@ -43,6 +43,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@ -177,6 +178,26 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
}
@EventHandler
public void orderThatBone(final PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.BONE)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(Material.BONE);
event.getPlayer().getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, 1, ChatColor.RESET + C.cGreen + "Pet Menu"));
event.getPlayer().updateInventory();
}
}
});
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{

View File

@ -67,7 +67,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
String name = args[1];
int amount = Integer.parseInt(args[2]);
_donationManager.RewardGems(null, name, amount);
_donationManager.RewardGems(null, name, "purchase", amount);
System.out.println("enjin gem");
}
else if (args.length == 4 && args[0].equalsIgnoreCase("rank"))

View File

@ -107,7 +107,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
new JumpManager(this);
new NewsManager(this);
new GadgetManager(this, new MountManager(this), clientManager, donationManager);
new GadgetManager(this, new MountManager(this));
_partyManager = partyManager;
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);

View File

@ -2,17 +2,18 @@ package mineplex.hub.gadget;
import java.util.HashSet;
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 mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.hub.HubManager;
import mineplex.hub.gadget.gadgets.Halloween2013_BatGun;
@ -32,7 +33,7 @@ public class GadgetManager extends MiniPlugin
private HashSet<Gadget> _gadgets;
public GadgetManager(HubManager manager, MountManager mountManager, CoreClientManager clientManager, DonationManager donationManager)
public GadgetManager(HubManager manager, MountManager mountManager)
{
super("Gadget Manager", manager.GetPlugin());
@ -40,7 +41,7 @@ public class GadgetManager extends MiniPlugin
CreateGadgets();
_gadgetShop = new GadgetShop(this, mountManager, clientManager, donationManager);
_gadgetShop = new GadgetShop(this, mountManager, Manager.GetClients(), Manager.GetDonation());
}
private void CreateGadgets()
@ -59,6 +60,34 @@ public class GadgetManager extends MiniPlugin
public void onPlayerJoin(PlayerJoinEvent event)
{
event.getPlayer().getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Gadget Menu"));
if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
{
for (Gadget gadget : _gadgets)
{
Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(gadget.GetName());
}
}
}
@EventHandler
public void orderThatChest(final PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.CHEST)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(Material.CHEST);
event.getPlayer().getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Gadget Menu"));
event.getPlayer().updateInventory();
}
}
});
}
}
@EventHandler

View File

@ -10,14 +10,12 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public abstract class Gadget extends SalesPackageBase implements Listener
{
public GadgetManager Manager;
private HashSet<Player> _owners = new HashSet<Player>();
protected HashSet<Player> _active = new HashSet<Player>();
public Gadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data)
@ -30,11 +28,6 @@ public abstract class Gadget extends SalesPackageBase implements Listener
Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin());
}
public HashSet<Player> GetOwners()
{
return _owners;
}
public HashSet<Player> GetActive()
{
return _active;
@ -45,24 +38,9 @@ public abstract class Gadget extends SalesPackageBase implements Listener
return _active.contains(player);
}
public boolean HasGadget(Player player)
{
return _owners.contains(player);
}
@EventHandler
public void PlayerJoin(PlayerJoinEvent event)
{
if (event.getPlayer().isOp())
{
_owners.add(event.getPlayer());
}
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
_owners.remove(event.getPlayer());
Disable(event.getPlayer());
}

View File

@ -2,8 +2,11 @@ package mineplex.hub.gadget.types;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
@ -39,6 +42,26 @@ public abstract class ItemGadget extends Gadget
UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + "."));
}
@EventHandler
public void orderThatChest(final PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == GetDisplayMaterial())
{
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(GetDisplayMaterial());
event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName())));
event.getPlayer().updateInventory();
}
}
});
}
}
public void RemoveItem(Player player)
{
player.getInventory().setItem(4, null);

View File

@ -2,6 +2,8 @@ package mineplex.hub.modules;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -11,6 +13,7 @@ import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@ -42,8 +45,6 @@ public class StackerManager extends MiniPlugin implements IThrown
private HashSet<Player> _disabled = new HashSet<Player>();
private HashSet<Entity> _tempStackShift = new HashSet<Entity>();
private int _slot = 7;
public StackerManager(HubManager manager)
@ -82,7 +83,6 @@ public class StackerManager extends MiniPlugin implements IThrown
}
}
@EventHandler
public void PlayerJoin(PlayerJoinEvent event)
{
@ -90,6 +90,26 @@ public class StackerManager extends MiniPlugin implements IThrown
C.cYellow + "Stacker" + C.cWhite + " - " + C.cGreen + "Enabled"));
}
@EventHandler
public void orderThatItem(final PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.REDSTONE_TORCH_OFF || event.getItemDrop().getItemStack().getType() == Material.REDSTONE_TORCH_ON)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(event.getItemDrop().getItemStack().getType());
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(event.getItemDrop().getItemStack().getType(), (byte)0, 1, ChatColor.RESET + C.cYellow + "Stacker" + C.cWhite + (_disabled.contains(event.getPlayer()) ? C.cWhite + " - " + C.cRed + "Disabled" : " - " + C.cGreen + "Enabled")));
event.getPlayer().updateInventory();
}
}
});
}
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{

View File

@ -3,12 +3,15 @@ package mineplex.hub.modules;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -59,6 +62,26 @@ public class VisibilityManager extends MiniPlugin
_hide.remove(event.getPlayer());
}
@EventHandler
public void orderThatItem(final PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.EYE_OF_ENDER || event.getItemDrop().getItemStack().getType() == Material.ENDER_PEARL)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(event.getItemDrop().getItemStack().getType());
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(event.getItemDrop().getItemStack().getType(), (byte)0, 1, ChatColor.RESET + C.cYellow + "Show Players" + C.cWhite + " - " + (_hide.contains(event.getPlayer()) ? C.cRed + "Disabled" : C.cGreen + "Enabled")));
event.getPlayer().updateInventory();
}
}
});
}
}
@EventHandler
public void ToggleVisibility(PlayerInteractEvent event)
{

View File

@ -8,8 +8,10 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.hub.HubManager;
@ -43,6 +45,18 @@ public class MountManager extends MiniPlugin
return _types;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
{
for (Mount gadget : _types)
{
Manager.GetDonation().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(gadget.GetName());
}
}
}
//Disallows two mounts active
public void DeregisterAll(Player player)
{