From e3fb40805c56fdbfbe775ce934cfa837a2273bcd Mon Sep 17 00:00:00 2001 From: phobia Date: Wed, 9 Mar 2016 22:46:45 +1100 Subject: [PATCH] all siege items shouldn't be able to be placed or used while on PvP timer. Fixes to Jagged prefix --- .../game/clans/clans/ClansManager.java | 7 ++- .../game/clans/clans/pvptimer/PvpTimer.java | 2 +- .../game/clans/clans/siege/SiegeManager.java | 11 ++++ .../clans/clans/siege/outpost/Outpost.java | 12 +++++ .../clans/siege/outpost/OutpostManager.java | 9 +++- .../game/clans/clans/siege/weapon/Cannon.java | 20 ++++++++ .../clans/clans/siege/weapon/Catapult.java | 23 ++++++++- .../attributes/weapon/JaggedAttribute.java | 51 +++++++++---------- 8 files changed, 103 insertions(+), 32 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 4f0445230..516c6ae39 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 @@ -190,7 +190,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati private WarPointEvasion _warPointEvasion; private ObserverManager _observerManager; private Punish _punish; - + private PvpTimer _pvpTimer; + private int _inviteExpire = 2; private int _nameMin = 3; private int _nameMax = 10; @@ -317,7 +318,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati new ClanEnergyManager(plugin, this, clientManager, donationManager); _playTracker = new Playtime(this, statsManager); - new PvpTimer(this, _playTracker, statsManager); + _pvpTimer = new PvpTimer(this, _playTracker, statsManager); _tutorialManager = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler); TutorialManager tutorial = new TutorialManager(plugin, clientManager, donationManager); @@ -1221,4 +1222,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati { return _damageManager; } + + public PvpTimer getPvpTimer() { return _pvpTimer; } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index a814a1439..30f0c8e3c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -274,7 +274,7 @@ public class PvpTimer extends MiniClientPlugin return (TIMER_LENGTH <= time ? 0 : TIMER_LENGTH - time); } - private boolean hasTimer(Player victim) + public boolean hasTimer(Player victim) { return victim != null && getPvPTimerLeft(victim) > 0 && !Get(victim).Skipped; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index 390d47a32..a07b258dd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans.siege; import java.util.Stack; +import mineplex.game.clans.clans.pvptimer.PvpTimer; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -182,6 +183,11 @@ public class SiegeManager extends MiniPlugin UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place a Cannon.")); return false; } + + if(_clansManager.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot place a cannon whilst on PvPTimer")); + return false; + } ClanTerritory claim = _clansManager.getClanUtility().getClaim(location); @@ -217,6 +223,11 @@ public class SiegeManager extends MiniPlugin UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place a Catapult.")); return false; } + + if(_clansManager.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot place a catapult whilst on PvPTimer")); + return false; + } ClanTerritory claim = _clansManager.getClanUtility().getClaim(location); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 15ddf2aa9..1f6e610a8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -303,6 +303,12 @@ public class Outpost implements Listener if (getLifetime() <= 2000) return; + + + if(_outpostManager.getClansManager().getPvpTimer().hasTimer(event.getPlayer())) { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an outpost whilst on PvPTimer")); + return; + } if (!_ownerClan.equals(_ownerClan.Clans.getClanUtility().getClanByPlayer(event.getPlayer()))) { @@ -325,6 +331,12 @@ public class Outpost implements Listener { if (event.getBlock().getLocation().equals(_core) && getState() == OutpostState.LIVE) { + + if(_outpostManager.getClansManager().getPvpTimer().hasTimer(event.getPlayer())) { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an outpost whilst on PvPTimer")); + event.setCancelled(true); + return; + } UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have destroyed " + F.elem(_ownerClan.getName()) + "'s Outpost!")); _core.getBlock().setType(Material.AIR); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java index e2076a611..a507dba26 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java @@ -84,13 +84,20 @@ public class OutpostManager extends MiniPlugin UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place an Outpost.")); return false; } + + if(_clansManager.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot create an outpost whilst on PvPTimer")); + return false; + } if (location.getBlockY() < 30) { UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost this deep.")); return false; } - + + + ClanInfo clan = _clansManager.getClan(player); if (UtilItem.isBoundless(location.clone().subtract(0, 1, 0).getBlock().getType())) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index aab98a18e..3770088f8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -73,6 +73,11 @@ public class Cannon extends SiegeWeapon UtilPlayer.message(player, F.main("Clans", "This cannon is not owned by your Clan.")); return false; } + + if(_clans.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot fire a cannon whilst on PvPTimer")); + return false; + } if (!canBeFired()) { @@ -103,6 +108,11 @@ public class Cannon extends SiegeWeapon UtilPlayer.message(player, F.main("Clans", "Someone is already riding this cannon.")); return false; } + + if(_clans.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot sit in a cannon whilst on PvPTimer")); + return false; + } return !player.equals(getRider()); })); @@ -143,6 +153,11 @@ public class Cannon extends SiegeWeapon UtilPlayer.message(player, F.main("Clans", "This cannon is not owned by your Clan.")); return false; } + + if(_clans.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot fire a cannon whilst on PvPTimer")); + return false; + } if (!canBeFired()) { @@ -173,6 +188,11 @@ public class Cannon extends SiegeWeapon UtilPlayer.message(player, F.main("Clans", "Someone is already riding this cannon.")); return false; } + + if(_clans.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot sit in a cannon whilst on PvPTimer")); + return false; + } return !player.equals(getRider()); })); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Catapult.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Catapult.java index 6a22a4030..6484d1530 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Catapult.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Catapult.java @@ -78,7 +78,12 @@ public class Catapult extends SiegeWeapon UtilPlayer.message(player, F.main("Clans", "This Catapult is not owned by your Clan.")); return false; } - + + if(_clans.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot fire a catapult whilst on PvPTimer")); + return false; + } + if (!canBeFired()) { UtilPlayer.message(player, F.main("Clans", "Catapult is not loaded correctly.")); @@ -108,6 +113,11 @@ public class Catapult extends SiegeWeapon UtilPlayer.message(player, F.main("Clans", "Someone is already riding this Catapult.")); return false; } + + if(_clans.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot sit in a catapult whilst on PvPTimer")); + return false; + } return !player.equals(getRider()); })); @@ -151,7 +161,12 @@ public class Catapult extends SiegeWeapon UtilPlayer.message(player, F.main("Clans", "This Catapult is not owned by your Clan.")); return false; } - + + if(_clans.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannotfire a catapult whilst on PvPTimer")); + return false; + } + if (!canBeFired()) { UtilPlayer.message(player, F.main("Clans", "Catapult is not loaded correctly.")); @@ -181,6 +196,10 @@ public class Catapult extends SiegeWeapon UtilPlayer.message(player, F.main("Clans", "Someone is already riding this Catapult.")); return false; } + if(_clans.getPvpTimer().hasTimer(player)) { + UtilPlayer.message(player, F.main("Clans", "You cannot sit in a cannon whilst on PvPTimer")); + return false; + } return !player.equals(getRider()); })); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java index 3c4186d94..1b532943b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java @@ -3,35 +3,34 @@ package mineplex.game.clans.items.attributes.weapon; import mineplex.game.clans.items.attributes.AttackAttribute; import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.generation.ValueDistribution; - import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; -public class JaggedAttribute extends AttackAttribute -{ - private static ValueDistribution attackGen = generateDistribution(2, 4); - - public JaggedAttribute() - { - super(AttributeType.PREFIX, attackGen.generateIntValue()); - } +public class JaggedAttribute extends AttackAttribute { + private static ValueDistribution attackGen = generateDistribution(2, 4); - @Override - public String getDisplayName() - { - return "Jagged"; - } - - @Override - public String getDescription() - { - return String.format("Every %d attacks mini-stuns enemies", getAttackLimit()); - } - - @Override - public void triggerAttack(Entity attacker, Entity defender) - { - defender.setVelocity(new Vector(0, 0, 0)); - } + public JaggedAttribute() { + super(AttributeType.PREFIX, attackGen.generateIntValue()); + } + + @Override + public String getDisplayName() { + return "Jagged"; + } + + @Override + public String getDescription() { + return String.format("Every %d attacks mini-stuns enemies", getAttackLimit()); + } + + @Override + public void triggerAttack(Entity attacker, Entity defender) { + defender.setVelocity(new Vector(0, 0, 0)); + if (defender instanceof LivingEntity) + ((LivingEntity) defender).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 1, false, false)); + } }