From 3aa896cfc984e1e77d3fc578b27867dfd94a5d2a Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 19 Sep 2019 19:29:27 -0700 Subject: [PATCH] Cleaner TamingSummon initialization/checks --- .../nossr50/listeners/PlayerListener.java | 17 +----- .../nossr50/skills/taming/TamingManager.java | 52 ++++--------------- 2 files changed, 10 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index bd8211699..2640323aa 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -811,23 +811,8 @@ public class PlayerListener implements Listener { } /* CALL OF THE WILD CHECKS */ - Material type = heldItem.getType(); TamingManager tamingManager = mcMMOPlayer.getTamingManager(); - - - switch(type) { - case - } - - if (type == ) { - tamingManager.summonWolf(); - } - else if (type == Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry())) { - tamingManager.summonOcelot(); - } - else if (type == Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry())) { - tamingManager.summonHorse(); - } + tamingManager.processCallOfTheWild(); break; diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 9b26950f3..ee72d3167 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -163,48 +163,6 @@ public class TamingManager extends SkillManager { return pluginRef.getConfigManager().getConfigTaming().getSubSkills().getSharpenedClaws().getBonusDamage().getPVPModifier(); } - /** - * Summon an ocelot to your side. - */ - public void summonOcelot() { - if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) - return; - - if (!pluginRef.getPermissionTools().callOfTheWild(getPlayer(), EntityType.OCELOT)) { - return; - } - - processCallOfTheWild(); - } - - /** - * Summon a wolf to your side. - */ - public void summonWolf() { - if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) - return; - - if (!pluginRef.getPermissionTools().callOfTheWild(getPlayer(), EntityType.WOLF)) { - return; - } - - processCallOfTheWild(); - } - - /** - * Summon a horse to your side. - */ - public void summonHorse() { - if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) - return; - - if (!pluginRef.getPermissionTools().callOfTheWild(getPlayer(), EntityType.HORSE)) { - return; - } - - processCallOfTheWild(); - } - /** * Handle the Beast Lore ability. * @@ -282,7 +240,10 @@ public class TamingManager extends SkillManager { } - private void processCallOfTheWild() { + public void processCallOfTheWild() { + if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) + return; + //Prevent summoning too many things accidentally if a player holds down the button if(lastSummonTimeStamp + 150 > System.currentTimeMillis()) { return; @@ -299,6 +260,11 @@ public class TamingManager extends SkillManager { CallOfTheWildType callOfTheWildType = pluginRef.getDynamicSettingsManager().getTamingItemManager().getCallType(itemInMainHand.getType()); TamingSummon tamingSummon = tamingBehaviour.getSummon(callOfTheWildType); + //Permission Check + if(!pluginRef.getPermissionTools().callOfTheWild(getPlayer(), tamingSummon.getEntityType())) { + return; + } + //Players will pay for the cost if at least one thing was summoned int amountSummoned = 0;