From 1532abcc620d6c34821517b960a68ec9907140b5 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 9 Mar 2016 21:12:02 +0000 Subject: [PATCH] disable nether and legendary fixes --- .../game/clans/clans/ClansManager.java | 2 +- .../mineplex/game/clans/items/CustomItem.java | 40 +------- .../game/clans/items/GearManager.java | 9 -- .../mineplex/game/clans/items/PlayerGear.java | 1 - .../game/clans/items/rares/RunedPickaxe.java | 91 +++++++++++-------- 5 files changed, 57 insertions(+), 86 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 7912db776..7a924de7a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -392,7 +392,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict"); new SiegeManager(this); - _netherManager = new NetherManager(this); +// _netherManager = new NetherManager(this); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java index 534fc3391..d52ebc928 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -29,7 +29,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; * @author MrTwiggy * */ -public class CustomItem implements Listener +public class CustomItem { private static final ChatColor TITLE_COLOR = ChatColor.GOLD; // Chat color @@ -52,12 +52,12 @@ public class CustomItem implements Listener } protected String _displayName; - private String[] _description; - private Material _material; + protected String[] _description; + protected Material _material; - private String _uuid; + protected String _uuid; - private boolean _dullEnchantment; + protected boolean _dullEnchantment; public String OriginalOwner = null; @@ -73,8 +73,6 @@ public class CustomItem implements Listener _material = material; _attributes = new AttributeContainer(); _uuid = UUID.randomUUID().toString(); - - UtilServer.RegisterEvents(this); } public CustomItem(Material material) @@ -95,34 +93,6 @@ public class CustomItem implements Listener return _description; } - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - { - return; - } - - final EnclosedObject success = new EnclosedObject<>(Boolean.FALSE); - - UtilServer.getPlayersCollection().forEach(player -> { - PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(player); - - if (gear.getWeapon() == null) - return; - - if (gear.getWeapon().getUuid().equals(getUuid())) - { - success.Set(Boolean.TRUE); - } - }); - - if (!success.Get().booleanValue()) - { - UtilServer.Unregister(this); - } - } - public List getLore() { List lore = new ArrayList(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 340fee52a..e6a78a9bf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -257,15 +257,6 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable } } - @EventHandler - public void quit(PlayerQuitEvent event) - { - if (_playerGears.get(event.getPlayer().getName()) != null) - { - HandlerList.unregisterAll(_playerGears.get(event.getPlayer().getName()).getWeapon()); - } - } - /** * @param player - the player whose {@link PlayerGear} set is to be fetched. * @return the cached or newly instantiated {@link PlayerGear} associated diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index 2496da4b9..64fec8dcf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -163,7 +163,6 @@ public class PlayerGear if (!itemsMatch(_weapon, weaponItem)) { - HandlerList.unregisterAll(_weapon); _weapon = parseItem(weaponItem); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java index 953e59d40..a62afc92c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java @@ -6,15 +6,21 @@ import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.RGBData; import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.core.repository.ClanTerritory; @@ -22,12 +28,46 @@ import mineplex.game.clans.items.PlayerGear; public class RunedPickaxe extends RareItem { - private long _lastFire = System.currentTimeMillis(); - private long _interactWait; - private long _instamineEnabled; - private RGBData[] colors = { UtilColor.RgbLightBlue, UtilColor.RgbLightBlue.Lighten(), UtilColor.RgbLightBlue.Darken() }; + static + { + UtilServer.RegisterEvents(new Listener() { + @EventHandler(priority = EventPriority.LOWEST) + public void blockDamage(BlockDamageEvent event) + { + PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer()); + + if (!(gear.getWeapon() instanceof RunedPickaxe)) + { + return; + } + + System.out.println(event.getBlock()); + + RunedPickaxe pick = (RunedPickaxe) gear.getWeapon(); + + String playerClan = ClansManager.getInstance().getClanUtility().getClanByPlayer(event.getPlayer()) == null ? null : ClansManager.getInstance().getClanUtility().getClanByPlayer(event.getPlayer()).getName(); + + ClanTerritory territory = ClansManager.getInstance().getClanUtility().getClaim(event.getBlock().getLocation()); + + if (territory != null && !territory.Owner.equals(playerClan)) + return; + + if (event.getBlock().getType() == Material.BEDROCK) + return; + + if (!UtilTime.elapsed(pick._instamineEnabled, 12000)) + { + event.getBlock().breakNaturally(); + + event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.TILE_BREAK, event.getBlock().getType(), 10); + + event.getPlayer().playSound(event.getBlock().getLocation(), Sound.LAVA_POP, 1.f, 1.f); + } + } + }); + } public RunedPickaxe() { @@ -36,48 +76,19 @@ public class RunedPickaxe extends RareItem }, LineFormat.LORE), Material.RECORD_8); } - @Override - public void update(Player wielder) + public void onInteract(PlayerInteractEvent event) { - if ((System.currentTimeMillis() - _lastBlock) < 98) - System.out.println((System.currentTimeMillis() - _lastBlock) + ", " + (System.currentTimeMillis() - _interactWait)); - - if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98) + if (!UtilEvent.isAction(event, ActionType.R)) { - _interactWait = System.currentTimeMillis(); - - if (Recharge.Instance.use(wielder, "Instant Mine", 30000, true, true)) - { - _instamineEnabled = System.currentTimeMillis(); - } + return; } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void blockDamage(BlockDamageEvent event) - { - PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer()); - System.out.println(event.getBlock()); - - String playerClan = ClansManager.getInstance().getClanUtility().getClanByPlayer(event.getPlayer()) == null ? null : ClansManager.getInstance().getClanUtility().getClanByPlayer(event.getPlayer()).getName(); - - ClanTerritory territory = ClansManager.getInstance().getClanUtility().getClaim(event.getBlock().getLocation()); - - if (territory != null && !territory.Owner.equals(playerClan)) - return; - - if (event.getBlock().getType() == Material.BEDROCK) - return; - - if (equals(gear.getWeapon()) && !UtilTime.elapsed(_instamineEnabled, 12000)) + if (Recharge.Instance.use(event.getPlayer(), "Instant Mine", 30000, true, true)) { - event.getBlock().breakNaturally(); - - event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, event.getBlock().getType(), 10); - - event.getPlayer().playSound(event.getBlock().getLocation(), Sound.LAVA_POP, 1.f, 1.f); + _instamineEnabled = System.currentTimeMillis(); } + + super.onInteract(event); } }