From e50eb1963f427f51f7aeeaf45a7a0f84f377ed1d Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 20 Feb 2013 18:20:34 -0500 Subject: [PATCH 001/137] Minor typo. --- src/main/java/com/gmail/nossr50/config/AdvancedConfig.java | 2 +- src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index ef0213e60..494af7b28 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -107,7 +107,7 @@ public class AdvancedConfig extends ConfigLoader { public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); } public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); } - public int getHylianLucksMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); } + public int getHylianLuckMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); } /* MINING */ public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 6fa900c99..e9bdbd56a 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -47,7 +47,7 @@ public class Herbalism { public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getHerbalismDoubleDropsMaxLevel(); public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax(); - public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLucksMaxLevel(); + public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel(); /** * Handle the farmers diet skill. From 3dc1afde7e792f72e81887b0d7e383a2a5708819 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Fri, 22 Feb 2013 01:08:37 -0500 Subject: [PATCH 002/137] Add graph to see if any config values have been changed from the default, or if a server is 100% vanilla configs --- .../gmail/nossr50/config/ConfigLoader.java | 9 +++++++ .../nossr50/util/metrics/MetricsManager.java | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index ceb305d54..fa6dcacde 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -16,6 +16,7 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.util.metrics.MetricsManager; public abstract class ConfigLoader { protected static final mcMMO plugin = mcMMO.p; @@ -129,6 +130,14 @@ public abstract class ConfigLoader { e.printStackTrace(); } } + else { + for (String key : configKeys) { + if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) { + MetricsManager.customConfig(); + break; + } + } + } } protected abstract void loadKeys(); diff --git a/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java b/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java index 79b08827a..ababef612 100644 --- a/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java +++ b/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java @@ -22,6 +22,8 @@ public class MetricsManager { private static Tracker chimeraUseTracker; private static Tracker chimeraServerUseTracker; + private static boolean customConfig = false; + private static DataTracker tracker; private static EMetrics emetrics; @@ -220,6 +222,26 @@ public class MetricsManager { }); } + // Vanilla v Modified config graph + Graph customConfigGraph = metrics.createGraph("Modified Configs"); + + if (customConfig) { + customConfigGraph.addPlotter(new Metrics.Plotter("Edited") { + @Override + public int getValue() { + return 1; + } + }); + } + else { + customConfigGraph.addPlotter(new Metrics.Plotter("Vanilla") { + @Override + public int getValue() { + return 1; + } + }); + } + /* Debug stuff tracker = emetrics.getDataTracker(); tracker.enable(); @@ -239,6 +261,10 @@ public class MetricsManager { chimeraServerUseTracker.increment(); } + public static void customConfig() { + customConfig = true; + } + @SuppressWarnings("unused") private static void debug() { emetrics.getMetrics().flush(); From 0a68b82078fd36bd6fc5d1251d22fc6f69db2970 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 09:53:18 -0500 Subject: [PATCH 003/137] Fixes wolves gaining combat bonuses based on their owner's held item. Closes #713 --- .../nossr50/skills/utilities/CombatTools.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index 8f6f40d07..211d6593c 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -58,8 +58,9 @@ public final class CombatTools { public static void combatChecks(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) { boolean targetIsPlayer = (target.getType() == EntityType.PLAYER); boolean targetIsTamedPet = (target instanceof Tameable) ? ((Tameable) target).isTamed() : false; + Entity damager = event.getDamager(); - if (attacker instanceof Player) { + if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) { Player player = (Player) attacker; if (Misc.isNPCEntity(player)) { @@ -72,9 +73,8 @@ public final class CombatTools { ItemStack heldItem = player.getItemInHand(); Material heldItemType = heldItem.getType(); - DamageCause damageCause = event.getCause(); - if (ItemChecks.isSword(heldItem) && damageCause == DamageCause.ENTITY_ATTACK) { + if (ItemChecks.isSword(heldItem)) { if (targetIsPlayer || targetIsTamedPet) { if (!SkillType.SWORDS.getPVPEnabled()) { return; @@ -105,7 +105,7 @@ public final class CombatTools { startGainXp(mcMMOPlayer, target, SkillType.SWORDS); } } - else if (ItemChecks.isAxe(heldItem) && damageCause == DamageCause.ENTITY_ATTACK) { + else if (ItemChecks.isAxe(heldItem)) { if (targetIsPlayer || targetIsTamedPet) { if (!SkillType.AXES.getPVPEnabled()) { return; @@ -143,7 +143,7 @@ public final class CombatTools { startGainXp(mcMMOPlayer, target, SkillType.AXES); } } - else if (heldItemType == Material.AIR && damageCause == DamageCause.ENTITY_ATTACK) { + else if (heldItemType == Material.AIR) { if (targetIsPlayer || targetIsTamedPet) { if (!SkillType.UNARMED.getPVPEnabled()) { return; @@ -178,15 +178,13 @@ public final class CombatTools { startGainXp(mcMMOPlayer, target, SkillType.UNARMED); } } - else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player) && damageCause == DamageCause.ENTITY_ATTACK) { + else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) { TamingManager tamingManager = new TamingManager(Users.getPlayer(player)); tamingManager.beastLore(target); event.setCancelled(true); } } - Entity damager = event.getDamager(); - switch (damager.getType()) { case WOLF: Wolf wolf = (Wolf) damager; From 84dce845a5f6ee48c2344079d91b4895c4815984 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 11:14:13 -0500 Subject: [PATCH 004/137] Weekly beta release. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5293ed23c..2740956bc 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.4.00-dev4 + 1.4.00-beta4 mcMMO https://github.com/mcMMO-Dev/mcMMO From 513a9212e47d61a8d8258a481c36cdf8ee9a2c33 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 11:17:43 -0500 Subject: [PATCH 005/137] Back to active development. --- Changelog.txt | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 9def7a325..9e5884526 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -70,6 +70,7 @@ Version 1.4.00-dev = Fixed a bug where a new party leader wasn't appointed, after the previous party leader left = Fixed a bug where Disarm and Deflect had wrong values = Fixed Magic Hunter (Fishing ability) favoring certain enchants + ! Changed some config value key names regarding double drops and XP - make sure you copy any custom values to your new config after updating. ! Changed Green Terra blocks to be determined via permissions instead of the config file ! Config files are now backed up even when running in SQL mode ! Changed /p and /a to use /partychat and /adminchat as the default command name. The use of /p, /pc, /a, and /ac is still supported. diff --git a/pom.xml b/pom.xml index 2740956bc..ae3836756 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.4.00-beta4 + 1.4.00-dev5 mcMMO https://github.com/mcMMO-Dev/mcMMO From d052d7a3ced8ba7d971cb12fb362b744fb6722c8 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Fri, 22 Feb 2013 11:23:46 -0500 Subject: [PATCH 006/137] Change from using Block to BlockState in many locations Convert Herbalism ability to use BlockState instead of Block. Move all block checks back to BlockChecks. Don't need this if we're using BlockState Convert Excavation to BlockState. We don't need to return booleans here because we never edit the block state.Switch ModCheck.getCustomBlock to use BlockState More work on the conversion to BlockState More conversion to BlockState Better way to handle mining drops, I believe. Remove useless imports. A test of making the diff look nicer BlockChecks diff cleanup Herbalism diff cleanup Gotta update the block states here. Moar blockstate. Little more blockState stuff. Even more blockstate. --- .../nossr50/listeners/BlockListener.java | 111 +++-- .../nossr50/listeners/PlayerListener.java | 14 +- .../nossr50/listeners/WorldListener.java | 9 +- .../com/gmail/nossr50/mods/ModChecks.java | 169 +++++-- .../nossr50/skills/excavation/Excavation.java | 116 ++--- .../skills/herbalism/GreenThumbTimer.java | 86 ---- .../nossr50/skills/herbalism/Herbalism.java | 442 ++++++++++-------- .../mining/BlastMiningDropEventHandler.java | 45 +- .../gmail/nossr50/skills/mining/Mining.java | 162 +++---- .../mining/MiningBlockEventHandler.java | 45 -- .../nossr50/skills/mining/MiningManager.java | 22 - .../smelting/FluxMiningEventHandler.java | 68 --- .../nossr50/skills/smelting/Smelting.java | 57 +++ .../skills/smelting/SmeltingManager.java | 14 - .../gmail/nossr50/skills/unarmed/Unarmed.java | 18 +- .../nossr50/skills/utilities/AbilityType.java | 18 +- .../nossr50/skills/utilities/SkillTools.java | 32 +- .../skills/woodcutting/TreeFeller.java | 173 ++++--- .../skills/woodcutting/Woodcutting.java | 130 ++---- .../woodcutting/WoodcuttingCommand.java | 3 +- .../com/gmail/nossr50/util/BlockChecks.java | 231 ++++----- .../blockmeta/chunkmeta/ChunkManager.java | 24 + .../blockmeta/chunkmeta/HashChunkManager.java | 30 +- .../blockmeta/chunkmeta/NullChunkManager.java | 12 + 24 files changed, 994 insertions(+), 1037 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/mining/MiningBlockEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/smelting/FluxMiningEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index d705da386..269bbed25 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -6,6 +6,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -31,10 +32,10 @@ import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.runnables.StickyPistonTracker; import com.gmail.nossr50.skills.excavation.Excavation; import com.gmail.nossr50.skills.herbalism.Herbalism; -import com.gmail.nossr50.skills.mining.MiningManager; +import com.gmail.nossr50.skills.mining.Mining; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; -import com.gmail.nossr50.skills.smelting.SmeltingManager; +import com.gmail.nossr50.skills.smelting.Smelting; import com.gmail.nossr50.skills.unarmed.Unarmed; import com.gmail.nossr50.skills.utilities.AbilityType; import com.gmail.nossr50.skills.utilities.SkillTools; @@ -108,15 +109,15 @@ public class BlockListener implements Listener { return; } - Block block = event.getBlock(); + BlockState blockState = event.getBlock().getState(); /* Check if the blocks placed should be monitored so they do not give out XP in the future */ - if (BlockChecks.shouldBeWatched(block)) { - mcMMO.placeStore.setTrue(block); + if (BlockChecks.shouldBeWatched(blockState)) { + mcMMO.placeStore.setTrue(blockState); } if (Repair.anvilMessagesEnabled) { - int blockID = block.getTypeId(); + int blockID = blockState.getTypeId(); if (blockID == Repair.anvilID) { Repair.placedAnvilCheck(player, blockID); @@ -146,11 +147,12 @@ public class BlockListener implements Listener { McMMOPlayer mcMMOPlayer = Users.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - Block block = event.getBlock(); + BlockState blockState = event.getBlock().getState(); + ItemStack heldItem = player.getItemInHand(); /* HERBALISM */ - if (BlockChecks.canBeGreenTerra(block)) { + if (BlockChecks.affectedByGreenTerra(blockState)) { /* Green Terra */ if (profile.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(player)) { SkillTools.abilityCheck(player, SkillType.HERBALISM); @@ -161,53 +163,57 @@ public class BlockListener implements Listener { * Instead, we check it inside the drops handler. */ if (Permissions.skillEnabled(player, SkillType.HERBALISM)) { - Herbalism.herbalismProcCheck(block, mcMMOPlayer, plugin); //Double drops - if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) { - Herbalism.herbalismProcCheck(block, mcMMOPlayer, plugin); //Triple drops + //Double drops + if (Herbalism.herbalismBlockCheck(blockState, player)) { + blockState.update(); + } + + //Triple drops + if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && Herbalism.herbalismBlockCheck(blockState, player)) { + blockState.update(); } } } /* MINING */ - else if (BlockChecks.canBeSuperBroken(block) && ItemChecks.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(block)) { - MiningManager miningManager = new MiningManager(mcMMOPlayer); - miningManager.miningBlockCheck(block); + else if (BlockChecks.affectedBySuperBreaker(blockState) && ItemChecks.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) { + Mining.miningBlockCheck(blockState, player); if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) { - miningManager.miningBlockCheck(block); + Mining.miningBlockCheck(blockState, player); } } /* WOOD CUTTING */ - else if (BlockChecks.isLog(block) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(block)) { + else if (BlockChecks.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) { if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemChecks.isAxe(heldItem)) { - Woodcutting.beginTreeFeller(mcMMOPlayer, block); + Woodcutting.beginTreeFeller(blockState, player); } else { if (Config.getInstance().getWoodcuttingRequiresTool()) { if (ItemChecks.isAxe(heldItem)) { - Woodcutting.beginWoodcutting(mcMMOPlayer, block); + Woodcutting.beginWoodcutting(player, blockState); } } else { - Woodcutting.beginWoodcutting(mcMMOPlayer, block); + Woodcutting.beginWoodcutting(player, blockState); } } } /* EXCAVATION */ - else if (BlockChecks.canBeGigaDrillBroken(block) && ItemChecks.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(block)) { - Excavation.excavationProcCheck(block, mcMMOPlayer); + else if (BlockChecks.affectedByGigaDrillBreaker(blockState) && ItemChecks.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) { + Excavation.excavationBlockCheck(blockState, player); if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { - Excavation.gigaDrillBreaker(mcMMOPlayer, block); + Excavation.gigaDrillBreaker(blockState, player); } } /* Remove metadata from placed watched blocks */ - if (BlockChecks.shouldBeWatched(block) && mcMMO.placeStore.isTrue(block)) { - mcMMO.placeStore.setFalse(block); + if (BlockChecks.shouldBeWatched(blockState) && mcMMO.placeStore.isTrue(blockState)) { + mcMMO.placeStore.setFalse(blockState); } } @@ -228,15 +234,20 @@ public class BlockListener implements Listener { return; } - Block block = event.getBlock(); + BlockState blockState = event.getBlock().getState(); ItemStack heldItem = player.getItemInHand(); if (Permissions.hylianLuck(player) && ItemChecks.isSword(heldItem)) { - Herbalism.hylianLuck(block, player, event); + if (Herbalism.processHylianLuck(blockState, player)) { + event.setCancelled(true); + blockState.update(); + } } - else if (BlockChecks.canBeFluxMined(block) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(block)) { - SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player)); - smeltingManager.fluxMining(event); + else if (BlockChecks.affectedByFluxMining(blockState) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState)) { + if (Smelting.processFluxMining(blockState, player)) { + event.setCancelled(true); + blockState.update(); + } } } @@ -258,14 +269,14 @@ public class BlockListener implements Listener { } PlayerProfile profile = Users.getPlayer(player).getProfile(); - Block block = event.getBlock(); + BlockState blockState = event.getBlock().getState(); /* * ABILITY PREPARATION CHECKS * * We check permissions here before processing activation. */ - if (BlockChecks.canActivateAbilities(block)) { + if (BlockChecks.canActivateAbilities(blockState)) { ItemStack heldItem = player.getItemInHand(); if (HiddenConfig.getInstance().useEnchantmentBuffs()) { @@ -274,24 +285,24 @@ public class BlockListener implements Listener { } } else { - if ((profile.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockChecks.canBeSuperBroken(block)) || (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockChecks.canBeGigaDrillBroken(block))) { + if ((profile.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockChecks.affectedBySuperBreaker(blockState)) || (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockChecks.affectedByGigaDrillBreaker(blockState))) { SkillTools.handleAbilitySpeedDecrease(player); } } - if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block)) && Permissions.greenTerra(player)) { + if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.affectedByGreenTerra(blockState) || BlockChecks.canMakeMossy(blockState)) && Permissions.greenTerra(player)) { SkillTools.abilityCheck(player, SkillType.HERBALISM); } - else if (profile.getToolPreparationMode(ToolType.AXE) && ItemChecks.isAxe(heldItem) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) { + else if (profile.getToolPreparationMode(ToolType.AXE) && ItemChecks.isAxe(heldItem) && BlockChecks.isLog(blockState) && Permissions.treeFeller(player)) { SkillTools.abilityCheck(player, SkillType.WOODCUTTING); } - else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemChecks.isPickaxe(heldItem) && BlockChecks.canBeSuperBroken(block) && Permissions.superBreaker(player)) { + else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemChecks.isPickaxe(heldItem) && BlockChecks.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) { SkillTools.abilityCheck(player, SkillType.MINING); } - else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.canBeGigaDrillBroken(block) && Permissions.gigaDrillBreaker(player)) { + else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) { SkillTools.abilityCheck(player, SkillType.EXCAVATION); } - else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW || (block.getType() == Material.SMOOTH_BRICK && block.getData() == 0x0)) && Permissions.berserk(player)) { + else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockChecks.affectedByBlockCracker(blockState) && Permissions.berserk(player))) { SkillTools.abilityCheck(player, SkillType.UNARMED); } } @@ -301,8 +312,8 @@ public class BlockListener implements Listener { * * We don't need to check permissions here because they've already been checked for the ability to even activate. */ - if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockChecks.isLog(block)) { - player.playSound(block.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH); + if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockChecks.isLog(blockState)) { + player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH); } } @@ -327,41 +338,45 @@ public class BlockListener implements Listener { PlayerProfile profile = mcMMOPlayer.getProfile(); ItemStack heldItem = player.getItemInHand(); Block block = event.getBlock(); + BlockState blockState = block.getState(); /* * ABILITY TRIGGER CHECKS * * We don't need to check permissions here because they've already been checked for the ability to even activate. */ - if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(block)) { - Herbalism.greenTerra(player, block); + if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(blockState)) { + if (Herbalism.processGreenTerra(blockState, player)) { + blockState.update(); + } } else if (profile.getAbilityMode(AbilityType.BERSERK)) { if (SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) { if (heldItem.getType() == Material.AIR) { - FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); - plugin.getServer().getPluginManager().callEvent(armswing); + plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player)); event.setInstaBreak(true); player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); } } // Another perm check for the cracked blocks activation - else if (BlockChecks.canBeCracked(block) && Permissions.blockCracker(player)) { - Unarmed.blockCracker(player, block); + else if (BlockChecks.affectedByBlockCracker(blockState) && Permissions.blockCracker(player)) { + if (Unarmed.blockCracker(player, blockState)) { + blockState.update(); + } } } - else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(block)) { + else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(blockState)) { if (SkillTools.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) { if (Config.getInstance().getWoodcuttingRequiresTool()) { if (ItemChecks.isAxe(heldItem)) { event.setInstaBreak(true); - Woodcutting.beginLeafBlower(player, block); + Woodcutting.beginLeafBlower(player, blockState); } } else if (!(heldItem.getType() == Material.SHEARS)) { event.setInstaBreak(true); - Woodcutting.beginLeafBlower(player, block); + Woodcutting.beginLeafBlower(player, blockState); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index b32671e55..f415d9e4f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; @@ -326,15 +327,16 @@ public class PlayerListener implements Listener { } Block block = event.getClickedBlock(); + BlockState blockState = block.getState(); ItemStack heldItem = player.getItemInHand(); switch (event.getAction()) { case RIGHT_CLICK_BLOCK: /* ACTIVATION & ITEM CHECKS */ - if (BlockChecks.canActivateAbilities(block)) { + if (BlockChecks.canActivateAbilities(blockState)) { if (SkillTools.abilitiesEnabled) { - if (BlockChecks.canActivateHerbalism(block)) { + if (BlockChecks.canActivateHerbalism(blockState)) { SkillTools.activationCheck(player, SkillType.HERBALISM); } @@ -350,8 +352,12 @@ public class PlayerListener implements Listener { } /* GREEN THUMB CHECK */ - if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(block)) { - Herbalism.greenThumbBlocks(heldItem, player, block); + if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(blockState)) { + heldItem.setAmount(heldItem.getAmount() - 1); + + if (Herbalism.processGreenThumbBlocks(blockState, player) && SkillTools.blockBreakSimulate(block, player, false)) { + blockState.update(); + } } break; diff --git a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java index e6a9724a6..1460958c7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.ArrayList; import org.bukkit.Chunk; +import org.bukkit.Location; import org.bukkit.TreeType; import org.bukkit.World; import org.bukkit.block.BlockState; @@ -34,9 +35,11 @@ public class WorldListener implements Listener { return; } - if (mcMMO.placeStore.isTrue(event.getLocation().getBlock())) { - for (BlockState block : event.getBlocks()) { - mcMMO.placeStore.setFalse(block.getBlock()); + Location location = event.getLocation(); + + if (mcMMO.placeStore.isTrue(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld())) { + for (BlockState blockState : event.getBlocks()) { + mcMMO.placeStore.setFalse(blockState); } } } diff --git a/src/main/java/com/gmail/nossr50/mods/ModChecks.java b/src/main/java/com/gmail/nossr50/mods/ModChecks.java index 7f81f06a2..e793bf518 100644 --- a/src/main/java/com/gmail/nossr50/mods/ModChecks.java +++ b/src/main/java/com/gmail/nossr50/mods/ModChecks.java @@ -1,9 +1,8 @@ package com.gmail.nossr50.mods; -import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.mods.config.CustomArmorConfig; @@ -47,23 +46,19 @@ public final class ModChecks { /** * Get the custom block associated with an block. * - * @param block The block to check + * @param blockState The block to check * @return the block if it exists, null otherwise */ - public static CustomBlock getCustomBlock(Block block) { - if (!Config.getInstance().getBlockModsEnabled()) { - return null; - } + public static CustomBlock getCustomBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); - - if (!CustomBlocksConfig.getInstance().customItems.contains(item)) { - return null; - } - - for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) { - if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) { - return b; + if (CustomBlocksConfig.getInstance().customItems.contains(item)) { + for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return block; + } + } } } @@ -85,18 +80,42 @@ public final class ModChecks { } /** - * Check if a custom block is a mining block. + * Check if a custom block is a woodcutting block. * * @param block The block to check - * @return true if the block is custom, false otherwise + * @return true if the block represents a log, false otherwise */ - public static boolean isCustomMiningBlock(Block block) { - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); + public static boolean isCustomWoodcuttingBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); - if (customBlocksEnabled && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) { - for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) { - if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) { - return true; + if (CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(item)) { + for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block should not activate abilites. + * + * @param block The block to check + * @return true if the block represents an ability block, false otherwise + */ + public static boolean isCustomAbilityBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) { + for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } } } } @@ -110,13 +129,59 @@ public final class ModChecks { * @param block The block to check * @return true if the block is custom, false otherwise */ - public static boolean isCustomExcavationBlock(Block block) { - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); + public static boolean isCustomMiningBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); - if (customBlocksEnabled && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) { - for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) { - if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) { - return true; + if (CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) { + for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block is an excavation block. + * + * @param block The block to check + * @return true if the block is custom, false otherwise + */ + public static boolean isCustomExcavationBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) { + for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block is an herbalism block. + * + * @param blockState The block to check + * @return true if the block is custom, false otherwise + */ + public static boolean isCustomHerbalismBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) { + for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } } } } @@ -130,13 +195,15 @@ public final class ModChecks { * @param block The block to check * @return true if the block represents leaves, false otherwise */ - public static boolean isCustomLeafBlock(Block block) { - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); + public static boolean isCustomLeafBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); - if (CustomBlocksConfig.getInstance().customLeaves.contains(item)) { - for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) { - if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) { - return true; + if (CustomBlocksConfig.getInstance().customLeaves.contains(item)) { + for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } } } } @@ -150,13 +217,15 @@ public final class ModChecks { * @param block The block to check * @return true if the block represents a log, false otherwise */ - public static boolean isCustomLogBlock(Block block) { - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); + public static boolean isCustomLogBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); - if (CustomBlocksConfig.getInstance().customLogs.contains(item)) { - for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) { - if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) { - return true; + if (CustomBlocksConfig.getInstance().customLogs.contains(item)) { + for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } } } } @@ -167,16 +236,18 @@ public final class ModChecks { /** * Check if a custom block is an ore block. * - * @param block The block to check + * @param blockState The block to check * @return true if the block represents an ore, false otherwise */ - public static boolean isCustomOreBlock(Block block) { - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); + public static boolean isCustomOreBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); - if (CustomBlocksConfig.getInstance().customOres.contains(item)) { - for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) { - if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) { - return true; + if (CustomBlocksConfig.getInstance().customOres.contains(item)) { + for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } } } } diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index 0e7cd88a4..6d935ca45 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -4,8 +4,7 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import com.gmail.nossr50.config.Config; @@ -17,67 +16,34 @@ import com.gmail.nossr50.skills.utilities.PerksUtils; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; public class Excavation { /** - * Check to see if treasures were found. + * Process treasure drops & XP gain for Excavation. * - * @param block The block to check - * @param mcMMOPlayer The player who broke the block + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability */ - public static void excavationProcCheck(Block block, McMMOPlayer mcMMOPlayer) { - Material material = block.getType(); - int xp = Config.getInstance().getXp(SkillType.EXCAVATION, material); + public static void excavationBlockCheck(BlockState blockState, Player player) { + McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + int xp = Config.getInstance().getXp(SkillType.EXCAVATION, blockState.getType()); - if (xp == 0 && ModChecks.isCustomExcavationBlock(block)) { - xp = ModChecks.getCustomBlock(block).getXpGain(); + if (xp == 0 && ModChecks.isCustomExcavationBlock(blockState)) { + xp = ModChecks.getCustomBlock(blockState).getXpGain(); } - Player player = mcMMOPlayer.getPlayer(); - List treasures = new ArrayList(); - if (Permissions.excavationTreasureHunter(player)) { - switch (material) { - case DIRT: - treasures = TreasuresConfig.getInstance().excavationFromDirt; - break; + List treasures = getTreasures(blockState); - case GRASS: - treasures = TreasuresConfig.getInstance().excavationFromGrass; - break; + if (!treasures.isEmpty()) { + int skillLevel = mcMMOPlayer.getProfile().getSkillLevel(SkillType.EXCAVATION); + int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.EXCAVATION); + Location location = blockState.getLocation(); - case SAND: - treasures = TreasuresConfig.getInstance().excavationFromSand; - break; - - case GRAVEL: - treasures = TreasuresConfig.getInstance().excavationFromGravel; - break; - - case CLAY: - treasures = TreasuresConfig.getInstance().excavationFromClay; - break; - - case MYCEL: - treasures = TreasuresConfig.getInstance().excavationFromMycel; - break; - - case SOUL_SAND: - treasures = TreasuresConfig.getInstance().excavationFromSoulSand; - break; - - default: - break; - } - - Location location = block.getLocation(); - - for (ExcavationTreasure treasure : treasures) { - if (mcMMOPlayer.getProfile().getSkillLevel(SkillType.EXCAVATION) >= treasure.getDropLevel()) { - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.EXCAVATION); - - if (Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) { + for (ExcavationTreasure treasure : treasures) { + if (skillLevel >= treasure.getDropLevel() && Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) { xp += treasure.getXp(); Misc.dropItem(location, treasure.getDrop()); } @@ -89,13 +55,47 @@ public class Excavation { } /** - * Handle triple drops from Giga Drill Breaker. + * Process the Giga Drill Breaker ability. * - * @param mcMMOPlayer The player using the ability - * @param block The block to check + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability */ - public static void gigaDrillBreaker(McMMOPlayer mcMMOPlayer, Block block) { - Excavation.excavationProcCheck(block, mcMMOPlayer); - Excavation.excavationProcCheck(block, mcMMOPlayer); + public static void gigaDrillBreaker(BlockState blockState, Player player) { + Excavation.excavationBlockCheck(blockState, player); + Excavation.excavationBlockCheck(blockState, player); } -} \ No newline at end of file + + /** + * Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block. + * + * @param blockState The {@link BlockState} of the block to check. + * @return the list of treasures that could be found + */ + private static List getTreasures(BlockState blockState) { + switch (blockState.getType()) { + case DIRT: + return TreasuresConfig.getInstance().excavationFromDirt; + + case GRASS: + return TreasuresConfig.getInstance().excavationFromGrass; + + case SAND: + return TreasuresConfig.getInstance().excavationFromSand; + + case GRAVEL: + return TreasuresConfig.getInstance().excavationFromGravel; + + case CLAY: + return TreasuresConfig.getInstance().excavationFromClay; + + case MYCEL: + return TreasuresConfig.getInstance().excavationFromMycel; + + case SOUL_SAND: + return TreasuresConfig.getInstance().excavationFromSoulSand; + + default: + return new ArrayList(); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java deleted file mode 100644 index 1d32e5a66..000000000 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.gmail.nossr50.skills.herbalism; - -import org.bukkit.CropState; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.material.CocoaPlant; -import org.bukkit.material.CocoaPlant.CocoaPlantSize; - -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillType; - -public class GreenThumbTimer implements Runnable { - private Block block; - private PlayerProfile profile; - private Material type; - - public GreenThumbTimer(Block block, PlayerProfile profile, Material material) { - this.block = block; - this.profile = profile; - this.type = material; - } - - @Override - public void run() { - this.block.setType(this.type); - - int skillLevel = this.profile.getSkillLevel(SkillType.HERBALISM); - int greenThumbStage = skillLevel / Herbalism.greenThumbStageChangeLevel; - - if (greenThumbStage > 4) { - greenThumbStage = 4; - } - - switch(this.type) { - case CROPS: - case CARROT: - case POTATO: - //This replants the wheat at a certain stage in development based on Herbalism Skill - if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) { - this.block.setData((byte) greenThumbStage); - } - else { - this.block.setData(CropState.MEDIUM.getData()); - } - break; - case NETHER_WARTS: - if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) { - if (greenThumbStage == 3) { - this.block.setData((byte) 0x2); - } - else if (greenThumbStage == 2) { - this.block.setData((byte) 0x1); - } - else { - this.block.setData((byte) 0x0); - } - } - else { - this.block.setData((byte) 0x2); - } - break; - case COCOA: - CocoaPlant plant = (CocoaPlant) block.getState().getData(); - - if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) { - if (greenThumbStage == 3) { - plant.setSize(CocoaPlantSize.MEDIUM); - } - else if (greenThumbStage == 2) { - plant.setSize(CocoaPlantSize.MEDIUM); - } - else { - plant.setSize(CocoaPlantSize.SMALL); - } - } - else { - plant.setSize(CocoaPlantSize.MEDIUM); - } - block.setData(plant.getData()); - break; - default: - break; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index e9bdbd56a..9c3f44fbf 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -3,29 +3,29 @@ package com.gmail.nossr50.skills.herbalism; import java.util.ArrayList; import java.util.List; -import org.bukkit.DyeColor; +import org.bukkit.CropState; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.material.CocoaPlant; +import org.bukkit.material.CocoaPlant.CocoaPlantSize; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.TreasuresConfig; -import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.treasure.HylianTreasure; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.mods.datatypes.CustomBlock; import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.PerksUtils; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; @@ -65,63 +65,87 @@ public class Herbalism { } /** - * Activate the Green Terra ability. + * Process the Green Terra ability. * - * @param player The player activating the ability - * @param block The block to be changed by Green Terra + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + * @return true if the ability was successful, false otherwise */ - public static void greenTerra(Player player, Block block) { - PlayerInventory inventory = player.getInventory(); - boolean hasSeeds = inventory.contains(Material.SEEDS); + public static boolean processGreenTerra(BlockState blockState, Player player) { + PlayerInventory playerInventory = player.getInventory(); + ItemStack seed = new ItemStack(Material.SEEDS); - if (!hasSeeds) { + if (!playerInventory.containsAtLeast(seed, 1)) { player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore")); - return; + return false; } - inventory.removeItem(new ItemStack(Material.SEEDS)); - player.updateInventory(); // Needed until replacement available - greenTerraConvert(player, block); + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + + return convertGreenTerraBlocks(blockState, player); } - public static void greenTerraConvert(Player player, Block block) { - if (SkillTools.blockBreakSimulate(block, player, false)) { - Material type = block.getType(); + /** + * Convert blocks affected by the Green Thumb & Green Terra abilities. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + * @return true if the ability was successful, false otherwise + */ + private static boolean convertGreenTerraBlocks(BlockState blockState, Player player) { + Material blockType = blockState.getType(); - if (!Permissions.greenThumbBlock(player, type)) { - return; - } + if (!Permissions.greenThumbBlock(player, blockType)) { + return false; + } - switch (type) { - case SMOOTH_BRICK: - block.setData((byte) 0x1); - return; + switch (blockType) { + case COBBLE_WALL: + case SMOOTH_BRICK: + blockState.setRawData((byte) 0x1); + return true; - case DIRT: - block.setType(Material.GRASS); - return; + case DIRT: + blockState.setType(Material.GRASS); + return true; - case COBBLESTONE: - block.setType(Material.MOSSY_COBBLESTONE); - return; + case COBBLESTONE: + blockState.setType(Material.MOSSY_COBBLESTONE); + return true; - case COBBLE_WALL: - block.setData((byte) 0x1); - return; - - default: - return; - } + default: + return false; } } - private static int calculateCatciAndSugarDrops(Block block) { - Material blockType = block.getType(); + /** + * Calculate the drop amounts for cacti & sugar cane based on the blocks above them. + * + * @param blockState The {@link BlockState} of the bottom block of the plant + * @return the number of bonus drops to award from the blocks in this plant + */ + private static int calculateCatciAndSugarDrops(BlockState blockState) { + Block block = blockState.getBlock(); + Material blockType = blockState.getType(); int dropAmount = 0; - for (int y = 0; y <= 2; y++) { + // Handle the original block + if (!mcMMO.placeStore.isTrue(blockState)) { + dropAmount++; + } + + // Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally + for (int y = 1; y < 3; y++) { Block relativeBlock = block.getRelative(BlockFace.UP, y); - if (relativeBlock.getType() == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) { + Material relativeBlockType = relativeBlock.getType(); + + // If the first one is air, so is the next one + if (relativeBlockType == Material.AIR) { + break; + } + + if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) { dropAmount++; } } @@ -130,23 +154,18 @@ public class Herbalism { } /** - * Check for extra Herbalism drops. + * Process double drops & XP gain for Herbalism. * - * @param block The block to check for extra drops - * @param mcMMOPlayer The player getting extra drops - * @param event The event to use for Green Thumb - * @param plugin mcMMO plugin instance + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + * @return true if the ability was successful, false otherwise */ - public static void herbalismProcCheck(final Block block, McMMOPlayer mcMMOPlayer, mcMMO plugin) { - Player player = mcMMOPlayer.getPlayer(); - + public static boolean herbalismBlockCheck(BlockState blockState, Player player) { if (Config.getInstance().getHerbalismAFKDisabled() && player.isInsideVehicle()) { - return; + return false; } - PlayerProfile profile = mcMMOPlayer.getProfile(); - int herbLevel = profile.getSkillLevel(SkillType.HERBALISM); - Material blockType = block.getType(); + Material blockType = blockState.getType(); HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType); CustomBlock customBlock = null; @@ -154,199 +173,226 @@ public class Herbalism { int xp = 0; int dropAmount = 1; ItemStack dropItem = null; + boolean update = false; if (herbalismBlock != null) { if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) { dropItem = herbalismBlock.getDropItem(); - dropAmount = calculateCatciAndSugarDrops(block); + dropAmount = calculateCatciAndSugarDrops(blockState); xp = herbalismBlock.getXpGain() * dropAmount; } else if (herbalismBlock.hasGreenThumbPermission(player)){ dropItem = herbalismBlock.getDropItem(); xp = herbalismBlock.getXpGain(); - - greenThumbWheat(block, player, plugin); + update = processGreenThumbPlants(blockState, player); } else { - if (!mcMMO.placeStore.isTrue(block)) { + if (!mcMMO.placeStore.isTrue(blockState)) { dropItem = herbalismBlock.getDropItem(); xp = herbalismBlock.getXpGain(); } } } else { - customBlock = ModChecks.getCustomBlock(block); + customBlock = ModChecks.getCustomBlock(blockState); dropItem = customBlock.getItemDrop(); xp = customBlock.getXpGain(); } - if (Permissions.doubleDrops(player, SkillType.HERBALISM)) { - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.HERBALISM); - double chance = (doubleDropsMaxChance / doubleDropsMaxLevel) * SkillTools.skillCheck(herbLevel, doubleDropsMaxLevel); + if (Permissions.doubleDrops(player, SkillType.HERBALISM) && SkillTools.activationSuccessful(player, SkillType.HERBALISM, doubleDropsMaxChance, doubleDropsMaxLevel)) { + Location location = blockState.getLocation(); - if (chance > Misc.getRandom().nextInt(activationChance)) { - Location location = block.getLocation(); + if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) { + Misc.dropItems(location, dropItem, dropAmount); + } + else if (customBlock != null){ + int minimumDropAmount = customBlock.getMinimumDropAmount(); + int maximumDropAmount = customBlock.getMaximumDropAmount(); - if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) { - Misc.dropItems(location, dropItem, dropAmount); + if (minimumDropAmount != maximumDropAmount) { + Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); } - else if (customBlock != null){ - int minimumDropAmount = customBlock.getMinimumDropAmount(); - int maximumDropAmount = customBlock.getMaximumDropAmount(); - if (minimumDropAmount != maximumDropAmount) { - Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); - } - - Misc.dropItems(location, dropItem, minimumDropAmount); - } + Misc.dropItems(location, dropItem, minimumDropAmount); } } - mcMMOPlayer.beginXpGain(SkillType.HERBALISM, xp); + Users.getPlayer(player).beginXpGain(SkillType.HERBALISM, xp); + return update; } /** - * Apply the Green Thumb ability to crops. + * Convert plants affected by the Green Terra ability. * - * @param block The block to apply the ability to - * @param player The player using the ability - * @param event The event triggering the ability - * @param plugin mcMMO plugin instance + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise */ - private static void greenThumbWheat(Block block, Player player, mcMMO plugin) { - PlayerProfile profile = Users.getPlayer(player).getProfile(); - int herbLevel = profile.getSkillLevel(SkillType.HERBALISM); - PlayerInventory inventory = player.getInventory(); - boolean hasSeeds = false; - Material type = block.getType(); - - switch(type) { + private static boolean convertGreenTerraPlants(BlockState blockState) { + switch (blockState.getType()) { case CROPS: - hasSeeds = inventory.contains(Material.SEEDS); - break; - case COCOA: - hasSeeds = inventory.containsAtLeast(new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData()), 1); - break; case CARROT: - hasSeeds = inventory.contains(Material.CARROT_ITEM); - break; case POTATO: - hasSeeds = inventory.contains(Material.POTATO_ITEM); - break; + blockState.setRawData(CropState.MEDIUM.getData()); + return true; + case NETHER_WARTS: - hasSeeds = inventory.contains(Material.NETHER_STALK); - break; + blockState.setRawData((byte) 0x2); + return true; + + case COCOA: + CocoaPlant plant = (CocoaPlant) blockState.getData(); + plant.setSize(CocoaPlantSize.MEDIUM); + blockState.setData(plant); + return true; + default: - break; - } - - if (!hasSeeds) { - return; - } - - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.HERBALISM); - float chance = (float) (greenThumbMaxChance / greenThumbMaxLevel * herbLevel); - - if (chance > greenThumbMaxChance) { - chance = (float) greenThumbMaxChance; - } - - if (profile.getAbilityMode(AbilityType.GREEN_TERRA) || chance > Misc.getRandom().nextInt(activationChance)) { - switch(type) { - case CROPS: - inventory.removeItem(new ItemStack(Material.SEEDS)); - break; - case COCOA: - inventory.removeItem(new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())); - break; - case CARROT: - inventory.removeItem(new ItemStack(Material.CARROT_ITEM)); - break; - case POTATO: - inventory.removeItem(new ItemStack(Material.POTATO_ITEM)); - break; - case NETHER_WARTS: - inventory.removeItem(new ItemStack(Material.NETHER_STALK)); - break; - default: - break; - } - - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GreenThumbTimer(block, profile, type), 0); - player.updateInventory(); // Needed until replacement available + return false; } } /** - * Apply the Green Thumb ability to blocks. + * Process the Green Thumb ability for blocks. * - * @param is The item in the player's hand - * @param player The player activating the ability - * @param block The block being used in the ability + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + * @return true if the ability was successful, false otherwise */ - public static void greenThumbBlocks(ItemStack is, Player player, Block block) { - PlayerProfile profile = Users.getPlayer(player).getProfile(); - int skillLevel = profile.getSkillLevel(SkillType.HERBALISM); - int seeds = is.getAmount(); - - player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1)); - - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.HERBALISM); - - float chance = (float) ((greenThumbMaxChance / greenThumbMaxLevel) * skillLevel); - if (chance > greenThumbMaxChance) chance = (float) greenThumbMaxChance; - - if (chance > Misc.getRandom().nextInt(activationChance)) { - greenTerraConvert(player, block); - } - else { + public static boolean processGreenThumbBlocks(BlockState blockState, Player player) { + if (!SkillTools.activationSuccessful(player, SkillType.HERBALISM, greenThumbMaxChance, greenThumbMaxLevel)) { player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail")); + return false; + } + + return convertGreenTerraBlocks(blockState, player); + } + + /** + * Convert plants affected by the Green Thumb ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param skillLevel The player's Herbalism skill level + * @return true if the ability was successful, false otherwise + */ + private static boolean convertGreenThumbPlants(BlockState blockState, int skillLevel) { + int greenThumbStage = Math.min(skillLevel, greenThumbStageMaxLevel) / 4; + + switch(blockState.getType()) { + case CROPS: + case CARROT: + case POTATO: + blockState.setRawData((byte) greenThumbStage); + return true; + + case NETHER_WARTS: + if (greenThumbStage > 2) { + blockState.setRawData((byte) 0x2); + } + else if (greenThumbStage == 2) { + blockState.setRawData((byte) 0x1); + } + else { + blockState.setRawData((byte) 0x0); + } + return true; + + case COCOA: + CocoaPlant plant = (CocoaPlant) blockState.getData(); + + if (greenThumbStage > 1) { + plant.setSize(CocoaPlantSize.MEDIUM); + } + else { + plant.setSize(CocoaPlantSize.SMALL); + } + blockState.setData(plant); + return true; + + default: + return false; } } - public static void hylianLuck(Block block, Player player, BlockBreakEvent event) { - int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.HERBALISM); + /** + * Process the Green Thumb ability for plants. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + * @return true if the ability was successful, false otherwise + */ + private static boolean processGreenThumbPlants(BlockState blockState, Player player) { + PlayerInventory playerInventory = player.getInventory(); + ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); - double chance = (hylianLuckMaxChance / hylianLuckMaxLevel) * SkillTools.skillCheck(skillLevel, hylianLuckMaxLevel); - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.HERBALISM); - - if (chance > Misc.getRandom().nextInt(activationChance)) { - List treasures = new ArrayList(); - - switch (block.getType()) { - case DEAD_BUSH: - case LONG_GRASS: - case SAPLING: - treasures = TreasuresConfig.getInstance().hylianFromBushes; - break; - - case RED_ROSE: - case YELLOW_FLOWER: - if (mcMMO.placeStore.isTrue(block)) { - mcMMO.placeStore.setFalse(block); - return; - } - - treasures = TreasuresConfig.getInstance().hylianFromFlowers; - break; - - case FLOWER_POT: - treasures = TreasuresConfig.getInstance().hylianFromPots; - break; - - default: - return; - } - - if (treasures.isEmpty()) { - return; - } - - event.setCancelled(true); - event.getBlock().setType(Material.AIR); - Misc.dropItem(block.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop()); - player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); + if (!playerInventory.containsAtLeast(seed, 1)) { + return false; } + + PlayerProfile playerProfile = Users.getPlayer(player).getProfile(); + + if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) { + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + + return convertGreenTerraPlants(blockState); + } + else if (SkillTools.activationSuccessful(player, SkillType.HERBALISM, greenThumbMaxChance, greenThumbMaxLevel)) { + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + + return convertGreenThumbPlants(blockState, playerProfile.getSkillLevel(SkillType.HERBALISM)); + } + + return false; + } + + /** + * Process the Hylian Luck ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + * @return true if the ability was successful, false otherwise + */ + public static boolean processHylianLuck(BlockState blockState, Player player) { + if (!SkillTools.activationSuccessful(player, SkillType.HERBALISM, hylianLuckMaxChance, hylianLuckMaxLevel)) { + return false; + } + + List treasures = new ArrayList(); + + switch (blockState.getType()) { + case DEAD_BUSH: + case LONG_GRASS: + case SAPLING: + treasures = TreasuresConfig.getInstance().hylianFromBushes; + break; + + case RED_ROSE: + case YELLOW_FLOWER: + if (mcMMO.placeStore.isTrue(blockState)) { + mcMMO.placeStore.setFalse(blockState); + return false; + } + + treasures = TreasuresConfig.getInstance().hylianFromFlowers; + break; + + case FLOWER_POT: + treasures = TreasuresConfig.getInstance().hylianFromPots; + break; + + default: + return false; + } + + if (treasures.isEmpty()) { + return false; + } + + blockState.setRawData((byte) 0x0); + blockState.setType(Material.AIR); + + Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop()); + player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMiningDropEventHandler.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMiningDropEventHandler.java index dd5f9055d..77c9ade0b 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMiningDropEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMiningDropEventHandler.java @@ -6,11 +6,11 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.util.BlockChecks; import com.gmail.nossr50.util.Misc; @@ -20,9 +20,9 @@ public class BlastMiningDropEventHandler { private EntityExplodeEvent event; private float yield; private List blocks; - private List ores = new ArrayList(); - private List debris = new ArrayList(); - private List droppedOres = new ArrayList(); + private List ores = new ArrayList(); + private List debris = new ArrayList(); + private List droppedOres = new ArrayList(); private float oreBonus; private float debrisReduction; private int dropMultiplier; @@ -38,38 +38,35 @@ public class BlastMiningDropEventHandler { protected void sortExplosionBlocks() { for (Block block : blocks) { - if (BlockChecks.isOre(block)) { - ores.add(block); + BlockState blockState = block.getState(); + + if (BlockChecks.isOre(blockState)) { + ores.add(blockState); } else { - debris.add(block); + debris.add(blockState); } } } protected void processXPGain() { - McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer(); - - for (Block block : droppedOres) { - if (!mcMMO.placeStore.isTrue(block)) { - Mining.miningXP(mcMMOPlayer, block, block.getType()); + for (BlockState blockState : droppedOres) { + if (!mcMMO.placeStore.isTrue(blockState)) { + Mining.awardMiningXp(blockState, manager.getMcMMOPlayer().getPlayer()); } } } protected void processDroppedBlocks() { - for (Block block : ores) { - Location location = block.getLocation(); - Material type = block.getType(); - + for (BlockState blockState : ores) { if (Misc.getRandom().nextFloat() < (yield + oreBonus)) { - droppedOres.add(block); - Mining.miningDrops(block, location, type); + droppedOres.add(blockState); + Mining.handleMiningDrops(blockState); - if (!mcMMO.placeStore.isTrue(block)) { + if (!mcMMO.placeStore.isTrue(blockState)) { for (int i = 1 ; i < dropMultiplier ; i++) { - droppedOres.add(block); - Mining.miningDrops(block, location, type); + droppedOres.add(blockState); + Mining.handleMiningDrops(blockState); } } } @@ -78,9 +75,9 @@ public class BlastMiningDropEventHandler { float debrisYield = yield - debrisReduction; if (debrisYield > 0) { - for (Block block : debris) { - Location location = block.getLocation(); - Material type = block.getType(); + for (BlockState blockState : debris) { + Location location = blockState.getLocation(); + Material type = blockState.getType(); if (Misc.getRandom().nextFloat() < debrisYield) { Misc.dropItem(location, new ItemStack(type)); diff --git a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java index 5402134af..9655af76e 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -1,19 +1,21 @@ package com.gmail.nossr50.skills.mining; -import org.bukkit.CoalType; -import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.mods.datatypes.CustomBlock; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; public class Mining { private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -21,44 +23,58 @@ public class Mining { public static int doubleDropsMaxLevel = advancedConfig.getMiningDoubleDropMaxLevel(); public static double doubleDropsMaxChance = advancedConfig.getMiningDoubleDropChance(); - public static final int DIAMOND_TOOL_TIER = 4; - public static final int IRON_TOOL_TIER = 3; - public static final int STONE_TOOL_TIER = 2; + /** + * Process double drops & XP gain for Mining. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + */ + public static void miningBlockCheck(BlockState blockState, Player player) { + awardMiningXp(blockState, player); + + if (Permissions.doubleDrops(player, SkillType.MINING) && SkillTools.activationSuccessful(player, SkillType.MINING, doubleDropsMaxChance, doubleDropsMaxLevel)) { + if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { + handleSilkTouchDrops(blockState); + } + else { + handleMiningDrops(blockState); + } + } + } /** - * Award XP for Mining blocks. + * Award XP gain for Mining. * - * @param mcMMOPlayer The player to award XP to - * @param block The block to award XP for + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability */ - protected static void miningXP(McMMOPlayer mcMMOPlayer, Block block, Material type) { - int xp = Config.getInstance().getXp(SkillType.MINING, type); + protected static void awardMiningXp(BlockState blockState, Player player) { + Material blockType = blockState.getType(); + int xp = Config.getInstance().getXp(SkillType.MINING, blockType); - if (type == Material.GLOWING_REDSTONE_ORE) { + if (blockType == Material.GLOWING_REDSTONE_ORE) { xp = Config.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE); } - else if (xp == 0 && ModChecks.isCustomMiningBlock(block)) { - xp = ModChecks.getCustomBlock(block).getXpGain(); + else if (xp == 0 && ModChecks.isCustomMiningBlock(blockState)) { + xp = ModChecks.getCustomBlock(blockState).getXpGain(); } - mcMMOPlayer.beginXpGain(SkillType.MINING, xp); + Users.getPlayer(player).beginXpGain(SkillType.MINING, xp); } /** * Handle double drops when using Silk Touch. * - * @param block The block to process drops for - * @param location The location of the block - * @param type The material type of the block + * @param blockState The {@link BlockState} to check ability activation for */ - protected static void silkTouchDrops(Block block, Location location, Material type) { - ItemStack item = new ItemStack(type); + protected static void handleSilkTouchDrops(BlockState blockState) { + Material blockType = blockState.getType(); - if (type != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, type)) { + if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) { return; } - switch (type) { + switch (blockType) { case ENDER_STONE: case GOLD_ORE: case IRON_ORE: @@ -66,14 +82,14 @@ public class Mining { case NETHERRACK: case OBSIDIAN: case SANDSTONE: - miningDrops(block, location, type); - break; + handleMiningDrops(blockState); + return; case GLOWING_REDSTONE_ORE: if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) { - Misc.dropItem(location, item); + Misc.dropItem(blockState.getLocation(), new ItemStack(Material.REDSTONE_ORE)); } - break; + return; case COAL_ORE: case DIAMOND_ORE: @@ -82,75 +98,39 @@ public class Mining { case LAPIS_ORE: case STONE: case EMERALD_ORE: - Misc.dropItem(location, item); - break; + Misc.dropItem(blockState.getLocation(), new ItemStack(blockType)); + return; default: - if (ModChecks.isCustomMiningBlock(block)) { - ItemStack dropItem = new ItemStack(block.getTypeId(), 1, block.getData()); - - Misc.dropItem(location, dropItem); + if (ModChecks.isCustomMiningBlock(blockState)) { + Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); } - break; + return; } } /** - * Drop items from Mining & Blast Mining skills. + * Handle double drops from Mining & Blast Mining. * - * @param block The block to process drops for - * @param location The location of the block - * @param type The material type of the block + * @param blockState The {@link BlockState} to check ability activation for */ - protected static void miningDrops(Block block, Location location, Material type) { - if (type != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, type)) { + protected static void handleMiningDrops(BlockState blockState) { + Material blockType = blockState.getType(); + + if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) { return; } - ItemStack item = new ItemStack(type); + Location location = blockState.getLocation(); + ItemStack dropItem; - switch (type) { + switch (blockType) { case COAL_ORE: - item = new ItemStack(Material.COAL, 1, CoalType.COAL.getData()); - Misc.dropItem(location, item); - break; - case DIAMOND_ORE: - item = new ItemStack(Material.DIAMOND); - Misc.dropItem(location, item); - break; - case EMERALD_ORE: - item = new ItemStack(Material.EMERALD); - Misc.dropItem(location, item); - break; - - case GLOWING_REDSTONE_ORE: - case REDSTONE_ORE: - if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) { - item = new ItemStack(Material.REDSTONE); - Misc.dropItems(location, item, 4); - Misc.randomDropItem(location, item, 50); - } - break; - case GLOWSTONE: - item = new ItemStack(Material.GLOWSTONE_DUST); - Misc.dropItems(location, item, 2); - Misc.randomDropItems(location, item, 2); - break; - case LAPIS_ORE: - item = new ItemStack(Material.INK_SACK, 1, DyeColor.BLUE.getDyeData()); - Misc.dropItems(location, item, 4); - Misc.randomDropItems(location, item, 4); - break; - case STONE: - item = new ItemStack(Material.COBBLESTONE); - Misc.dropItem(location, item); - break; - case ENDER_STONE: case GOLD_ORE: case IRON_ORE: @@ -158,26 +138,36 @@ public class Mining { case NETHERRACK: case OBSIDIAN: case SANDSTONE: - Misc.dropItem(location, item); - break; + for (ItemStack drop : blockState.getBlock().getDrops()) { + Misc.dropItem(location, drop); + } + return; + case GLOWING_REDSTONE_ORE: + case REDSTONE_ORE: + if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) { + for (ItemStack drop : blockState.getBlock().getDrops()) { + Misc.dropItem(location, drop); + } + } + return; default: - if (ModChecks.isCustomMiningBlock(block)) { - CustomBlock customBlock = ModChecks.getCustomBlock(block); + if (ModChecks.isCustomMiningBlock(blockState)) { + CustomBlock customBlock = ModChecks.getCustomBlock(blockState); int minimumDropAmount = customBlock.getMinimumDropAmount(); int maximumDropAmount = customBlock.getMaximumDropAmount(); - item = ModChecks.getCustomBlock(block).getItemDrop(); + dropItem = customBlock.getItemDrop(); if (minimumDropAmount != maximumDropAmount) { - Misc.dropItems(location, item, minimumDropAmount); - Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount); + Misc.dropItems(location, dropItem, minimumDropAmount); + Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); } else { - Misc.dropItems(location, item, minimumDropAmount); + Misc.dropItems(location, dropItem, minimumDropAmount); } } - break; + return; } } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningBlockEventHandler.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningBlockEventHandler.java deleted file mode 100644 index 2926ef90a..000000000 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningBlockEventHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.gmail.nossr50.skills.mining; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.enchantments.Enchantment; - -import com.gmail.nossr50.skills.utilities.SkillTools; - -public class MiningBlockEventHandler { - private MiningManager manager; - private Block block; - private Location blockLocation; - private Material blockType; - protected int skillModifier; - - protected MiningBlockEventHandler(MiningManager manager, Block block) { - this.manager = manager; - this.block = block; - this.blockLocation = block.getLocation(); - this.blockType = block.getType(); - - calculateSkillModifier(); - } - - private void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Mining.doubleDropsMaxLevel); - } - - /** - * Process Mining block drops. - */ - protected void processDrops() { - if (manager.getMcMMOPlayer().getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { - Mining.silkTouchDrops(block, blockLocation, blockType); - } - else { - Mining.miningDrops(block, blockLocation, blockType); - } - } - - protected void processXPGain() { - Mining.miningXP(manager.getMcMMOPlayer(), block, blockType); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 176c527b4..dfe853bc6 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.mining; import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; @@ -12,7 +11,6 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; public class MiningManager extends SkillManager{ public MiningManager (McMMOPlayer mcMMOPlayer) { @@ -102,24 +100,4 @@ public class MiningManager extends SkillManager{ eventHandler.calculateRadiusIncrease(); eventHandler.modifyBlastRadius(); } - - /** - * Process Mining block drops. - * - * @param block The block being broken - */ - public void miningBlockCheck(Block block) { - MiningBlockEventHandler eventHandler = new MiningBlockEventHandler(this, block); - eventHandler.processXPGain(); - - if (!Permissions.doubleDrops(mcMMOPlayer.getPlayer(), skill)) { - return; - } - - float chance = ((float) Mining.doubleDropsMaxChance / Mining.doubleDropsMaxLevel) * eventHandler.skillModifier; - - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.processDrops(); - } - } } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/FluxMiningEventHandler.java b/src/main/java/com/gmail/nossr50/skills/smelting/FluxMiningEventHandler.java deleted file mode 100644 index 5e8884524..000000000 --- a/src/main/java/com/gmail/nossr50/skills/smelting/FluxMiningEventHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.gmail.nossr50.skills.smelting; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.mining.Mining; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; - -public class FluxMiningEventHandler { - private SmeltingManager manager; - private BlockBreakEvent event; - private Block block; - - protected FluxMiningEventHandler(SmeltingManager manager, BlockBreakEvent event) { - this.manager = manager; - this.event = event; - this.block = event.getBlock(); - } - - protected void processDrops() { - ItemStack item = null; - - switch (block.getType()) { - case IRON_ORE: - item = new ItemStack(Material.IRON_INGOT); - break; - - case GOLD_ORE: - item = new ItemStack(Material.GOLD_INGOT); - break; - - default: - break; - } - - if (item == null) { - return; - } - - Location location = block.getLocation(); - - Misc.dropItem(location, item); - - McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer(); - - if (Permissions.doubleDrops(mcMMOPlayer.getPlayer(), manager.getSkill())) { - int chance = (int) ((Mining.doubleDropsMaxChance / Mining.doubleDropsMaxLevel) * (SkillTools.skillCheck(mcMMOPlayer.getProfile().getSkillLevel(SkillType.MINING), Mining.doubleDropsMaxLevel))); - Misc.randomDropItem(location, item, chance); - } - } - - protected void eventCancellationAndProcessing() { - event.setCancelled(true); - block.setType(Material.AIR); - } - - protected void sendAbilityMessage() { - manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success")); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java index 16cc57c6c..113d6c98f 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java @@ -1,6 +1,18 @@ package com.gmail.nossr50.skills.smelting; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.mining.Mining; +import com.gmail.nossr50.skills.utilities.SkillTools; +import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; public class Smelting { public static int burnModifierMaxLevel = AdvancedConfig.getInstance().getBurnModifierMaxLevel(); @@ -23,4 +35,49 @@ public class Smelting { public static int vanillaXPBoostRank3Multiplier = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Multiplier(); public static int vanillaXPBoostRank4Multiplier = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Multiplier(); public static int vanillaXPBoostRank5Multiplier = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Multiplier(); + + /** + * Process the Flux Mining ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + * @return true if the ability was successful, false otherwise + */ + public static boolean processFluxMining(BlockState blockState, Player player) { + if (SkillTools.unlockLevelReached(player, SkillType.SMELTING, fluxMiningUnlockLevel) && SkillTools.activationSuccessful(player, SkillType.SMELTING, fluxMiningChance)) { + ItemStack item = null; + + switch (blockState.getType()) { + case IRON_ORE: + item = new ItemStack(Material.IRON_INGOT); + break; + + case GOLD_ORE: + item = new ItemStack(Material.GOLD_INGOT); + break; + + default: + break; + } + + if (item == null) { + return false; + } + + Location location = blockState.getLocation(); + + Misc.dropItem(location, item); + + if (Permissions.doubleDrops(player, SkillType.SMELTING) && SkillTools.activationSuccessful(player, SkillType.SMELTING, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { + Misc.dropItem(location, item); + } + + blockState.setRawData((byte) 0x0); + blockState.setType(Material.AIR); + player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success")); + return true; + } + + return false; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index 7c637e2dc..846cb764b 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.smelting; import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.event.inventory.FurnaceExtractEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; @@ -60,19 +59,6 @@ public class SmeltingManager extends SkillManager { } } - public void fluxMining(BlockBreakEvent event) { - if (skillLevel < Smelting.fluxMiningUnlockLevel) { - return; - } - - if (Smelting.fluxMiningChance > Misc.getRandom().nextInt(activationChance)) { - FluxMiningEventHandler eventHandler = new FluxMiningEventHandler(this, event); - eventHandler.processDrops(); - eventHandler.eventCancellationAndProcessing(); - eventHandler.sendAbilityMessage(); - } - } - public void vanillaXPBoost(FurnaceExtractEvent event) { if (skillLevel < Smelting.vanillaXPBoostRank1Level || !Permissions.vanillaXpBoost(mcMMOPlayer.getPlayer(), skill)) { return; diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java index 8ae527735..9c4611401 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java @@ -1,7 +1,7 @@ package com.gmail.nossr50.skills.unarmed; import org.bukkit.Material; -import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import com.gmail.nossr50.config.AdvancedConfig; @@ -25,20 +25,22 @@ public class Unarmed { public static double berserkDamageModifier = 1.5; - public static void blockCracker(Player player, Block block) { - if (SkillTools.blockBreakSimulate(block, player, false)) { - Material type = block.getType(); + public static boolean blockCracker(Player player, BlockState blockState) { + if (SkillTools.blockBreakSimulate(blockState.getBlock(), player, false)) { + Material type = blockState.getType(); switch (type) { case SMOOTH_BRICK: - if (blockCrackerSmoothBrick && block.getData() == 0x0) { - block.setData((byte) 0x2); + if (blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) { + blockState.setRawData((byte) 0x2); } - return; + return true; default: - return; + return false; } } + + return false; } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/AbilityType.java b/src/main/java/com/gmail/nossr50/skills/utilities/AbilityType.java index 9f8787469..25ae18b9e 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/AbilityType.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/AbilityType.java @@ -1,7 +1,7 @@ package com.gmail.nossr50.skills.utilities; import org.bukkit.Material; -import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import com.gmail.nossr50.config.Config; @@ -181,28 +181,28 @@ public enum AbilityType { /** * Check if a block is affected by this ability. * - * @param block the block to check + * @param blockState the block to check * @return true if the block is affected by this ability, false otherwise */ - public boolean blockCheck(Block block) { + public boolean blockCheck(BlockState blockState) { switch (this) { case BERSERK: - return (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW); + return (BlockChecks.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW); case GIGA_DRILL_BREAKER: - return BlockChecks.canBeGigaDrillBroken(block); + return BlockChecks.affectedByGigaDrillBreaker(blockState); case GREEN_TERRA: - return BlockChecks.canMakeMossy(block); + return BlockChecks.canMakeMossy(blockState); case LEAF_BLOWER: - return block.getType() == Material.LEAVES; + return BlockChecks.isLeaves(blockState); case SUPER_BREAKER: - return BlockChecks.canBeSuperBroken(block); + return BlockChecks.affectedBySuperBreaker(blockState); case TREE_FELLER: - return block.getType() == Material.LOG; + return BlockChecks.isLog(blockState); default: return false; diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java index 8912471c4..704acce16 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java @@ -426,10 +426,8 @@ public class SkillTools { switch (ability) { case BERSERK: - case GIGA_DRILL_BREAKER: - case SUPER_BREAKER: case LEAF_BLOWER: - if (!ability.blockCheck(block)) { + if (!ability.blockCheck(block.getState())) { activate = false; break; } @@ -440,8 +438,10 @@ public class SkillTools { } break; + case GIGA_DRILL_BREAKER: + case SUPER_BREAKER: case GREEN_TERRA: - if (!ability.blockCheck(block)) { + if (!ability.blockCheck(block.getState())) { activate = false; break; } @@ -480,7 +480,7 @@ public class SkillTools { } public static void handleAbilitySpeedIncrease(Player player) { - if (HiddenConfig.getInstance().useEnchantmentBuffs()) { + if (HiddenConfig.getInstance().useEnchantmentBuffs()) { ItemStack heldItem = player.getItemInHand(); if (heldItem == null || heldItem.getType() == Material.AIR ) { @@ -583,15 +583,13 @@ public class SkillTools { * @return true if the event wasn't cancelled, false otherwise */ public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) { + PluginManager pluginManger = mcMMO.p.getServer().getPluginManager(); //Support for NoCheat if (shouldArmSwing) { - FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); - mcMMO.p.getServer().getPluginManager().callEvent(armswing); + pluginManger.callEvent(new FakePlayerAnimationEvent(player)); } - PluginManager pluginManger = mcMMO.p.getServer().getPluginManager(); - FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true); pluginManger.callEvent(damageEvent); @@ -604,4 +602,20 @@ public class SkillTools { return false; } + + public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) { + int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill); + int activationChance = PerksUtils.handleLuckyPerks(player, skill); + double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel); + + return chance > Misc.getRandom().nextInt(activationChance); + } + + public static boolean activationSuccessful(Player player, SkillType skill, double chance) { + return chance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, skill)); + } + + public static boolean unlockLevelReached(Player player, SkillType skill, int unlockLevel) { + return Users.getPlayer(player).getProfile().getSkillLevel(skill) > unlockLevel; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java index 1d67500e9..6e9717914 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java @@ -6,13 +6,14 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; -import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Tree; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.mods.datatypes.CustomBlock; @@ -22,6 +23,7 @@ import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod; import com.gmail.nossr50.util.BlockChecks; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Users; public final class TreeFeller { private static boolean treeFellerReachedThreshold = false; @@ -32,26 +34,24 @@ public final class TreeFeller { * Begins Tree Feller * * @param mcMMOPlayer Player using Tree Feller - * @param block Block being broken + * @param blockState Block being broken */ - public static void process(McMMOPlayer mcMMOPlayer, Block block) { - List treeFellerBlocks = new ArrayList(); + protected static void process(BlockState blockState, Player player) { + List treeFellerBlocks = new ArrayList(); - processRecursively(block, treeFellerBlocks); + processRecursively(blockState, treeFellerBlocks); - // If the player is trying to break to many block + // If the player is trying to break too many blocks if (treeFellerReachedThreshold) { treeFellerReachedThreshold = false; - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold")); + player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold")); return; } - Player player = mcMMOPlayer.getPlayer(); - // If the tool can't sustain the durability loss if (!handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) { - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter")); + player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter")); int health = player.getHealth(); @@ -62,28 +62,28 @@ public final class TreeFeller { return; } - dropBlocks(treeFellerBlocks, mcMMOPlayer); + dropBlocks(treeFellerBlocks, player); } /** * Processes Tree Feller * - * @param block Block being checked + * @param blockState Block being checked * @param treeFellerBlocks List of blocks to be removed */ - private static void processRecursively(Block block, List treeFellerBlocks) { - if (!BlockChecks.isLog(block)) { + private static void processRecursively(BlockState blockState, List treeFellerBlocks) { + if (!BlockChecks.isLog(blockState)) { return; } - List futureCenterBlocks = new ArrayList(); - World world = block.getWorld(); + List futureCenterBlocks = new ArrayList(); + World world = blockState.getWorld(); // Handle the blocks around 'block' - for (int y = 0 ; y <= 1 ; y++) { - for (int x = -1 ; x <= 1 ; x++) { - for (int z = -1 ; z <= 1 ; z++) { - Block nextBlock = world.getBlockAt(block.getLocation().add(x, y, z)); + for (int y = 0; y <= 1; y++) { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState(); handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks); @@ -95,12 +95,12 @@ public final class TreeFeller { } // Recursive call for each log found - for (Block futurCenterBlock : futureCenterBlocks) { + for (BlockState futureCenterBlock : futureCenterBlocks) { if (treeFellerReachedThreshold) { return; } - processRecursively(futurCenterBlock, treeFellerBlocks); + processRecursively(futureCenterBlock, treeFellerBlocks); } } @@ -108,23 +108,23 @@ public final class TreeFeller { * Handle a block addition to the list of blocks to be removed * and to the list of blocks used for future recursive calls of 'processRecursively()' * - * @param block Block to be added + * @param blockState Block to be added * @param futureCenterBlocks List of blocks that will be used to call 'processRecursively()' * @param treeFellerBlocks List of blocks to be removed */ - private static void handleBlock(Block block, List futureCenterBlocks, List treeFellerBlocks) { - if (!BlockChecks.treeFellerCompatible(block) || mcMMO.placeStore.isTrue(block) || treeFellerBlocks.contains(block)) { + private static void handleBlock(BlockState blockState, List futureCenterBlocks, List treeFellerBlocks) { + if (!BlockChecks.affectedByTreeFeller(blockState) || mcMMO.placeStore.isTrue(blockState) || treeFellerBlocks.contains(blockState)) { return; } - treeFellerBlocks.add(block); + treeFellerBlocks.add(blockState); - if (treeFellerBlocks.size() > Woodcutting.CONFIG.getTreeFellerThreshold()) { + if (treeFellerBlocks.size() > Config.getInstance().getTreeFellerThreshold()) { treeFellerReachedThreshold = true; return; } - futureCenterBlocks.add(block); + futureCenterBlocks.add(blockState); } /** @@ -134,15 +134,15 @@ public final class TreeFeller { * @param inHand tool being used * @return True if the tool can sustain the durability loss */ - private static boolean handleDurabilityLoss(List treeFellerBlocks, ItemStack inHand) { + private static boolean handleDurabilityLoss(List treeFellerBlocks, ItemStack inHand) { Material inHandMaterial = inHand.getType(); if (inHandMaterial != Material.AIR) { short durabilityLoss = 0; int unbreakingLevel = inHand.getEnchantmentLevel(Enchantment.DURABILITY); - for (Block block : treeFellerBlocks) { - if (BlockChecks.isLog(block) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) { + for (BlockState blockState : treeFellerBlocks) { + if (BlockChecks.isLog(blockState) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) { durabilityLoss += SkillTools.toolDurabilityLoss; } } @@ -165,87 +165,74 @@ public final class TreeFeller { * Handles the dropping of blocks * * @param treeFellerBlocks List of blocks to be dropped - * @param mcMMOPlayer Player using the ability + * @param player Player using the ability */ - private static void dropBlocks(List treeFellerBlocks, McMMOPlayer mcMMOPlayer) { + private static void dropBlocks(List treeFellerBlocks, Player player) { int xp = 0; - for (Block block : treeFellerBlocks) { - if (!SkillTools.blockBreakSimulate(block, mcMMOPlayer.getPlayer(), true)) { + for (BlockState blockState : treeFellerBlocks) { + if (!SkillTools.blockBreakSimulate(blockState.getBlock(), player, true)) { break; // TODO: Shouldn't we use continue instead? } - Material material = block.getType(); + Material material = blockState.getType(); switch (material) { case HUGE_MUSHROOM_1: case HUGE_MUSHROOM_2: - try { - xp += Woodcutting.getExperienceFromLog(block, ExperienceGainMethod.TREE_FELLER); - } - catch (IllegalArgumentException exception) { - break; - } + xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); - // Stems have a block data value of 15 and should not drop mushrooms - // 0-2 mushrooms drop when you break a block - if (block.getData() == (byte) 15) { - break; - } - - if (material == Material.HUGE_MUSHROOM_1) { - Misc.randomDropItems(block.getLocation(), new ItemStack(Material.BROWN_MUSHROOM), 2); - } - else { - Misc.randomDropItems(block.getLocation(), new ItemStack(Material.RED_MUSHROOM), 2); + for (ItemStack drop : blockState.getBlock().getDrops()) { + Misc.dropItem(blockState.getLocation(), drop); } break; - case LOG: - Woodcutting.checkForDoubleDrop(mcMMOPlayer, block); - try { - xp += Woodcutting.getExperienceFromLog(block, ExperienceGainMethod.TREE_FELLER); - } - catch (IllegalArgumentException exception) { - break; - } - - Misc.dropItem(block.getLocation(), new ItemStack(Material.LOG, 1, Woodcutting.extractLogItemData(block.getData()))); - break; - case LEAVES: - Misc.randomDropItem(block.getLocation(), new ItemStack(Material.SAPLING, 1, Woodcutting.extractLogItemData(block.getData())), 10); - break; default: - if (ModChecks.isCustomLogBlock(block)) { - Woodcutting.checkForDoubleDrop(mcMMOPlayer, block); - - CustomBlock customBlock = ModChecks.getCustomBlock(block); - xp = customBlock.getXpGain(); - int minimumDropAmount = customBlock.getMinimumDropAmount(); - int maximumDropAmount = customBlock.getMaximumDropAmount(); - Location location = block.getLocation(); - ItemStack item = customBlock.getItemDrop();; - - Misc.dropItems(location, item, minimumDropAmount); - - if (minimumDropAmount < maximumDropAmount) { - Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount); - } - } - else if (ModChecks.isCustomLeafBlock(block)) { - CustomBlock customBlock = ModChecks.getCustomBlock(block); - - Misc.randomDropItem(block.getLocation(), customBlock.getItemDrop(), 10); - } - break; } - block.setData((byte) 0); - block.setType(Material.AIR); + if (ModChecks.isCustomLogBlock(blockState)) { + Woodcutting.checkForDoubleDrop(player, blockState); + + CustomBlock customBlock = ModChecks.getCustomBlock(blockState); + xp = customBlock.getXpGain(); + int minimumDropAmount = customBlock.getMinimumDropAmount(); + int maximumDropAmount = customBlock.getMaximumDropAmount(); + Location location = blockState.getLocation(); + ItemStack item = customBlock.getItemDrop();; + + Misc.dropItems(location, item, minimumDropAmount); + + if (minimumDropAmount < maximumDropAmount) { + Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount); + } + } + else if (ModChecks.isCustomLeafBlock(blockState)) { + Misc.randomDropItem(blockState.getLocation(), ModChecks.getCustomBlock(blockState).getItemDrop(), 10); + } + + Tree tree = (Tree) blockState.getData(); + switch (material) { + case LOG: + Woodcutting.checkForDoubleDrop(player, blockState); + xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); + Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData())); + break; + + case LEAVES: + Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10); + break; + + default: + break; + } + + blockState.setRawData((byte) 0x0); + blockState.setType(Material.AIR); + blockState.update(); } - mcMMOPlayer.beginXpGain(SkillType.WOODCUTTING, xp); + Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp); } } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index e5dabab5c..5c1f0e788 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -1,29 +1,27 @@ package com.gmail.nossr50.skills.woodcutting; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.TreeSpecies; -import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Tree; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.mods.datatypes.CustomBlock; -import com.gmail.nossr50.skills.utilities.PerksUtils; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public final class Woodcutting { - static final AdvancedConfig ADVANCED_CONFIG = AdvancedConfig.getInstance(); - static final Config CONFIG = Config.getInstance(); + public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getWoodcuttingDoubleDropChance(); + public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel(); protected enum ExperienceGainMethod { DEFAULT, @@ -38,8 +36,8 @@ public final class Woodcutting { * @param mcMMOPlayer Player using the ability * @param block Block being broken */ - public static void beginTreeFeller(McMMOPlayer mcMMOPlayer, Block block) { - TreeFeller.process(mcMMOPlayer, block); + public static void beginTreeFeller(BlockState blockState, Player player) { + TreeFeller.process(blockState, player); } /** @@ -48,10 +46,9 @@ public final class Woodcutting { * @param player Player using the ability * @param block Block being broken */ - public static void beginLeafBlower(Player player, Block block) { + public static void beginLeafBlower(Player player, BlockState blockState) { mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player)); - - player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); + player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); } /** @@ -60,75 +57,61 @@ public final class Woodcutting { * @param mcMMOPlayer Player breaking the block * @param block Block being broken */ - public static void beginWoodcutting(McMMOPlayer mcMMOPlayer, Block block) { - int xp = 0; - - if (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)) { - xp = ModChecks.getCustomBlock(block).getXpGain(); - } - else { - try { - xp = getExperienceFromLog(block, ExperienceGainMethod.DEFAULT); - } - catch (IllegalArgumentException exception) { - return; - } - } - - Player player = mcMMOPlayer.getPlayer(); + public static void beginWoodcutting(Player player, BlockState blockState) { + int xp = getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); if (Permissions.doubleDrops(player, SkillType.WOODCUTTING)) { - checkForDoubleDrop(mcMMOPlayer, block); + checkForDoubleDrop(player, blockState); } - mcMMOPlayer.beginXpGain(SkillType.WOODCUTTING, xp); + Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp); } /** * Retrieves the experience reward from a log * - * @param log Log being broken + * @param blockState Log being broken * @param experienceGainMethod How the log is being broken * @return Amount of experience - * @throws IllegalArgumentException if 'log' is invalid */ - protected static int getExperienceFromLog(Block log, ExperienceGainMethod experienceGainMethod) { + protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) { // Mushrooms aren't trees so we could never get species data from them - switch (log.getType()) { + switch (blockState.getType()) { case HUGE_MUSHROOM_1: return Config.getInstance().getWoodcuttingXPHugeBrownMushroom(); + case HUGE_MUSHROOM_2: return Config.getInstance().getWoodcuttingXPHugeRedMushroom(); + default: break; } - TreeSpecies logType = TreeSpecies.getByData(extractLogItemData(log.getData())); - - // Apparently species can be null in certain cases (custom server mods?) - // https://github.com/mcMMO-Dev/mcMMO/issues/229 - if (logType == null) { - throw new IllegalArgumentException(); + if (ModChecks.isCustomLogBlock(blockState)) { + return ModChecks.getCustomBlock(blockState).getXpGain(); } - switch (logType) { + switch (((Tree) blockState.getData()).getSpecies()) { case GENERIC: return Config.getInstance().getWoodcuttingXPOak(); + case REDWOOD: return Config.getInstance().getWoodcuttingXPSpruce(); + case BIRCH: return Config.getInstance().getWoodcuttingXPBirch(); + case JUNGLE: int xp = Config.getInstance().getWoodcuttingXPJungle(); - switch (experienceGainMethod) { - case TREE_FELLER: - return (int) (xp * 0.5); - default: - return xp; + if (experienceGainMethod == ExperienceGainMethod.TREE_FELLER) { + xp *= 0.5; } + + return xp; + default: - throw new IllegalArgumentException(); + return 0; } } @@ -136,28 +119,18 @@ public final class Woodcutting { * Checks for double drops * * @param mcMMOPlayer Player breaking the block - * @param block Block being broken + * @param blockState Block being broken */ - protected static void checkForDoubleDrop(McMMOPlayer mcMMOPlayer, Block block) { - Player player = mcMMOPlayer.getPlayer(); - double configDoubleDropChance = ADVANCED_CONFIG.getWoodcuttingDoubleDropChance(); - int configDoubleDropMaxLevel = ADVANCED_CONFIG.getWoodcuttingDoubleDropMaxLevel(); - int probability = (int) ((configDoubleDropChance / configDoubleDropMaxLevel) * Users.getPlayer(player).getProfile().getSkillLevel(SkillType.WOODCUTTING)); - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.WOODCUTTING); - - if (probability > configDoubleDropChance) { - probability = (int) configDoubleDropChance; - } - - if (probability <= Misc.getRandom().nextInt(activationChance)) { + protected static void checkForDoubleDrop(Player player, BlockState blockState) { + if (!SkillTools.activationSuccessful(player, SkillType.WOODCUTTING, doubleDropsMaxChance, doubleDropsMaxLevel)) { return; } - if (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)) { - CustomBlock customBlock = ModChecks.getCustomBlock(block); + if (ModChecks.isCustomLogBlock(blockState)) { + CustomBlock customBlock = ModChecks.getCustomBlock(blockState); int minimumDropAmount = customBlock.getMinimumDropAmount(); int maximumDropAmount = customBlock.getMaximumDropAmount(); - Location location = block.getLocation(); + Location location = blockState.getLocation(); ItemStack item = customBlock.getItemDrop(); Misc.dropItems(location, item, minimumDropAmount); @@ -167,44 +140,37 @@ public final class Woodcutting { } } else { - byte itemData = extractLogItemData(block.getData()); - Location location = block.getLocation(); - ItemStack item = new ItemStack(Material.LOG, 1, itemData); + Location location = blockState.getLocation(); + ItemStack item = blockState.getData().toItemStack(); - switch (TreeSpecies.getByData(itemData)) { + switch (((Tree) blockState.getData()).getSpecies()) { case GENERIC: if (Config.getInstance().getOakDoubleDropsEnabled()) { Misc.dropItem(location, item); } - break; + return; + case REDWOOD: if (Config.getInstance().getSpruceDoubleDropsEnabled()) { Misc.dropItem(location, item); } - break; + return; + case BIRCH: if (Config.getInstance().getBirchDoubleDropsEnabled()) { Misc.dropItem(location, item); } - break; + return; + case JUNGLE: if (Config.getInstance().getJungleDoubleDropsEnabled()) { Misc.dropItem(location, item); } - break; + return; + default: - break; + return; } } } - - /** - * Extracts the log type from the block data (i.e. removes rotation) - * - * @param data Original block data - * @return Extracted log type - */ - protected static byte extractLogItemData(byte data) { - return (byte) (data & 0x3); - } } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java index 0b9afc664..0b98c0e28 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java @@ -29,8 +29,7 @@ public class WoodcuttingCommand extends SkillCommand { treeFellerLengthEndurance = treeFellerStrings[1]; //DOUBLE DROPS - AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); - String[] doubleDropStrings = calculateAbilityDisplayValues(advancedConfig.getWoodcuttingDoubleDropMaxLevel(), advancedConfig.getWoodcuttingDoubleDropChance()); + String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance); doubleDropChance = doubleDropStrings[0]; doubleDropChanceLucky = doubleDropStrings[1]; } diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index 2426191c8..29989cc2e 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -1,30 +1,24 @@ package com.gmail.nossr50.util; import org.bukkit.CropState; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.inventory.ItemStack; +import org.bukkit.block.BlockState; import org.bukkit.material.CocoaPlant; -import org.bukkit.material.MaterialData; import org.bukkit.material.CocoaPlant.CocoaPlantSize; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.mods.config.CustomBlocksConfig; public final class BlockChecks { - private static Config configInstance = Config.getInstance(); - private BlockChecks() {} /** - * Checks to see if a block type awards XP. + * Checks to see if a given block awards XP. * - * @param block Block to check - * @return true if the block type awards XP, false otherwise + * @param blockState The {@link BlockState} of the block to check + * @return true if the block awards XP, false otherwise */ - public static boolean shouldBeWatched(Block block) { - switch (block.getType()) { + public static boolean shouldBeWatched(BlockState blockState) { + switch (blockState.getType()) { case BROWN_MUSHROOM: case CACTUS: case CLAY: @@ -64,30 +58,18 @@ public final class BlockChecks { return true; default: - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); - - if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customItems.contains(item)) { - return true; - } - - return false; + return ModChecks.getCustomBlock(blockState) != null; } } /** - * Check if a block should allow for the activation of abilities. + * Check if a given block should allow for the activation of abilities * - * @param block Block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block should allow ability activation, false otherwise */ - public static boolean canActivateAbilities(Block block) { - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); - - if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) { - return false; - } - - switch (block.getType()) { + public static boolean canActivateAbilities(BlockState blockState) { + switch (blockState.getType()) { case BED_BLOCK: case BREWING_STAND: case BOOKSHELF: @@ -114,7 +96,13 @@ public final class BlockChecks { return false; default: - if (block.getTypeId() == Config.getInstance().getRepairAnvilId() || block.getTypeId() == Config.getInstance().getSalvageAnvilId()) { + int blockId = blockState.getTypeId(); + + if (blockId == Config.getInstance().getRepairAnvilId() || blockId == Config.getInstance().getSalvageAnvilId()) { + return false; + } + + if (ModChecks.isCustomAbilityBlock(blockState)) { return false; } @@ -123,13 +111,13 @@ public final class BlockChecks { } /** - * Check if a block type is an ore. + * Check if a given block is an ore * - * @param block Block to check - * @return true if the Block is an ore, false otherwise + * @param blockState The {@link BlockState} of the block to check + * @return true if the block is an ore, false otherwise */ - public static boolean isOre(Block block) { - switch (block.getType()) { + public static boolean isOre(BlockState blockState) { + switch (blockState.getType()) { case COAL_ORE: case DIAMOND_ORE: case GLOWING_REDSTONE_ORE: @@ -141,32 +129,25 @@ public final class BlockChecks { return true; default: - if (configInstance.getBlockModsEnabled() && ModChecks.isCustomOreBlock(block)) { - return true; - } - - return false; + return ModChecks.isCustomOreBlock(blockState); } } /** - * Check if a block can be made mossy. + * Determine if a given block can be made mossy * - * @param block The block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block can be made mossy, false otherwise */ - public static boolean canMakeMossy(Block block) { - switch (block.getType()) { + public static boolean canMakeMossy(BlockState blockState) { + switch (blockState.getType()) { case COBBLESTONE: case DIRT: return true; + case SMOOTH_BRICK: case COBBLE_WALL: - if (block.getData() == (byte)0x0) { - return true; - } - - return false; + return blockState.getRawData() == (byte) 0x0; default: return false; @@ -174,13 +155,13 @@ public final class BlockChecks { } /** - * Check if a block is affected by Herbalism abilities. + * Determine if a given block should be affected by Green Terra * - * @param block Block to check - * @return true if the block is affected, false otherwise + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Green Terra, false otherwise */ - public static boolean canBeGreenTerra(Block block) { - switch (block.getType()) { + public static boolean affectedByGreenTerra(BlockState blockState) { + switch (blockState.getType()) { case BROWN_MUSHROOM: case CACTUS: case MELON_BLOCK: @@ -196,44 +177,27 @@ public final class BlockChecks { case CARROT: case CROPS: case POTATO: - if (block.getData() == CropState.RIPE.getData()) { - return true; - } - return false; + return blockState.getRawData() == CropState.RIPE.getData(); case NETHER_WARTS: - if (block.getData() == (byte) 0x3) { - return true; - } - return false; + return blockState.getRawData() == (byte) 0x3; case COCOA: - CocoaPlant plant = (CocoaPlant) block.getState().getData(); - - if (plant.getSize() == CocoaPlantSize.LARGE) { - return true; - } - return false; + return ((CocoaPlant) blockState.getData()).getSize() == CocoaPlantSize.LARGE; default: - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); - - if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) { - return true; - } - - return false; + return ModChecks.isCustomHerbalismBlock(blockState); } } /** - * Check to see if a block is broken by Super Breaker. + * Determine if a given block should be affected by Super Breaker * - * @param block Block to check - * @return true if the block would be broken by Super Breaker, false otherwise + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Super Breaker, false otherwise */ - public static Boolean canBeSuperBroken(Block block) { - switch (block.getType()) { + public static Boolean affectedBySuperBreaker(BlockState blockState) { + switch (blockState.getType()) { case COAL_ORE: case DIAMOND_ORE: case ENDER_STONE: @@ -252,24 +216,18 @@ public final class BlockChecks { return true; default: - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); - - if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) { - return true; - } - - return false; + return ModChecks.isCustomMiningBlock(blockState); } } /** - * Check to see if a block can be broken by Giga Drill Breaker. + * Determine if a given block should be affected by Giga Drill Breaker * - * @param block Block to check - * @return true if the block can be broken by Giga Drill Breaker, false otherwise + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Giga Drill Breaker, false otherwise */ - public static boolean canBeGigaDrillBroken(Block block) { - switch (block.getType()) { + public static boolean affectedByGigaDrillBreaker(BlockState blockState) { + switch (blockState.getType()) { case CLAY: case DIRT: case GRASS: @@ -280,24 +238,18 @@ public final class BlockChecks { return true; default: - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); - - if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) { - return true; - } - - return false; + return ModChecks.isCustomExcavationBlock(blockState); } } /** - * Checks if the block is affected by Tree Feller. + * Determine if a given block should be affected by Tree Feller * - * @param block Block to check - * @return true if the block is affected by Tree Feller, false otherwise + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Tree Feller, false otherwise */ - public static boolean treeFellerCompatible(Block block) { - switch (block.getType()) { + public static boolean affectedByTreeFeller(BlockState blockState) { + switch (blockState.getType()) { case LOG: case LEAVES: case HUGE_MUSHROOM_1: @@ -305,38 +257,52 @@ public final class BlockChecks { return true; default: - ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); - - if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(item)) { - return true; - } - - return false; + return ModChecks.isCustomWoodcuttingBlock(blockState); } } - public static boolean isLog(Block block) { - switch (block.getType()) { + /** + * Check if a given block is a log + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block is a log, false otherwise + */ + public static boolean isLog(BlockState blockState) { + switch (blockState.getType()) { case LOG: case HUGE_MUSHROOM_1: case HUGE_MUSHROOM_2: return true; default: - return (configInstance.getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)); + return ModChecks.isCustomLogBlock(blockState); } } - public static boolean isLeaves(Block block) { - if (block.getType() == Material.LEAVES || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block))) { + /** + * Check if a given block is a leaf + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block is a leaf, false otherwise + */ + public static boolean isLeaves(BlockState blockState) { + switch (blockState.getType()) { + case LEAVES: return true; - } - return false; + default: + return ModChecks.isCustomLeafBlock(blockState); + } } - public static boolean canBeFluxMined(Block block) { - switch (block.getType()) { + /** + * Determine if a given block should be affected by Flux Mining + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Flux Mining, false otherwise + */ + public static boolean affectedByFluxMining(BlockState blockState) { + switch (blockState.getType()) { case IRON_ORE: case GOLD_ORE: return true; @@ -346,8 +312,14 @@ public final class BlockChecks { } } - public static boolean canActivateHerbalism(Block block) { - switch (block.getType()) { + /** + * Determine if a given block can activate Herbalism abilities + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block can be made mossy, false otherwise + */ + public static boolean canActivateHerbalism(BlockState blockState) { + switch (blockState.getType()) { case DIRT: case GRASS: case SOIL: @@ -358,13 +330,16 @@ public final class BlockChecks { } } - public static boolean canBeCracked(Block block) { - switch(block.getType()) { + /** + * Determine if a given block should be affected by Block Cracker + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Block Cracker, false otherwise + */ + public static boolean affectedByBlockCracker(BlockState blockState) { + switch (blockState.getType()) { case SMOOTH_BRICK: - if (block.getData() == 0x0) { - return true; - } - return false; + return blockState.getRawData() == (byte) 0x0; default: return false; diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java index da7c09840..1c304d493 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java @@ -4,6 +4,7 @@ import java.io.IOException; import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; public interface ChunkManager { @@ -60,6 +61,7 @@ public interface ChunkManager { public void saveChunk(int cx, int cz, World world); public boolean isChunkLoaded(int cx, int cz, World world); + /** * Informs the ChunkletManager a chunk is loaded * @@ -128,6 +130,14 @@ public interface ChunkManager { */ public boolean isTrue(Block block); + /** + * Check to see if a given BlockState location is set to true + * + * @param location BlockState location to check + * @return true if the given BlockState location is set to true, false if otherwise + */ + public boolean isTrue(BlockState blockState); + /** * Set a given location to true, should create stores as necessary if the location does not exist * @@ -145,6 +155,13 @@ public interface ChunkManager { */ public void setTrue(Block block); + /** + * Set a given BlockState location to true, should create stores as necessary if the location does not exist + * + * @param block BlockState location to set + */ + public void setTrue(BlockState blockState); + /** * Set a given location to false, should not create stores if one does not exist for the given location * @@ -162,6 +179,13 @@ public interface ChunkManager { */ public void setFalse(Block block); + /** + * Set a given BlockState location to false, should not create stores if one does not exist for the given location + * + * @param block BlockState location to set + */ + public void setFalse(BlockState blockState); + /** * Delete any ChunkletStores that are empty */ diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index beaceb675..940763694 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -14,6 +14,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; import org.getspout.spoutapi.chunkstore.mcMMOSimpleRegionFile; @@ -317,6 +318,15 @@ public class HashChunkManager implements ChunkManager { return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld()); } + @Override + public synchronized boolean isTrue(BlockState blockState) { + if (blockState == null) { + return false; + } + + return isTrue(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld()); + } + @Override public synchronized void setTrue(int x, int y, int z, World world) { if (world == null) @@ -352,6 +362,14 @@ public class HashChunkManager implements ChunkManager { setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld()); } + @Override + public void setTrue(BlockState blockState) { + if (blockState == null) + return; + + setTrue(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld()); + } + @Override public synchronized void setFalse(int x, int y, int z, World world) { if (world == null) @@ -380,12 +398,22 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized void setFalse(Block block) { - if (block == null) + if (block == null) { return; + } setFalse(block.getX(), block.getY(), block.getZ(), block.getWorld()); } + @Override + public synchronized void setFalse(BlockState blockState) { + if (blockState == null) { + return; + } + + setFalse(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld()); + } + @Override public synchronized void cleanUp() {} diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/NullChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/NullChunkManager.java index 96d91b943..0862f61e0 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/NullChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/NullChunkManager.java @@ -4,6 +4,7 @@ import java.io.IOException; import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; public class NullChunkManager implements ChunkManager { @@ -73,18 +74,29 @@ public class NullChunkManager implements ChunkManager { return false; } + @Override + public boolean isTrue(BlockState blockState) { + return false; + } + @Override public void setTrue(int x, int y, int z, World world) {} @Override public void setTrue(Block block) {} + @Override + public void setTrue(BlockState blockState) {} + @Override public void setFalse(int x, int y, int z, World world) {} @Override public void setFalse(Block block) {} + @Override + public void setFalse(BlockState blockState) {} + @Override public void cleanUp() {} } \ No newline at end of file From 3b07d4055a75dfb275faae08314efda6d3b02338 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Fri, 22 Feb 2013 11:59:56 -0500 Subject: [PATCH 007/137] Added config option to make .new config files instead over writing over old ones when updating --- Changelog.txt | 2 ++ src/main/java/com/gmail/nossr50/config/Config.java | 1 + src/main/java/com/gmail/nossr50/config/ConfigLoader.java | 8 +++++++- src/main/resources/config.yml | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 9e5884526..1ceacadca 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -36,6 +36,8 @@ Version 1.4.00-dev + Added config option to disable automatic zip backups. + Added particle effects for many abilities. + Added '/mcnotify' command to toggle ability notifications on/off + + Added ability for config files to automatically update with new keys, and prune out old ones + + Added config option to make .new config files instead over writing over old ones when updating = Fixed Green Thumb on wheat not working properly at rank 4 = Fixed Green Thumb and Green Terra consuming twice the amount of seed needed = Fixed Green Terra not also checking Green Thumb permissions diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index a0b3f9bae..3a03bbbe6 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -44,6 +44,7 @@ public class Config extends ConfigLoader { public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); } public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); } public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); } + public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); } public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); } public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); } diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index fa6dcacde..f5d18a530 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -121,7 +121,13 @@ public abstract class ConfigLoader { // Save it try { - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), fileName))); + String saveName = fileName; + // At this stage we cannot guarantee that Config has been loaded, so we do the check directly here + if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) { + saveName += ".new"; + } + + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName))); writer.write(output); writer.flush(); writer.close(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4047ad80c..0979873dd 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -24,6 +24,8 @@ General: Power_Level_Cap: 0 #Should mcMMO print out debug messages? Verbose_Logging: false + #Should mcMMO over-write configs to update, or make new ones ending in .new? + Config_Update_Overwrite: true Database_Purging: #Amount of time (in hours) to wait between database purging From 63974f3968d696fcda267d6fdeb715d8a1ab1acb Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 12:10:15 -0500 Subject: [PATCH 008/137] Passing the event is bad - pass just event.getDamage() instead. --- .../java/com/gmail/nossr50/listeners/EntityListener.java | 7 ++++--- .../com/gmail/nossr50/skills/utilities/CombatTools.java | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index c6c1dcb52..e31351960 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -131,7 +131,7 @@ public class EntityListener implements Listener { if (defender instanceof LivingEntity) { LivingEntity livingDefender = (LivingEntity) defender; - if (!CombatTools.isInvincible(livingDefender, event)) { + if (!CombatTools.isInvincible(livingDefender, event.getDamage())) { CombatTools.combatChecks(event, attacker, livingDefender); } } @@ -160,6 +160,7 @@ public class EntityListener implements Listener { if (livingEntity instanceof Player) { Player player = (Player) entity; + // TODO: Is it even possible for the player to be off-line here? if (!player.isOnline() || Misc.isNPCEntity(player)) { return; } @@ -173,7 +174,7 @@ public class EntityListener implements Listener { return; } - if (!CombatTools.isInvincible(player, event)) { + if (!CombatTools.isInvincible(player, event.getDamage())) { if (cause == DamageCause.FALL && player.getItemInHand().getType() != Material.ENDER_PEARL && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player)) { AcrobaticsManager acrobaticsManager = new AcrobaticsManager(mcMMOPlayer); acrobaticsManager.rollCheck(event); @@ -192,7 +193,7 @@ public class EntityListener implements Listener { Tameable pet = (Tameable) livingEntity; AnimalTamer owner = pet.getOwner(); - if ((!CombatTools.isInvincible(livingEntity, event)) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) { + if ((!CombatTools.isInvincible(livingEntity, event.getDamage())) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) { TamingManager tamingManager = new TamingManager(Users.getPlayer((Player) owner)); tamingManager.preventDamage(event); } diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index 211d6593c..140ee80fe 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -572,17 +572,17 @@ public final class CombatTools { /** * Checks to see if an entity is currently invincible. * - * @param le The LivingEntity to check - * @param event The event the entity is involved in + * @param entity The {@link LivingEntity} to check + * @param eventDamage The damage from the event the entity is involved in * @return true if the entity is invincible, false otherwise */ - public static boolean isInvincible(LivingEntity le, EntityDamageEvent event) { + public static boolean isInvincible(LivingEntity entity, int eventDamage) { /* * So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility. * So yeah, this is for that. */ - if (le.getNoDamageTicks() > le.getMaximumNoDamageTicks() / 2.0F && event.getDamage() <= le.getLastDamage()) { + if ((entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage())) { return true; } From e85a0f6cfcecf642dd1c5a259277a21a5bce70e2 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 13:39:47 -0500 Subject: [PATCH 009/137] Change Acrobatics roll handling to take event.getDamage() instead of the event. Also adds a few new config options in advanced.yml for further customizing roll behavior. --- .../gmail/nossr50/config/AdvancedConfig.java | 4 + .../nossr50/listeners/EntityListener.java | 8 +- .../nossr50/skills/acrobatics/Acrobatics.java | 69 +++++++++++- .../skills/acrobatics/AcrobaticsManager.java | 27 ----- .../skills/acrobatics/RollEventHandler.java | 101 ------------------ src/main/resources/advanced.yml | 6 ++ 6 files changed, 83 insertions(+), 132 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 494af7b28..f9e200f9c 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -20,6 +20,7 @@ public class AdvancedConfig extends ConfigLoader { protected void loadKeys() { // TODO Do we need to use this? } + /* GENERAL */ public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); } @@ -29,9 +30,12 @@ public class AdvancedConfig extends ConfigLoader { public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); } public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); } + public int getRollDamageThreshold() { return config.getInt("Skills.Acrobatics.Roll_DamageThreshold", 7); } public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); } public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); } + public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); } + public int getGracefulRollSuccessModifer() { return config.getInt("Skills.Acrobatics.GracefulRoll_SuccessModifier", 2); } public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); } public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index e31351960..d78f5dced 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -34,7 +34,6 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.skills.acrobatics.Acrobatics; -import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; @@ -176,8 +175,11 @@ public class EntityListener implements Listener { if (!CombatTools.isInvincible(player, event.getDamage())) { if (cause == DamageCause.FALL && player.getItemInHand().getType() != Material.ENDER_PEARL && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player)) { - AcrobaticsManager acrobaticsManager = new AcrobaticsManager(mcMMOPlayer); - acrobaticsManager.rollCheck(event); + event.setDamage(Acrobatics.processRoll(player, event.getDamage())); + + if (event.getDamage() == 0) { + event.setCancelled(true); + } } else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.demolitionsExpertise(player)) { MiningManager miningManager = new MiningManager(mcMMOPlayer); diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index a085632f7..11d332359 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -1,22 +1,89 @@ package com.gmail.nossr50.skills.acrobatics; +import org.bukkit.entity.Player; + import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.utilities.PerksUtils; +import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; -public class Acrobatics { +public final class Acrobatics { public static double dodgeMaxChance = AdvancedConfig.getInstance().getDodgeChanceMax(); public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel(); public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier(); public static double rollMaxChance = AdvancedConfig.getInstance().getRollChanceMax(); public static int rollMaxBonusLevel = AdvancedConfig.getInstance().getRollMaxBonusLevel(); + public static int rollThreshold = AdvancedConfig.getInstance().getRollDamageThreshold(); public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax(); public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel(); + public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold(); + public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer(); public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier(); public static int fallXpModifier = AdvancedConfig.getInstance().getFallXPModifier(); public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled(); public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled(); + + private Acrobatics() {}; + + public static int processRoll(Player player, int damage) { + if (player.isSneaking() && Permissions.gracefulRoll(player)) { + return processGracefulRoll(player, damage); + } + + int modifiedDamage = calculateModifiedDamage(damage, rollThreshold); + + if (!isFatal(player, modifiedDamage) && isSuccessfulRoll(player, rollMaxChance, rollMaxBonusLevel, 1)) { + player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); + applyXpGain(player, damage, rollXpModifier); + + return modifiedDamage; + } + else if (!isFatal(player, damage)) { + applyXpGain(player, damage, fallXpModifier); + } + + return damage; + } + + private static int processGracefulRoll(Player player, int damage) { + int modifiedDamage = calculateModifiedDamage(damage, gracefulRollThreshold); + + if (!isFatal(player, modifiedDamage) && isSuccessfulRoll(player, gracefulRollMaxChance, gracefulRollMaxBonusLevel, gracefulRollSuccessModifier)) { + player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); + applyXpGain(player, damage, rollXpModifier); + + return modifiedDamage; + } + else if (!isFatal(player, damage)) { + applyXpGain(player, damage, fallXpModifier); + } + + return damage; + } + + private static boolean isFatal(Player player, int damage) { + return player.getHealth() - damage < 1; + } + + private static int calculateModifiedDamage(int damage, int damageThreshold) { + return Math.max(damage - damageThreshold, 0); + } + + private static boolean isSuccessfulRoll(Player player, double maxChance, int maxLevel, int successModifier) { + double successChance = (maxChance / maxLevel) * Math.min(Users.getPlayer(player).getProfile().getSkillLevel(SkillType.ACROBATICS), maxLevel) * successModifier; + + return successChance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, SkillType.ACROBATICS)); + } + + private static void applyXpGain(Player player, int baseXp, int multiplier) { + Users.getPlayer(player).beginXpGain(SkillType.ACROBATICS, baseXp * multiplier); + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 293844abf..f1c3f364d 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -12,33 +12,6 @@ public class AcrobaticsManager extends SkillManager { super(mcMMOPlayer, SkillType.ACROBATICS); } - /** - * Check for fall damage reduction. - * - * @param event The event to check - */ - public void rollCheck(EntityDamageEvent event) { - RollEventHandler eventHandler = new RollEventHandler(this, event); - - double chance; - - if (eventHandler.isGraceful) { - chance = (Acrobatics.gracefulRollMaxChance / Acrobatics.gracefulRollMaxBonusLevel) * eventHandler.skillModifier; - } - else { - chance = (Acrobatics.rollMaxChance / Acrobatics.rollMaxBonusLevel) * eventHandler.skillModifier; - } - - if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) { - eventHandler.modifyEventDamage(); - eventHandler.sendAbilityMessage(); - eventHandler.processXpGain(eventHandler.damage * Acrobatics.rollXpModifier); - } - else if (!eventHandler.isFatal(event.getDamage())) { - eventHandler.processXpGain(eventHandler.damage * Acrobatics.fallXpModifier); - } - } - /** * Check for dodge damage reduction. * diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java deleted file mode 100644 index 81fb9367d..000000000 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.gmail.nossr50.skills.acrobatics; - -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class RollEventHandler extends AcrobaticsEventHandler { - protected boolean isGraceful; - private int damageThreshold; - - protected RollEventHandler(AcrobaticsManager manager, EntityDamageEvent event) { - super(manager, event); - - isGracefulRoll(); - calculateSkillModifier(); - calculateDamageThreshold(); - calculateModifiedDamage(); - } - - @Override - protected void calculateSkillModifier() { - int skillModifer = manager.getSkillLevel(); - - if (isGraceful) { - skillModifer = skillModifer * 2; - } - - skillModifer = SkillTools.skillCheck(skillModifer, Acrobatics.rollMaxBonusLevel); - this.skillModifier = skillModifer; - } - - @Override - protected void calculateModifiedDamage() { - int modifiedDamage = damage - damageThreshold; - - if (modifiedDamage < 0) { - modifiedDamage = 0; - } - - this.modifiedDamage = modifiedDamage; - } - - @Override - protected void modifyEventDamage() { - event.setDamage(modifiedDamage); - - if (event.getDamage() == 0) { - event.setCancelled(true); - } - } - - - @Override - protected void sendAbilityMessage() { - Player player = manager.getMcMMOPlayer().getPlayer(); - - if (isGraceful) { - player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); - } - else { - player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); - } - } - - - @Override - protected void processXpGain(int xp) { - manager.getMcMMOPlayer().beginXpGain(SkillType.ACROBATICS, xp); - } - - /** - * Check if this is a graceful roll. - */ - private void isGracefulRoll() { - Player player = manager.getMcMMOPlayer().getPlayer(); - - if (Permissions.gracefulRoll(player)) { - this.isGraceful = player.isSneaking(); - } - else { - this.isGraceful = false; - } - } - - /** - * Calculate the damage threshold for this event. - */ - private void calculateDamageThreshold() { - int damageThreshold = 7; - - if (isGraceful) { - damageThreshold = damageThreshold * 2; - } - - this.damageThreshold = damageThreshold; - } -} diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 276622d1f..1e953ef16 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -27,13 +27,19 @@ Skills: # Roll_ChanceMax: Maximum chance of rolling when on Roll_MaxBonusLevel or higher # Roll_MaxBonusLevel: On this level or higher, the roll chance will not go higher than Roll_ChanceMax + # Roll_DamageThreshold: The max damage a player can negate with a roll Roll_ChanceMax: 100.0 Roll_MaxBonusLevel: 1000 + Roll_DamageThreshold: 7 # GracefulRoll_ChanceMax: Maximum chance of graceful rolling when on GracefulRoll_MaxBonusLevel or higher # GracefulRoll_MaxBonusLevel: On this level or higher, the graceful roll chance will not go higher than GracefulRoll_ChanceMax + # GracefulRoll_DamageThreshold: The max damage a player can negate with a graceful roll + # GracefulRoll_SuccessModifier: Graceful rolls will be this many times more likely to succeed than regular rolls GracefulRoll_ChanceMax: 100.0 GracefulRoll_MaxBonusLevel: 500 + GracefulRoll_DamageThreshold: 14 + GracefulRoll_SuccessModifier: 2 # Amount of experience for performing a dodge, roll or fall Dodge_XP_Modifier: 120 From f9ad8ffe93927161c9689310534024e470147844 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 13:40:36 -0500 Subject: [PATCH 010/137] This check was unneeded, we already verify that the player is, in fact, a player before this check is ever called. --- .../nossr50/skills/acrobatics/AcrobaticsEventHandler.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java index c2c441838..740782d10 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java @@ -3,8 +3,6 @@ package com.gmail.nossr50.skills.acrobatics; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; -import com.gmail.nossr50.util.Misc; - public abstract class AcrobaticsEventHandler { protected AcrobaticsManager manager; @@ -53,7 +51,7 @@ public abstract class AcrobaticsEventHandler { protected boolean isFatal(int damage) { Player player = manager.getMcMMOPlayer().getPlayer(); - if (Misc.isNPCEntity(player) || player.getHealth() - damage < 1) { + if (player.getHealth() - damage < 1) { return true; } From 0d473d232e8232f8d909454d5aec7dd47281e33a Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 13:47:54 -0500 Subject: [PATCH 011/137] Remove config caching from CombatTools.java --- .../nossr50/skills/utilities/CombatTools.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index 140ee80fe..f72bb42f2 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -46,8 +46,6 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public final class CombatTools { - private static Config configInstance = Config.getInstance(); - private CombatTools() {} /** @@ -342,7 +340,7 @@ public final class CombatTools { * @param cause DamageCause to pass to damage event */ private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) { - if (configInstance.getEventCallbackEnabled()) { + if (Config.getInstance().getEventCallbackEnabled()) { EntityDamageEvent ede = new FakeEntityDamageEvent(target, cause, dmg); mcMMO.p.getServer().getPluginManager().callEvent(ede); @@ -365,7 +363,7 @@ public final class CombatTools { * @param attacker Player to pass to event as damager */ private static void dealDamage(LivingEntity target, int dmg, Player attacker) { - if (configInstance.getEventCallbackEnabled()) { + if (Config.getInstance().getEventCallbackEnabled()) { EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg); mcMMO.p.getServer().getPluginManager().callEvent(ede); @@ -445,14 +443,14 @@ public final class CombatTools { double baseXP = 0; if (target instanceof Player) { - if (!configInstance.getExperienceGainsPlayerVersusPlayerEnabled()) { + if (!Config.getInstance().getExperienceGainsPlayerVersusPlayerEnabled()) { return; } Player defender = (Player) target; if (System.currentTimeMillis() >= Users.getPlayer(defender).getProfile().getRespawnATS() + 5) { - baseXP = 20 * configInstance.getPlayerVersusPlayerXP(); + baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP(); } } else if (!target.hasMetadata(mcMMO.entityMetadataKey)) { @@ -461,7 +459,7 @@ public final class CombatTools { baseXP = ModChecks.getCustomEntity(target).getXpMultiplier(); } else { - baseXP = configInstance.getAnimalsXP(); + baseXP = Config.getInstance().getAnimalsXP(); } } else { @@ -469,7 +467,7 @@ public final class CombatTools { switch (type) { case BAT: - baseXP = configInstance.getAnimalsXP(); + baseXP = Config.getInstance().getAnimalsXP(); break; case BLAZE: @@ -498,7 +496,7 @@ public final class CombatTools { case SKELETON: switch(((Skeleton) target).getSkeletonType()) { case WITHER: - baseXP = configInstance.getWitherSkeletonXP(); + baseXP = Config.getInstance().getWitherSkeletonXP(); break; default: baseXP = Config.getInstance().getCombatXP(type); From 9282b7bd15a247159a98b66466323468a45ded00 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 13:53:16 -0500 Subject: [PATCH 012/137] Remove config caching from SkillTools.java --- .../java/com/gmail/nossr50/listeners/PlayerListener.java | 4 ++-- src/main/java/com/gmail/nossr50/skills/SkillCommand.java | 3 ++- .../com/gmail/nossr50/skills/utilities/SkillTools.java | 7 +------ .../com/gmail/nossr50/skills/woodcutting/TreeFeller.java | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index f415d9e4f..e20cafb3a 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -335,7 +335,7 @@ public class PlayerListener implements Listener { /* ACTIVATION & ITEM CHECKS */ if (BlockChecks.canActivateAbilities(blockState)) { - if (SkillTools.abilitiesEnabled) { + if (Config.getInstance().getAbilitiesEnabled()) { if (BlockChecks.canActivateHerbalism(blockState)) { SkillTools.activationCheck(player, SkillType.HERBALISM); } @@ -365,7 +365,7 @@ public class PlayerListener implements Listener { case RIGHT_CLICK_AIR: /* ACTIVATION CHECKS */ - if (SkillTools.abilitiesEnabled) { + if (Config.getInstance().getAbilitiesEnabled()) { SkillTools.activationCheck(player, SkillType.AXES); SkillTools.activationCheck(player, SkillType.EXCAVATION); SkillTools.activationCheck(player, SkillType.HERBALISM); diff --git a/src/main/java/com/gmail/nossr50/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/skills/SkillCommand.java index eb430a969..b9b21b87f 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillCommand.java @@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.commands.CommandHelper; +import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.PerksUtils; @@ -125,7 +126,7 @@ public abstract class SkillCommand implements CommandExecutor { protected String[] calculateLengthDisplayValues() { int maxLength = skill.getAbility().getMaxTicks(); - int length = 2 + (int) (skillValue / SkillTools.abilityLengthIncreaseLevel); + int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength()); int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength); if (maxLength != 0) { diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java index 704acce16..5b6825123 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java @@ -37,11 +37,6 @@ import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class SkillTools { - static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); - public static boolean abilitiesEnabled = Config.getInstance().getAbilitiesEnabled(); - public static int toolDurabilityLoss = Config.getInstance().getAbilityToolDamage(); - public static int abilityLengthIncreaseLevel = AdvancedConfig.getInstance().getAbilityLength(); - public static void handleFoodSkills(Player player, SkillType skill, FoodLevelChangeEvent event, int baseLevel, int maxLevel, int rankChange) { int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill); @@ -391,7 +386,7 @@ public class SkillTools { } if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) { - int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / abilityLengthIncreaseLevel), ability.getMaxTicks()); + int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks()); ParticleEffectUtils.playAbilityEnabledEffect(player); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java index 6e9717914..4f3abeb1d 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java @@ -143,7 +143,7 @@ public final class TreeFeller { for (BlockState blockState : treeFellerBlocks) { if (BlockChecks.isLog(blockState) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) { - durabilityLoss += SkillTools.toolDurabilityLoss; + durabilityLoss += Config.getInstance().getAbilityToolDamage(); } } From e556b707c910e30407a9433bf112b08a3fcd0a3e Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 13:59:07 -0500 Subject: [PATCH 013/137] Fix for NPE when right/left clicking air. --- .../java/com/gmail/nossr50/listeners/PlayerListener.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index e20cafb3a..ec26f221f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -327,7 +327,12 @@ public class PlayerListener implements Listener { } Block block = event.getClickedBlock(); - BlockState blockState = block.getState(); + BlockState blockState = null; + + if (block != null) { + blockState = block.getState(); + } + ItemStack heldItem = player.getItemInHand(); switch (event.getAction()) { From 7e6550d1477d6da4a00782e53e7ebb8c4191fe94 Mon Sep 17 00:00:00 2001 From: "U-YUE\\Sean" Date: Wed, 20 Feb 2013 09:53:24 -0800 Subject: [PATCH 014/137] Unregistering events on disable. Should deal with edge cases regarding forced reloads. --- src/main/java/com/gmail/nossr50/mcMMO.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 0e5b0bc96..97db900a6 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -11,6 +11,7 @@ import net.shatteredlands.shatt.backup.ZipLibrary; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -214,6 +215,7 @@ public class mcMMO extends JavaPlugin { getServer().getScheduler().cancelTasks(this); // This removes our tasks placeStore.saveAll(); // Save our metadata placeStore.cleanUp(); // Cleanup empty metadata stores + HandlerList.unregisterAll(this); // Cancel event registrations if (Config.getInstance().getBackupsEnabled()) { // Remove other tasks BEFORE starting the Backup, or we just cancel it straight away. From fd821139bdfe9bf5ffcc8d1af2a45428a87bffbb Mon Sep 17 00:00:00 2001 From: "U-YUE\\Sean" Date: Wed, 20 Feb 2013 09:58:53 -0800 Subject: [PATCH 015/137] Fixing an NPE related to the skillreset command. --- .../com/gmail/nossr50/commands/admin/SkillresetCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java index 4ba87e25e..901de47da 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java @@ -137,7 +137,7 @@ public class SkillresetCommand implements CommandExecutor { continue; } - if (!Permissions.skillresetOthers(sender, skill)) { + if (!Permissions.skillresetOthers(sender, skillType)) { sender.sendMessage(command.getPermissionMessage()); continue; } From d2035f1816419b06fff18e0c0f8e3b0e30a8f3ff Mon Sep 17 00:00:00 2001 From: "U-YUE\\Sean" Date: Wed, 20 Feb 2013 12:44:17 -0800 Subject: [PATCH 016/137] Setting mcMMO to disable itself if it errors on load. Fixes most reloading errors. --- src/main/java/com/gmail/nossr50/mcMMO.java | 103 ++++++++++++--------- 1 file changed, 61 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 97db900a6..e72a6a6d5 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -8,6 +8,7 @@ import java.util.List; import net.shatteredlands.shatt.backup.ZipLibrary; +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -98,46 +99,52 @@ public class mcMMO extends JavaPlugin { */ @Override public void onEnable() { - p = this; - getLogger().setFilter(new LogFilter(this)); - entityMetadata = new FixedMetadataValue(mcMMO.p, true); - setupFilePaths(); - setupSpout(); - loadConfigFiles(); + try { + p = this; + getLogger().setFilter(new LogFilter(this)); + entityMetadata = new FixedMetadataValue(mcMMO.p, true); + setupFilePaths(); + setupSpout(); + loadConfigFiles(); - if (!Config.getInstance().getUseMySQL()) { - Users.loadUsers(); + if (!Config.getInstance().getUseMySQL()) { + Users.loadUsers(); + } + + registerEvents(); + + // Setup the leader boards + if (Config.getInstance().getUseMySQL()) { + // TODO: Why do we have to check for a connection that hasn't be made yet? + Database.checkConnected(); + Database.createStructure(); + } + else { + Leaderboard.updateLeaderboards(); + } + + for (Player player : getServer().getOnlinePlayers()) { + Users.addUser(player); // In case of reload add all users back into PlayerProfile + } + + getLogger().info("Version " + getDescription().getVersion() + " is enabled!"); + + scheduleTasks(); + registerCommands(); + + MetricsManager.setup(); + + placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager + + checkForUpdates(); + + if (Config.getInstance().getPTPCommandWorldPermissions()) { + Permissions.generateWorldTeleportPermissions(); + } } - - registerEvents(); - - // Setup the leader boards - if (Config.getInstance().getUseMySQL()) { - // TODO: Why do we have to check for a connection that hasn't be made yet? - Database.checkConnected(); - Database.createStructure(); - } - else { - Leaderboard.updateLeaderboards(); - } - - for (Player player : getServer().getOnlinePlayers()) { - Users.addUser(player); // In case of reload add all users back into PlayerProfile - } - - getLogger().info("Version " + getDescription().getVersion() + " is enabled!"); - - scheduleTasks(); - registerCommands(); - - MetricsManager.setup(); - - placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager - - checkForUpdates(); - - if (Config.getInstance().getPTPCommandWorldPermissions()) { - Permissions.generateWorldTeleportPermissions(); + catch (Throwable t) { + getLogger().severe("There was an error while enabling mcMMO! Disabling now"); + Bukkit.getPluginManager().disablePlugin(this); } } @@ -210,11 +217,15 @@ public class mcMMO extends JavaPlugin { */ @Override public void onDisable() { - Users.saveAll(); // Make sure to save player information if the server shuts down - PartyManager.saveParties(); + try { + Users.saveAll(); // Make sure to save player information if the server shuts down + PartyManager.saveParties(); + placeStore.saveAll(); // Save our metadata + placeStore.cleanUp(); // Cleanup empty metadata stores + } + catch (NullPointerException e) {} + getServer().getScheduler().cancelTasks(this); // This removes our tasks - placeStore.saveAll(); // Save our metadata - placeStore.cleanUp(); // Cleanup empty metadata stores HandlerList.unregisterAll(this); // Cancel event registrations if (Config.getInstance().getBackupsEnabled()) { @@ -225,6 +236,14 @@ public class mcMMO extends JavaPlugin { catch (IOException e) { getLogger().severe(e.toString()); } + catch (Throwable e) { + if (e instanceof NoClassDefFoundError) { + getLogger().severe("Backup class not found. Do not replace the mcMMO jar during runtime."); + } + else { + getLogger().severe(e.toString()); + } + } } getLogger().info("Was disabled."); //How informative! From 1d316f9420ac7f928748617087d81b4509e33021 Mon Sep 17 00:00:00 2001 From: Glitchfinder Date: Wed, 20 Feb 2013 15:30:42 -0800 Subject: [PATCH 017/137] Making the error reporting for enabling mcMMO more informative. --- src/main/java/com/gmail/nossr50/mcMMO.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index e72a6a6d5..47236aa1e 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -143,7 +143,15 @@ public class mcMMO extends JavaPlugin { } } catch (Throwable t) { - getLogger().severe("There was an error while enabling mcMMO! Disabling now"); + getLogger().severe("There was an error while enabling mcMMO!"); + + if (!(t instanceof ExceptionInInitializerError)) { + t.printStackTrace(); + } + else { + getLogger().info("Please do not replace the mcMMO jar while the server is running."); + } + Bukkit.getPluginManager().disablePlugin(this); } } @@ -238,7 +246,8 @@ public class mcMMO extends JavaPlugin { } catch (Throwable e) { if (e instanceof NoClassDefFoundError) { - getLogger().severe("Backup class not found. Do not replace the mcMMO jar during runtime."); + getLogger().severe("Backup class not found!"); + getLogger().info("Please do not replace the mcMMO jar while the server is running."); } else { getLogger().severe(e.toString()); From 6c6ab4c96e5a9bc28fc846fd46ffeb8106e20f4e Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 14:50:41 -0500 Subject: [PATCH 018/137] We only need the block in here. --- .../java/com/gmail/nossr50/listeners/PlayerListener.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index ec26f221f..96a8d95cc 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -326,17 +326,12 @@ public class PlayerListener implements Listener { return; } - Block block = event.getClickedBlock(); - BlockState blockState = null; - - if (block != null) { - blockState = block.getState(); - } - ItemStack heldItem = player.getItemInHand(); switch (event.getAction()) { case RIGHT_CLICK_BLOCK: + Block block = event.getClickedBlock(); + BlockState blockState = block.getState(); /* ACTIVATION & ITEM CHECKS */ if (BlockChecks.canActivateAbilities(blockState)) { From 2fee9df62559f67e1c9bb6b7ec5e8a5c1c75c624 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 17:55:15 -0500 Subject: [PATCH 019/137] Move more event handling back into the main listener to avoid passing the event itself. --- .../nossr50/listeners/EntityListener.java | 90 ++++++++++++++++--- .../nossr50/skills/acrobatics/Acrobatics.java | 5 ++ .../nossr50/skills/mining/BlastMining.java | 27 ++++++ .../DemoltionsExpertiseEventHandler.java | 37 -------- .../nossr50/skills/mining/MiningManager.java | 13 --- .../EnvironmentallyAwareEventHandler.java | 35 -------- .../skills/taming/ShockProofEventHandler.java | 15 ---- .../gmail/nossr50/skills/taming/Taming.java | 43 +++++++++ .../nossr50/skills/taming/TamingManager.java | 87 ------------------ .../skills/taming/ThickFurEventHandler.java | 33 ------- 10 files changed, 153 insertions(+), 232 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/mining/DemoltionsExpertiseEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/taming/EnvironmentallyAwareEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/taming/ShockProofEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/taming/ThickFurEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index d78f5dced..5b1f22eac 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.listeners; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.Entity; @@ -37,8 +36,10 @@ import com.gmail.nossr50.skills.acrobatics.Acrobatics; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; +import com.gmail.nossr50.skills.mining.BlastMining; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.runnables.BleedTimer; +import com.gmail.nossr50.skills.taming.Taming; import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.utilities.CombatTools; import com.gmail.nossr50.util.Misc; @@ -156,6 +157,10 @@ public class EntityListener implements Listener { DamageCause cause = event.getCause(); LivingEntity livingEntity = (LivingEntity) entity; + if (CombatTools.isInvincible(livingEntity, event.getDamage())) { + return; + } + if (livingEntity instanceof Player) { Player player = (Player) entity; @@ -173,31 +178,92 @@ public class EntityListener implements Listener { return; } - if (!CombatTools.isInvincible(player, event.getDamage())) { - if (cause == DamageCause.FALL && player.getItemInHand().getType() != Material.ENDER_PEARL && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player)) { + switch (cause) { + case FALL: + if (Acrobatics.canRoll(player)) { event.setDamage(Acrobatics.processRoll(player, event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); + return; } } - else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.demolitionsExpertise(player)) { - MiningManager miningManager = new MiningManager(mcMMOPlayer); - miningManager.demolitionsExpertise(event); - } + break; - if (event.getDamage() >= 1) { - profile.actualizeRecentlyHurt(); + case BLOCK_EXPLOSION: + if (Permissions.demolitionsExpertise(player)) { + event.setDamage(BlastMining.processDemolitionsExpertise(player, event.getDamage())); + + if (event.getDamage() == 0) { + event.setCancelled(true); + return; + } } + break; + + default: + break; + } + + if (event.getDamage() >= 1) { + profile.actualizeRecentlyHurt(); } } else if (livingEntity instanceof Tameable) { Tameable pet = (Tameable) livingEntity; AnimalTamer owner = pet.getOwner(); - if ((!CombatTools.isInvincible(livingEntity, event.getDamage())) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) { - TamingManager tamingManager = new TamingManager(Users.getPlayer((Player) owner)); - tamingManager.preventDamage(event); + if (Taming.canPreventDamage(pet, owner)) { + Player player = (Player) owner; + Wolf wolf = (Wolf) pet; + + switch (cause) { + case CONTACT: + case LAVA: + case FIRE: + if (Taming.canUseEnvironmentallyAware(player)) { + Taming.processEnvironmentallyAware(player, wolf, event.getDamage()); + } + return; + + case FALL: + if (Taming.canUseEnvironmentallyAware(player)) { + event.setCancelled(true); + } + return; + + case ENTITY_ATTACK: + case PROJECTILE: + if (Taming.canUseThickFur(player)) { + event.setDamage(Taming.processThickFur(event.getDamage())); + + if (event.getDamage() == 0) { + event.setCancelled(true); + } + } + return; + + case FIRE_TICK: + if (Taming.canUseThickFur(player)) { + wolf.setFireTicks(0); + } + return; + + case BLOCK_EXPLOSION: + case ENTITY_EXPLOSION: + case LIGHTNING: + if (Taming.canUseShockProof(player)) { + event.setDamage(Taming.processShockProof(event.getDamage())); + + if (event.getDamage() == 0) { + event.setCancelled(true); + } + } + return; + + default: + return; + } } } } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index 11d332359..618c8269e 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.skills.acrobatics; +import org.bukkit.Material; import org.bukkit.entity.Player; import com.gmail.nossr50.config.AdvancedConfig; @@ -33,6 +34,10 @@ public final class Acrobatics { private Acrobatics() {}; + public static boolean canRoll(Player player) { + return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player); + } + public static int processRoll(Player player, int damage) { if (player.isSneaking() && Permissions.gracefulRoll(player)) { return processGracefulRoll(player, damage); diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java index f293104e8..0d31b3acd 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java @@ -1,7 +1,13 @@ package com.gmail.nossr50.skills.mining; +import org.bukkit.entity.Player; + import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.skills.utilities.SkillTools; +import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; public class BlastMining { public static int rank1 = AdvancedConfig.getInstance().getBlastMiningRank1(); @@ -16,4 +22,25 @@ public class BlastMining { public static int detonatorID = Config.getInstance().getDetonatorItemID(); public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100; + + public static boolean canUseDemolitionsExpertise(Player player) { + return SkillTools.unlockLevelReached(player, SkillType.MINING, rank4) && Permissions.demolitionsExpertise(player); + } + + public static int processDemolitionsExpertise(Player player, int damage) { + int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.MINING); + int modifiedDamage; + + if (skillLevel >= BlastMining.rank8) { + modifiedDamage = 0; + } + else if (skillLevel >= BlastMining.rank6) { + modifiedDamage = damage / 4; + } + else { + modifiedDamage = damage / 2; + } + + return modifiedDamage; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/DemoltionsExpertiseEventHandler.java b/src/main/java/com/gmail/nossr50/skills/mining/DemoltionsExpertiseEventHandler.java deleted file mode 100644 index a10ff7adf..000000000 --- a/src/main/java/com/gmail/nossr50/skills/mining/DemoltionsExpertiseEventHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.gmail.nossr50.skills.mining; - -import org.bukkit.event.entity.EntityDamageEvent; - -public class DemoltionsExpertiseEventHandler { - private int skillLevel; - private EntityDamageEvent event; - private int damage; - private double damageModifier; - - public DemoltionsExpertiseEventHandler(MiningManager manager, EntityDamageEvent event) { - this.skillLevel = manager.getSkillLevel(); - - this.event = event; - this.damage = event.getDamage(); - } - - protected void calculateDamageModifier() { - if (skillLevel >= BlastMining.rank8) { - damageModifier = 0.0; - } - else if (skillLevel >= BlastMining.rank6) { - damageModifier = 0.25; - } - else if (skillLevel >= BlastMining.rank4) { - damageModifier = 0.5; - } - else { - damageModifier = 1.0; - } - } - - protected void modifyEventDamage() { - damage = (int) (damage * damageModifier); - event.setDamage(damage); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index dfe853bc6..1a75ceb38 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.mining; import org.bukkit.Material; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -73,18 +72,6 @@ public class MiningManager extends SkillManager{ eventHandler.processXPGain(); } - /** - * Decreases damage dealt by the explosion from TNT activated by Blast Mining. - * - * @param event Event whose explosion damage is being reduced - */ - public void demolitionsExpertise(EntityDamageEvent event) { - DemoltionsExpertiseEventHandler eventHandler = new DemoltionsExpertiseEventHandler(this, event); - - eventHandler.calculateDamageModifier(); - eventHandler.modifyEventDamage(); - } - /** * Increases the blast radius of the explosion. * diff --git a/src/main/java/com/gmail/nossr50/skills/taming/EnvironmentallyAwareEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/EnvironmentallyAwareEventHandler.java deleted file mode 100644 index c1ac28f7a..000000000 --- a/src/main/java/com/gmail/nossr50/skills/taming/EnvironmentallyAwareEventHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.entity.Player; -import org.bukkit.entity.Wolf; -import org.bukkit.event.entity.EntityDamageEvent; - -import com.gmail.nossr50.locale.LocaleLoader; - -public class EnvironmentallyAwareEventHandler { - private Player player; - private EntityDamageEvent event; - private Wolf wolf; - - protected EnvironmentallyAwareEventHandler(TamingManager manager, EntityDamageEvent event) { - this.player = manager.getMcMMOPlayer().getPlayer(); - this.event = event; - this.wolf = (Wolf) event.getEntity(); - } - - protected void teleportWolf() { - if (event.getDamage() > wolf.getHealth()) { - return; - } - - wolf.teleport(player.getLocation()); - } - - protected void sendAbilityMessage() { - player.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf")); - } - - protected void cancelEvent() { - event.setCancelled(true); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/ShockProofEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/ShockProofEventHandler.java deleted file mode 100644 index 7259fbfba..000000000 --- a/src/main/java/com/gmail/nossr50/skills/taming/ShockProofEventHandler.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.event.entity.EntityDamageEvent; - -public class ShockProofEventHandler { - private EntityDamageEvent event; - - protected ShockProofEventHandler (EntityDamageEvent event) { - this.event = event; - } - - protected void modifyEventDamage() { - event.setDamage(event.getDamage() / Taming.shockProofModifier); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java index 0bffe5419..e0a8e7e0c 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java @@ -1,7 +1,16 @@ package com.gmail.nossr50.skills.taming; +import org.bukkit.entity.AnimalTamer; +import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; +import org.bukkit.entity.Wolf; + import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.utilities.SkillTools; +import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.Permissions; public class Taming { public static int environmentallyAwareUnlockLevel = AdvancedConfig.getInstance().getEnviromentallyAwareUnlock(); @@ -25,4 +34,38 @@ public class Taming { public static int wolfXp = Config.getInstance().getTamingXPWolf(); public static int ocelotXp = Config.getInstance().getTamingXPOcelot(); + + public static boolean canPreventDamage(Tameable pet, AnimalTamer owner) { + return pet.isTamed() && owner instanceof Player && pet instanceof Wolf; + } + + public static boolean canUseThickFur(Player player) { + return SkillTools.unlockLevelReached(player, SkillType.TAMING, thickFurUnlockLevel) && Permissions.thickFur(player); + } + + public static boolean canUseEnvironmentallyAware(Player player) { + return SkillTools.unlockLevelReached(player, SkillType.TAMING, environmentallyAwareUnlockLevel) && Permissions.environmentallyAware(player); + } + + public static boolean canUseShockProof(Player player) { + return SkillTools.unlockLevelReached(player, SkillType.TAMING, shockProofUnlockLevel) && Permissions.shockProof(player); + } + + public static int processThickFur(int damage) { + return damage / thickFurModifier; + } + + public static void processEnvironmentallyAware(Player player, Wolf wolf, int damage) { + if (damage > wolf.getHealth()) { + return; + } + + wolf.teleport(player); + player.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf")); + } + + public static int processShockProof(int damage) { + return damage / shockProofModifier; + } + } 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 6a4a94a69..8d851bf65 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -4,7 +4,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Wolf; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityTameEvent; import org.bukkit.inventory.ItemStack; @@ -90,39 +89,6 @@ public class TamingManager extends SkillManager { } } - /** - * Prevent damage to wolves based on various skills. - * - * @param event The event to modify - */ - public void preventDamage(EntityDamageEvent event) { - DamageCause cause = event.getCause(); - - switch (cause) { - case CONTACT: - case LAVA: - case FIRE: - case FALL: - environmentallyAware(event, cause); - break; - - case ENTITY_ATTACK: - case FIRE_TICK: - case PROJECTILE: - thickFur(event, cause); - break; - - case BLOCK_EXPLOSION: - case ENTITY_EXPLOSION: - case LIGHTNING: - shockProof(event); - break; - - default: - break; - } - } - /** * Summon an ocelot to your side. */ @@ -177,57 +143,4 @@ public class TamingManager extends SkillManager { eventHandler.sendSuccessMessage(); } } - - /** - * Handle the Environmentally Aware ability. - * - * @param event The event to modify - * @param cause The damage cause of the event - */ - private void environmentallyAware(EntityDamageEvent event, DamageCause cause) { - if (skillLevel >= Taming.environmentallyAwareUnlockLevel && Permissions.environmentallyAware(mcMMOPlayer.getPlayer())) { - EnvironmentallyAwareEventHandler eventHandler = new EnvironmentallyAwareEventHandler(this, event); - - switch (cause) { - case CONTACT: - case FIRE: - case LAVA: - eventHandler.teleportWolf(); - eventHandler.sendAbilityMessage(); - break; - - case FALL: - eventHandler.cancelEvent(); - break; - - default: - break; - } - } - } - - /** - * Handle the Thick Fur ability. - * - * @param event The event to modify - * @param cause The damage cause of the event - */ - private void thickFur(EntityDamageEvent event, DamageCause cause) { - if (skillLevel >= Taming.thickFurUnlockLevel && Permissions.thickFur(mcMMOPlayer.getPlayer())) { - ThickFurEventHandler eventHandler = new ThickFurEventHandler(event, cause); - eventHandler.modifyEventDamage(); - } - } - - /** - * Handle the Shock Proof ability. - * - * @param event The event to modify - */ - private void shockProof(EntityDamageEvent event) { - if (skillLevel >= Taming.shockProofUnlockLevel && Permissions.shockProof(mcMMOPlayer.getPlayer())) { - ShockProofEventHandler eventHandler = new ShockProofEventHandler(event); - eventHandler.modifyEventDamage(); - } - } } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/ThickFurEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/ThickFurEventHandler.java deleted file mode 100644 index 7a0a19153..000000000 --- a/src/main/java/com/gmail/nossr50/skills/taming/ThickFurEventHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.entity.Wolf; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -public class ThickFurEventHandler { - private DamageCause cause; - private EntityDamageEvent event; - private Wolf wolf; - - protected ThickFurEventHandler (EntityDamageEvent event, DamageCause cause) { - this.cause = cause; - this.event = event; - this.wolf = (Wolf) event.getEntity(); - } - - protected void modifyEventDamage() { - switch (cause) { - case FIRE_TICK: - wolf.setFireTicks(0); - break; - - case ENTITY_ATTACK: - case PROJECTILE: - event.setDamage(event.getDamage() / Taming.thickFurModifier); - break; - - default: - break; - } - } -} From 62aaad8707009a5b782ba89ca000f7fbecd5f603 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 22 Feb 2013 18:47:34 -0500 Subject: [PATCH 020/137] Added "Holy Hound" ability to Taming --- Changelog.txt | 1 + .../gmail/nossr50/config/AdvancedConfig.java | 2 ++ .../nossr50/listeners/EntityListener.java | 16 +++++++++---- .../gmail/nossr50/skills/taming/Taming.java | 23 +++++++++++++++++-- .../nossr50/skills/taming/TamingCommand.java | 19 +++++++++++++-- .../com/gmail/nossr50/util/Permissions.java | 1 + src/main/resources/advanced.yml | 3 +++ .../resources/locale/locale_en_US.properties | 5 ++++ src/main/resources/plugin.yml | 3 +++ 9 files changed, 65 insertions(+), 8 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 1ceacadca..1188a4184 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -38,6 +38,7 @@ Version 1.4.00-dev + Added '/mcnotify' command to toggle ability notifications on/off + Added ability for config files to automatically update with new keys, and prune out old ones + Added config option to make .new config files instead over writing over old ones when updating + + Added "Holy Hound" ability to Taming = Fixed Green Thumb on wheat not working properly at rank 4 = Fixed Green Thumb and Green Terra consuming twice the amount of seed needed = Fixed Green Terra not also checking Green Thumb permissions diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index f9e200f9c..1d56239ef 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -197,6 +197,8 @@ public class AdvancedConfig extends ConfigLoader { public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); } public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); } + public int getHolyHoundUnlock() {return config.getInt("Skills.Taming.HolyHound_UnlockLevel", 375); } + public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); } public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 5b1f22eac..d3da6d84e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -219,8 +219,8 @@ public class EntityListener implements Listener { switch (cause) { case CONTACT: - case LAVA: case FIRE: + case LAVA: if (Taming.canUseEnvironmentallyAware(player)) { Taming.processEnvironmentallyAware(player, wolf, event.getDamage()); } @@ -235,7 +235,7 @@ public class EntityListener implements Listener { case ENTITY_ATTACK: case PROJECTILE: if (Taming.canUseThickFur(player)) { - event.setDamage(Taming.processThickFur(event.getDamage())); + event.setDamage(Taming.processThickFur(wolf, event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); @@ -245,7 +245,15 @@ public class EntityListener implements Listener { case FIRE_TICK: if (Taming.canUseThickFur(player)) { - wolf.setFireTicks(0); + Taming.processThickFurFire(wolf); + } + return; + + case MAGIC: + case POISON: + case WITHER: + if (Taming.canUseHolyHound(player)) { + Taming.processHolyHound(wolf, event.getDamage()); } return; @@ -253,7 +261,7 @@ public class EntityListener implements Listener { case ENTITY_EXPLOSION: case LIGHTNING: if (Taming.canUseShockProof(player)) { - event.setDamage(Taming.processShockProof(event.getDamage())); + event.setDamage(Taming.processShockProof(wolf, event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java index e0a8e7e0c..2de1e2c31 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.skills.taming; +import org.bukkit.EntityEffect; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; @@ -14,6 +15,7 @@ import com.gmail.nossr50.util.Permissions; public class Taming { public static int environmentallyAwareUnlockLevel = AdvancedConfig.getInstance().getEnviromentallyAwareUnlock(); + public static int holyHoundUnlockLevel = AdvancedConfig.getInstance().getHolyHoundUnlock(); public static double fastFoodServiceActivationChance = AdvancedConfig.getInstance().getFastFoodChance(); public static int fastFoodServiceUnlockLevel = AdvancedConfig.getInstance().getFastFoodUnlock(); @@ -51,10 +53,20 @@ public class Taming { return SkillTools.unlockLevelReached(player, SkillType.TAMING, shockProofUnlockLevel) && Permissions.shockProof(player); } - public static int processThickFur(int damage) { + public static boolean canUseHolyHound(Player player) { + return SkillTools.unlockLevelReached(player, SkillType.TAMING, holyHoundUnlockLevel) && Permissions.holyHound(player); + } + + public static int processThickFur(Wolf wolf, int damage) { + wolf.playEffect(EntityEffect.WOLF_SHAKE); return damage / thickFurModifier; } + public static void processThickFurFire(Wolf wolf) { + wolf.playEffect(EntityEffect.WOLF_SMOKE); + wolf.setFireTicks(0); + } + public static void processEnvironmentallyAware(Player player, Wolf wolf, int damage) { if (damage > wolf.getHealth()) { return; @@ -64,8 +76,15 @@ public class Taming { player.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf")); } - public static int processShockProof(int damage) { + public static int processShockProof(Wolf wolf, int damage) { + wolf.playEffect(EntityEffect.WOLF_SHAKE); return damage / shockProofModifier; } + public static void processHolyHound(Wolf wolf, int damage) { + int modifiedHealth = Math.min(wolf.getHealth() + damage, wolf.getMaxHealth()); + + wolf.setHealth(modifiedHealth); + wolf.playEffect(EntityEffect.WOLF_HEARTS); + } } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingCommand.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingCommand.java index cf5786238..b5a89b727 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingCommand.java @@ -18,6 +18,7 @@ public class TamingCommand extends SkillCommand { private boolean canShockProof; private boolean canCallWild; private boolean canFastFood; + private boolean canHolyHound; public TamingCommand() { super(SkillType.TAMING); @@ -40,11 +41,12 @@ public class TamingCommand extends SkillCommand { canSharpenedClaws = Permissions.sharpenedClaws(player); canShockProof = Permissions.shockProof(player); canThickFur = Permissions.thickFur(player); + canHolyHound = Permissions.holyHound(player); } @Override protected boolean effectsHeaderPermissions() { - return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur; + return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; } @Override @@ -79,6 +81,10 @@ public class TamingCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17"))); } + if (canHolyHound) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19"))); + } + if (canCallWild) { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13"))); player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost())); @@ -88,7 +94,7 @@ public class TamingCommand extends SkillCommand { @Override protected boolean statsHeaderPermissions() { - return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur; + return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; } @Override @@ -120,6 +126,15 @@ public class TamingCommand extends SkillCommand { } } + if (canHolyHound) { + if (skillValue < Taming.holyHoundUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel))); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11"))); + } + } + if (canShockProof) { if (skillValue < Taming.shockProofUnlockLevel) { player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel))); diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index ec55c01a6..46d907b75 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -187,6 +187,7 @@ public final class Permissions { public static boolean environmentallyAware(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.taming.environmentallyaware"); } public static boolean fastFoodService(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.taming.fastfoodservice"); } public static boolean gore(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.taming.gore"); } + public static boolean holyHound(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.taming.holyhound"); } public static boolean thickFur(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.taming.thickfur"); } public static boolean sharpenedClaws(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.taming.sharpenedclaws"); } public static boolean shockProof(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.taming.shockproof"); } diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 1e953ef16..982a771e8 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -290,6 +290,9 @@ Skills: ThickFur_UnlockLevel: 250 ThickFur_Modifier: 2 + # HolyHound_UnlockLevel: Level when HolyHound unlocks + HolyHound_UnlockLevel: 375 + # ShockProof_UnlockLevel: Level when ShockProof unlocks # ShockProof_Modifier: Damage will get divided by this modifier ShockProof_UnlockLevel: 500 diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 50cefc831..9bdfe6e4d 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -288,11 +288,14 @@ Taming.Ability.Bonus.6=Sharpened Claws Taming.Ability.Bonus.7=+{0} Damage Taming.Ability.Bonus.8=Fast Food Service Taming.Ability.Bonus.9={0} Chance for heal on attack +Taming.Ability.Bonus.10=Holy Hound +Taming.Ability.Bonus.11=Regain health when damaged by magic or poison Taming.Ability.Locked.0=LOCKED UNTIL {0}+ SKILL (ENVIRONMENTALLY AWARE) Taming.Ability.Locked.1=LOCKED UNTIL {0}+ SKILL (THICK FUR) Taming.Ability.Locked.2=LOCKED UNTIL {0}+ SKILL (SHOCK PROOF) Taming.Ability.Locked.3=LOCKED UNTIL {0}+ SKILL (SHARPENED CLAWS) Taming.Ability.Locked.4=LOCKED UNTIL {0}+ SKILL (FAST FOOD SERVICE) +Taming.Ability.Locked.5=LOCKED UNTIL {0}+ SKILL (HOLY HOUND) Taming.Combat.Chance.Gore=[[RED]]Gore Chance: [[YELLOW]]{0} Taming.Effect.0=Beast Lore Taming.Effect.1=Bone-whacking inspects wolves & ocelots @@ -304,6 +307,8 @@ Taming.Effect.14=[[GRAY]]COTW (Ocelot): Crouch and left-click with {0} Fish in h Taming.Effect.15=[[GRAY]]COTW (Wolf): Crouch and left-click with {0} Bones in hand Taming.Effect.16=Fast Food Service Taming.Effect.17=Chance for wolves to heal on attack +Taming.Effect.18=Holy Hound +Taming.Effect.19=Healed by Magic & Poison Taming.Effect.2=Gore Taming.Effect.3=Critical Strike that applies Bleed Taming.Effect.4=Sharpened Claws diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6b33877ee..98ed35871 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -508,6 +508,7 @@ permissions: mcmmo.ability.taming.environmentallyaware: true mcmmo.ability.taming.fastfoodservice: true mcmmo.ability.taming.gore: true + mcmmo.ability.taming.holyhound: true mcmmo.ability.taming.sharpenedclaws: true mcmmo.ability.taming.shockproof: true mcmmo.ability.taming.thickfur: true @@ -521,6 +522,8 @@ permissions: description: Allows access to the Fast Food Service ability mcmmo.ability.taming.gore: description: Allows access to the Gore ability + mcmmo.ability.taming.holyhound: + description: Allows access to the Holy Hound ability mcmmo.ability.taming.sharpenedclaws: description: Allows access to the Sharpened Claws ability mcmmo.ability.taming.shockproof: From 1db9a554dc4d4ae5cd63d1014cd98aa56b53d85e Mon Sep 17 00:00:00 2001 From: shatteredbeam Date: Fri, 22 Feb 2013 20:54:15 -0800 Subject: [PATCH 021/137] Added Graphs determining above or below default values for the global multiplier and the global curve modifier. --- .../nossr50/util/metrics/MetricsManager.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java b/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java index ababef612..a30918a81 100644 --- a/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java +++ b/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java @@ -193,6 +193,74 @@ public class MetricsManager { } }); + // GlobalMultiplierGraph Fuzzy Logic Numbers + Graph globalMultiplierGraphFuzzy = metrics.createGraph("Global Multiplier Fuzz"); + + if (Config.getInstance().getExperienceGainsGlobalMultiplier() > 1.0) { + globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") { + + @Override + public int getValue() { + return 1; + } + }); + } + else if (Config.getInstance().getExperienceGainsGlobalMultiplier() < 1.0) { + globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") { + + @Override + public int getValue() { + return 1; + } + }); + } + else { + globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") { + + @Override + public int getValue() { + return 1; + } + }); + } + globalMultiplierGraph.addPlotter(new Metrics.Plotter(Config.getInstance().getExperienceGainsGlobalMultiplier() + "") { + @Override + public int getValue() { + return 1; + } + }); + + //GlobalCurveModifier Fuzzy Logic Numbers + Graph globalCurveMultiplierGraphFuzzy = metrics.createGraph("Global Curve Multiplier Fuzz"); + + if (Config.getInstance().getFormulaMultiplierCurve() > 20.0) { + globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") { + + @Override + public int getValue() { + return 1; + } + }); + } + else if (Config.getInstance().getFormulaMultiplierCurve() < 20.0) { + globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") { + + @Override + public int getValue() { + return 1; + } + }); + } + else { + globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") { + + @Override + public int getValue() { + return 1; + } + }); + } + // Chimera Wing Usage Trackers final String chimeraGraphName = "Chimera Wing Usage"; From 920bdde135290cbf63c833b1da6f992b0a34cdd3 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Sat, 23 Feb 2013 00:00:58 -0500 Subject: [PATCH 022/137] NuclearW is a mean person who hates other peoples' code --- .../nossr50/util/metrics/MetricsManager.java | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java b/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java index a30918a81..758248b5f 100644 --- a/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java +++ b/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java @@ -197,8 +197,7 @@ public class MetricsManager { Graph globalMultiplierGraphFuzzy = metrics.createGraph("Global Multiplier Fuzz"); if (Config.getInstance().getExperienceGainsGlobalMultiplier() > 1.0) { - globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") { - + globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") { @Override public int getValue() { return 1; @@ -206,8 +205,7 @@ public class MetricsManager { }); } else if (Config.getInstance().getExperienceGainsGlobalMultiplier() < 1.0) { - globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") { - + globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") { @Override public int getValue() { return 1; @@ -215,27 +213,19 @@ public class MetricsManager { }); } else { - globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") { - + globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") { @Override public int getValue() { return 1; } }); } - globalMultiplierGraph.addPlotter(new Metrics.Plotter(Config.getInstance().getExperienceGainsGlobalMultiplier() + "") { - @Override - public int getValue() { - return 1; - } - }); //GlobalCurveModifier Fuzzy Logic Numbers Graph globalCurveMultiplierGraphFuzzy = metrics.createGraph("Global Curve Multiplier Fuzz"); if (Config.getInstance().getFormulaMultiplierCurve() > 20.0) { - globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") { - + globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") { @Override public int getValue() { return 1; @@ -243,8 +233,7 @@ public class MetricsManager { }); } else if (Config.getInstance().getFormulaMultiplierCurve() < 20.0) { - globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") { - + globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") { @Override public int getValue() { return 1; @@ -252,8 +241,7 @@ public class MetricsManager { }); } else { - globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") { - + globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") { @Override public int getValue() { return 1; From 7e1eeb66d656c3dd973a85a7bc3f4142e4dfbec8 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Sat, 23 Feb 2013 00:05:28 -0500 Subject: [PATCH 023/137] Use -U if you want snapshot updates --- pom.xml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/pom.xml b/pom.xml index ae3836756..1ee4ef445 100755 --- a/pom.xml +++ b/pom.xml @@ -129,29 +129,14 @@ - - true - always - fail - bukkit-repo http://repo.bukkit.org/content/groups/public/ - - true - always - fail - spout-repo http://nexus.spout.org/content/groups/public/ - - true - always - fail - Plugin MetricsExtension http://repo.turt2live.com From 8d16c06739ad25950224bf69f11d8e9e20524f36 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 23 Feb 2013 00:29:25 -0500 Subject: [PATCH 024/137] Don't make a new metadata value for every block every time. --- .../java/com/gmail/nossr50/listeners/BlockListener.java | 8 ++++---- .../java/com/gmail/nossr50/listeners/EntityListener.java | 5 +---- src/main/java/com/gmail/nossr50/mcMMO.java | 8 +++++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 269bbed25..15678e380 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -18,7 +18,6 @@ import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; @@ -62,13 +61,14 @@ public class BlockListener implements Listener { */ @EventHandler(priority = EventPriority.MONITOR) public void onBlockPistonExtend(BlockPistonExtendEvent event) { + List blocks = event.getBlocks(); BlockFace direction = event.getDirection(); Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished for (Block b : blocks) { if (mcMMO.placeStore.isTrue(b)) { - b.getRelative(direction).setMetadata("pistonTrack", new FixedMetadataValue(plugin, true)); + b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.blockMetadata); if (b.equals(futureEmptyBlock)) { mcMMO.placeStore.setFalse(b); } @@ -76,9 +76,9 @@ public class BlockListener implements Listener { } for (Block b : blocks) { - if (b.getRelative(direction).hasMetadata("pistonTrack")) { + if (b.getRelative(direction).hasMetadata(mcMMO.blockMetadataKey)) { mcMMO.placeStore.setTrue(b.getRelative(direction)); - b.getRelative(direction).removeMetadata("pistonTrack", plugin); + b.getRelative(direction).removeMetadata(mcMMO.blockMetadataKey, plugin); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index d3da6d84e..b1c2d925a 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -301,10 +301,7 @@ public class EntityListener implements Listener { */ @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { - if (Misc.isSpawnerXPEnabled) { - return; - } - else if (event.getEntity() == null) { + if (Misc.isSpawnerXPEnabled || event.getEntity() == null) { return; } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 47236aa1e..095f184ef 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -94,6 +94,10 @@ public class mcMMO extends JavaPlugin { public static FixedMetadataValue entityMetadata; public final static String entityMetadataKey = "mcMMO: Spawned Entity"; + // Block Metadata Values + public static FixedMetadataValue blockMetadata; + public final static String blockMetadataKey = "mcMMO: Piston Tracking"; + /** * Things to be run when the plugin is enabled. */ @@ -102,7 +106,9 @@ public class mcMMO extends JavaPlugin { try { p = this; getLogger().setFilter(new LogFilter(this)); - entityMetadata = new FixedMetadataValue(mcMMO.p, true); + entityMetadata = new FixedMetadataValue(this, true); + blockMetadata = new FixedMetadataValue(this, true); + setupFilePaths(); setupSpout(); loadConfigFiles(); From 301914d94bcf61889ed9705ef355c2f2fc9fb2a4 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 23 Feb 2013 15:03:39 -0500 Subject: [PATCH 025/137] Fix ClassCastException with trying to use Woodcutting on Mushrooms. --- .../skills/woodcutting/TreeFeller.java | 39 ++++++++----------- .../skills/woodcutting/Woodcutting.java | 7 +++- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java index 4f3abeb1d..9c767f705 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java @@ -177,22 +177,14 @@ public final class TreeFeller { Material material = blockState.getType(); - switch (material) { - case HUGE_MUSHROOM_1: - case HUGE_MUSHROOM_2: + if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) { xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); for (ItemStack drop : blockState.getBlock().getDrops()) { Misc.dropItem(blockState.getLocation(), drop); } - - break; - - default: - break; } - - if (ModChecks.isCustomLogBlock(blockState)) { + else if (ModChecks.isCustomLogBlock(blockState)) { Woodcutting.checkForDoubleDrop(player, blockState); CustomBlock customBlock = ModChecks.getCustomBlock(blockState); @@ -211,21 +203,22 @@ public final class TreeFeller { else if (ModChecks.isCustomLeafBlock(blockState)) { Misc.randomDropItem(blockState.getLocation(), ModChecks.getCustomBlock(blockState).getItemDrop(), 10); } + else { + Tree tree = (Tree) blockState.getData(); + switch (material) { + case LOG: + Woodcutting.checkForDoubleDrop(player, blockState); + xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); + Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData())); + break; - Tree tree = (Tree) blockState.getData(); - switch (material) { - case LOG: - Woodcutting.checkForDoubleDrop(player, blockState); - xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); - Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData())); - break; + case LEAVES: + Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10); + break; - case LEAVES: - Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10); - break; - - default: - break; + default: + break; + } } blockState.setRawData((byte) 0x0); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index 5c1f0e788..d1d834c5b 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.skills.woodcutting; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; @@ -61,7 +62,11 @@ public final class Woodcutting { int xp = getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); if (Permissions.doubleDrops(player, SkillType.WOODCUTTING)) { - checkForDoubleDrop(player, blockState); + Material blockType = blockState.getType(); + + if (blockType != Material.HUGE_MUSHROOM_1 && blockType != Material.HUGE_MUSHROOM_2) { + checkForDoubleDrop(player, blockState); + } } Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp); From aba662e3d0c70603bd28a9a039939f8292cfdb7c Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 23 Feb 2013 15:25:49 -0500 Subject: [PATCH 026/137] Fix for exploiting new Super Breaker enchants using the anvil. --- .../gmail/nossr50/listeners/InventoryListener.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 605ef998d..ca72abbc0 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -3,22 +3,27 @@ package com.gmail.nossr50.listeners; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Furnace; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; +import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.event.inventory.FurnaceExtractEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.FurnaceInventory; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.skills.smelting.SmeltingManager; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Users; @@ -128,4 +133,11 @@ public class InventoryListener implements Listener{ } } } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onInventoryClickEvent(InventoryClickEvent event) { + if (event.getInventory() instanceof AnvilInventory) { + SkillTools.removeAbilityBuff(event.getCurrentItem()); + } + } } From 3036d4fa9097800373d706a8e05764b8cc240da2 Mon Sep 17 00:00:00 2001 From: Glitchfinder Date: Sat, 23 Feb 2013 13:51:21 -0800 Subject: [PATCH 027/137] Fixing an IllegalArgumentException related to custom repair configs. --- src/main/java/com/gmail/nossr50/config/ConfigLoader.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index f5d18a530..6d1620e63 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -46,7 +46,13 @@ public abstract class ConfigLoader { } config = YamlConfiguration.loadConfiguration(configFile); - FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName)); + InputStream resource = plugin.getResource(fileName); + + if (resource == null) { + return; + } + + FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(resource); Set configKeys = config.getKeys(true); Set internalConfigKeys = internalConfig.getKeys(true); From 38155e3af42e1453aae99c38e1008b3d6e508a8e Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 23 Feb 2013 18:13:12 -0500 Subject: [PATCH 028/137] Use the same MetadataValue for both of these --- .../com/gmail/nossr50/listeners/BlockListener.java | 2 +- .../com/gmail/nossr50/listeners/EntityListener.java | 4 ++-- src/main/java/com/gmail/nossr50/mcMMO.java | 10 +++------- .../skills/taming/CallOfTheWildEventHandler.java | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 15678e380..f4cc8ee7f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -68,7 +68,7 @@ public class BlockListener implements Listener { for (Block b : blocks) { if (mcMMO.placeStore.isTrue(b)) { - b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.blockMetadata); + b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue); if (b.equals(futureEmptyBlock)) { mcMMO.placeStore.setFalse(b); } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index b1c2d925a..cd3d7a3e8 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -67,7 +67,7 @@ public class EntityListener implements Listener { if (mcMMO.placeStore.isTrue(block) && !entity.hasMetadata(mcMMO.entityMetadataKey)) { mcMMO.placeStore.setFalse(block); - entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.entityMetadata); + entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); } else if (entity.hasMetadata(mcMMO.entityMetadataKey)) { mcMMO.placeStore.setTrue(block); @@ -308,7 +308,7 @@ public class EntityListener implements Listener { SpawnReason reason = event.getSpawnReason(); if (reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) { - event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.entityMetadata); + event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 095f184ef..5fb634214 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -90,12 +90,9 @@ public class mcMMO extends JavaPlugin { // XP Event Check private boolean xpEventEnabled = false; - // Entity Metadata Values - public static FixedMetadataValue entityMetadata; + // Metadata Values + public static FixedMetadataValue metadataValue; public final static String entityMetadataKey = "mcMMO: Spawned Entity"; - - // Block Metadata Values - public static FixedMetadataValue blockMetadata; public final static String blockMetadataKey = "mcMMO: Piston Tracking"; /** @@ -106,8 +103,7 @@ public class mcMMO extends JavaPlugin { try { p = this; getLogger().setFilter(new LogFilter(this)); - entityMetadata = new FixedMetadataValue(this, true); - blockMetadata = new FixedMetadataValue(this, true); + metadataValue = new FixedMetadataValue(this, true); setupFilePaths(); setupSpout(); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java index a253b1d24..02ad5a499 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java @@ -67,7 +67,7 @@ public class CallOfTheWildEventHandler { return; LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type); - entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.entityMetadata); + entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); ((Tameable) entity).setOwner(player); From 20970e430ce4f074d35adc5a05f4b3f090c009f6 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 23 Feb 2013 18:14:15 -0500 Subject: [PATCH 029/137] Remove unused imports. --- .../java/com/gmail/nossr50/listeners/InventoryListener.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index ca72abbc0..385201cd9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -3,9 +3,7 @@ package com.gmail.nossr50.listeners; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Furnace; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; -import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; From 9759224690f9593926dc4718fd865c9b8bf6c7d8 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 23 Feb 2013 21:29:15 -0500 Subject: [PATCH 030/137] Changed our custom chat events to be async --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java | 1 + 2 files changed, 2 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index 1188a4184..f1caec032 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -73,6 +73,7 @@ Version 1.4.00-dev = Fixed a bug where a new party leader wasn't appointed, after the previous party leader left = Fixed a bug where Disarm and Deflect had wrong values = Fixed Magic Hunter (Fishing ability) favoring certain enchants + ! Changed our custom chat events to be async ! Changed some config value key names regarding double drops and XP - make sure you copy any custom values to your new config after updating. ! Changed Green Terra blocks to be determined via permissions instead of the config file ! Config files are now backed up even when running in SQL mode diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java index 618cb70fa..d6c7ec6e8 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java @@ -13,6 +13,7 @@ public abstract class McMMOChatEvent extends Event implements Cancellable { private String message; protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) { + super(true); this.plugin = plugin; this.sender = sender; this.displayName = displayName; From 54ca6e78f5f186a95530940f5b5f4333b6c429bb Mon Sep 17 00:00:00 2001 From: NuclearW Date: Sun, 24 Feb 2013 00:01:01 -0500 Subject: [PATCH 031/137] Revert "Fixing an IllegalArgumentException related to custom repair configs." This reverts commit 3036d4fa9097800373d706a8e05764b8cc240da2. --- src/main/java/com/gmail/nossr50/config/ConfigLoader.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index 6d1620e63..f5d18a530 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -46,13 +46,7 @@ public abstract class ConfigLoader { } config = YamlConfiguration.loadConfiguration(configFile); - InputStream resource = plugin.getResource(fileName); - - if (resource == null) { - return; - } - - FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(resource); + FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName)); Set configKeys = config.getKeys(true); Set internalConfigKeys = internalConfig.getKeys(true); From 3b05bb96e36af09bf58f84f3bd49938d7826d807 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Sun, 24 Feb 2013 00:18:01 -0500 Subject: [PATCH 032/137] Change for only advanced.yml and config.yml to be auto-updated --- .../gmail/nossr50/config/AdvancedConfig.java | 2 +- .../config/AutoUpdateConfigLoader.java | 128 ++++++++++++++++++ .../java/com/gmail/nossr50/config/Config.java | 3 +- .../gmail/nossr50/config/ConfigLoader.java | 98 -------------- 4 files changed, 131 insertions(+), 100 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 1d56239ef..214ea0fdb 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.config; -public class AdvancedConfig extends ConfigLoader { +public class AdvancedConfig extends AutoUpdateConfigLoader { private static AdvancedConfig instance; private AdvancedConfig() { diff --git a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java new file mode 100644 index 000000000..74e84cc4f --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java @@ -0,0 +1,128 @@ +package com.gmail.nossr50.config; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import com.gmail.nossr50.util.metrics.MetricsManager; + +public abstract class AutoUpdateConfigLoader extends ConfigLoader { + public AutoUpdateConfigLoader(String relativePath, String fileName) { + super(relativePath, fileName); + } + + public AutoUpdateConfigLoader(String fileName) { + super(fileName); + } + + @Override + protected void loadFile() { + super.loadFile(); + FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName)); + + Set configKeys = config.getKeys(true); + Set internalConfigKeys = internalConfig.getKeys(true); + + boolean needSave = false; + + Set oldKeys = new HashSet(configKeys); + oldKeys.removeAll(internalConfigKeys); + + Set newKeys = new HashSet(internalConfigKeys); + newKeys.removeAll(configKeys); + + // Don't need a re-save if we have old keys sticking around? + // Would be less saving, but less... correct? + if (!newKeys.isEmpty() || !oldKeys.isEmpty()) { + needSave = true; + } + + for (String key : oldKeys) { + plugin.debug("Removing unused key: " + key); + config.set(key, null); + } + + for (String key : newKeys) { + plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key)); + config.set(key, internalConfig.get(key)); + } + + if (needSave) { + // Get Bukkit's version of an acceptable config with new keys, and no old keys + String output = config.saveToString(); + + // Convert to the superior 4 space indentation + output = output.replace(" ", " "); + + // Rip out Bukkit's attempt to save comments at the top of the file + while (output.indexOf('#') != -1) { + output = output.substring(output.indexOf('\n', output.indexOf('#'))+1); + } + + // Read the internal config to get comments, then put them in the new one + try { + // Read internal + BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName))); + HashMap comments = new HashMap(); + String temp = ""; + + String line; + while ((line = reader.readLine()) != null) { + if (line.contains("#")) { + temp += line + "\n"; + } + else if (line.contains(":")) { + line = line.substring(0, line.indexOf(":") + 1); + if(!temp.isEmpty()) { + comments.put(line, temp); + temp = ""; + } + } + } + + // Dump to the new one + for (String key : comments.keySet()) { + if (output.indexOf(key) != -1) { + output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key)); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + + // Save it + try { + String saveName = fileName; + // At this stage we cannot guarantee that Config has been loaded, so we do the check directly here + if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) { + saveName += ".new"; + } + + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName))); + writer.write(output); + writer.flush(); + writer.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + else { + for (String key : configKeys) { + if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) { + MetricsManager.customConfig(); + break; + } + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 3a03bbbe6..18f337de0 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -10,7 +10,7 @@ import com.gmail.nossr50.skills.utilities.AbilityType; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.StringUtils; -public class Config extends ConfigLoader { +public class Config extends AutoUpdateConfigLoader { private static Config instance; private Config() { @@ -45,6 +45,7 @@ public class Config extends ConfigLoader { public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); } public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); } public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); } + public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); } public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); } diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index f5d18a530..b85bf6a53 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -46,104 +46,6 @@ public abstract class ConfigLoader { } config = YamlConfiguration.loadConfiguration(configFile); - FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName)); - - Set configKeys = config.getKeys(true); - Set internalConfigKeys = internalConfig.getKeys(true); - - boolean needSave = false; - - Set oldKeys = new HashSet(configKeys); - oldKeys.removeAll(internalConfigKeys); - - Set newKeys = new HashSet(internalConfigKeys); - newKeys.removeAll(configKeys); - - // Don't need a re-save if we have old keys sticking around? - // Would be less saving, but less... correct? - if (!newKeys.isEmpty() || !oldKeys.isEmpty()) { - needSave = true; - } - - for (String key : oldKeys) { - plugin.debug("Removing unused key: " + key); - config.set(key, null); - } - - for (String key : newKeys) { - plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key)); - config.set(key, internalConfig.get(key)); - } - - if (needSave) { - // Get Bukkit's version of an acceptable config with new keys, and no old keys - String output = config.saveToString(); - - // Convert to the superior 4 space indentation - output = output.replace(" ", " "); - - // Rip out Bukkit's attempt to save comments at the top of the file - while (output.indexOf('#') != -1) { - output = output.substring(output.indexOf('\n', output.indexOf('#'))+1); - } - - // Read the internal config to get comments, then put them in the new one - try { - // Read internal - BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName))); - HashMap comments = new HashMap(); - String temp = ""; - - String line; - while ((line = reader.readLine()) != null) { - if (line.contains("#")) { - temp += line + "\n"; - } - else if (line.contains(":")) { - line = line.substring(0, line.indexOf(":") + 1); - if(!temp.isEmpty()) { - comments.put(line, temp); - temp = ""; - } - } - } - - // Dump to the new one - for (String key : comments.keySet()) { - if (output.indexOf(key) != -1) { - output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key)); - } - } - } - catch (Exception e) { - e.printStackTrace(); - } - - // Save it - try { - String saveName = fileName; - // At this stage we cannot guarantee that Config has been loaded, so we do the check directly here - if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) { - saveName += ".new"; - } - - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName))); - writer.write(output); - writer.flush(); - writer.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - else { - for (String key : configKeys) { - if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) { - MetricsManager.customConfig(); - break; - } - } - } } protected abstract void loadKeys(); From e9dcb3100278ae2ccb92598f8e05ace2ebd903e2 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 13:25:35 -0500 Subject: [PATCH 033/137] Fixed issue with async chatting. Closes #731 --- .../java/com/gmail/nossr50/chat/ChatManager.java | 16 ++++++++++++---- .../nossr50/chat/commands/AdminChatCommand.java | 6 ++---- .../nossr50/events/chat/McMMOAdminChatEvent.java | 4 ++++ .../nossr50/events/chat/McMMOChatEvent.java | 9 ++++++++- .../nossr50/events/chat/McMMOPartyChatEvent.java | 5 +++++ .../gmail/nossr50/listeners/PlayerListener.java | 4 ++-- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/chat/ChatManager.java b/src/main/java/com/gmail/nossr50/chat/ChatManager.java index e0df7c055..989d5feca 100644 --- a/src/main/java/com/gmail/nossr50/chat/ChatManager.java +++ b/src/main/java/com/gmail/nossr50/chat/ChatManager.java @@ -14,8 +14,8 @@ import com.gmail.nossr50.party.Party; public final class ChatManager { public ChatManager () {} - public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) { - McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message); + public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) { + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync); mcMMO.p.getServer().getPluginManager().callEvent(chatEvent); if (chatEvent.isCancelled()) { @@ -36,10 +36,14 @@ public final class ChatManager { handleAdminChat(plugin, senderName, senderName, message); } - public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) { + public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) { + handleAdminChat(plugin, playerName, displayName, message, false); + } + + public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message, boolean isAsync) { String partyName = party.getName(); - McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message); + McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message, isAsync); mcMMO.p.getServer().getPluginManager().callEvent(chatEvent); if (chatEvent.isCancelled()) { @@ -63,4 +67,8 @@ public final class ChatManager { public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) { handlePartyChat(plugin, party, senderName, senderName, message); } + + public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) { + handlePartyChat(plugin, party, playerName, displayName, message, false); + } } diff --git a/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java b/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java index 9b4a2025d..ccbad7c99 100644 --- a/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java +++ b/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java @@ -15,14 +15,12 @@ public class AdminChatCommand extends ChatCommand { @Override protected void handleChatSending(CommandSender sender, String[] args) { - String message = buildChatMessage(args, 0); - if (sender instanceof Player) { Player player = (Player) sender; - ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), message); + ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), buildChatMessage(args, 0)); } else { - ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), message); + ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 0)); } } } diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java index 2d33c4d1b..089a5917f 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java @@ -9,4 +9,8 @@ public class McMMOAdminChatEvent extends McMMOChatEvent { public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) { super(plugin, sender, displayName, message); } + + public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { + super(plugin, sender, displayName, message, isAsync); + } } diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java index d6c7ec6e8..d0a94f22f 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java @@ -13,7 +13,14 @@ public abstract class McMMOChatEvent extends Event implements Cancellable { private String message; protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) { - super(true); + this.plugin = plugin; + this.sender = sender; + this.displayName = displayName; + this.message = message; + } + + protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { + super(isAsync); this.plugin = plugin; this.sender = sender; this.displayName = displayName; diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java index 7e03dc644..ffa54f815 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java @@ -13,6 +13,11 @@ public class McMMOPartyChatEvent extends McMMOChatEvent { this.party = party; } + public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message, boolean isAsync) { + super(plugin, sender, displayName, message, isAsync); + this.party = party; + } + /** * @return String name of the party the message will be sent to */ diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 96a8d95cc..86e6eebd4 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -427,11 +427,11 @@ public class PlayerListener implements Listener { return; } - ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), event.getMessage()); + ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), event.getMessage(), true); event.setCancelled(true); } else if (mcMMOPlayer.getAdminChatMode()) { - ChatManager.handleAdminChat(plugin, player.getName(), player.getDisplayName(), event.getMessage()); + ChatManager.handleAdminChat(plugin, player.getName(), player.getDisplayName(), event.getMessage(), true); event.setCancelled(true); } } From 214079a3cd745769223806c14561bc4cc8a77855 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Sun, 24 Feb 2013 13:56:24 -0500 Subject: [PATCH 034/137] Configuration options for particles --- .../java/com/gmail/nossr50/config/Config.java | 7 ++++++ .../nossr50/util/ParticleEffectUtils.java | 22 +++++++++++++++++++ src/main/resources/config.yml | 11 +++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 18f337de0..56fa64429 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -106,6 +106,13 @@ public class Config extends AutoUpdateConfigLoader { public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); } public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); } + /* Particles */ + public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); } + public boolean getAbilityDeactivationEffectEnabled() { return config.getBoolean("Particles.Ability_Deactivation", true); } + public boolean getDodgeEffectEnabled() { return config.getBoolean("Particles.Dodge", true); } + public boolean getBleedEffectEnabled() { return config.getBoolean("Particles.Bleed", true); } + public boolean getGreaterImpactEffectEnabled() { return config.getBoolean("Particles.Greater_Impact", true); } + /* PARTY SETTINGS */ public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); } public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); } diff --git a/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java b/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java index d38ab8b8f..79f9c1cb5 100644 --- a/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java @@ -14,15 +14,25 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.meta.FireworkMeta; +import com.gmail.nossr50.config.Config; + public final class ParticleEffectUtils { private ParticleEffectUtils() {}; public static void playBleedEffect(Player player) { + if (!Config.getInstance().getBleedEffectEnabled()) { + return; + } + player.getWorld().playEffect(player.getEyeLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE); } public static void playDodgeEffect(Player player) { + if (!Config.getInstance().getDodgeEffectEnabled()) { + return; + } + Location location = player.getEyeLocation(); World world = player.getWorld(); @@ -38,16 +48,28 @@ public final class ParticleEffectUtils { } public static void playGreaterImpactEffect(LivingEntity livingEntity) { + if (!Config.getInstance().getGreaterImpactEffectEnabled()) { + return; + } + Location location = livingEntity.getEyeLocation(); livingEntity.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false); } public static void playAbilityEnabledEffect(Player player) { + if (!Config.getInstance().getAbilityActivationEffectEnabled()) { + return; + } + fireworkParticleShower(player, Color.GREEN); } public static void playAbilityDisabledEffect(Player player) { + if (!Config.getInstance().getAbilityDeactivationEffectEnabled()) { + return; + } + fireworkParticleShower(player, Color.RED); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0979873dd..0a3f32e7f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -355,4 +355,13 @@ Commands: Use_Display_Names: true a: #Allow mcMMO to use player display names in chat instead of their usernames - Use_Display_Names: true \ No newline at end of file + Use_Display_Names: true +# +# Settings for particles +### +Particles: + Ability_Activation: true + Ability_Deactivation: true + Dodge: true + Bleed: true + Greater_Impact: true From 9659ef65b980efb56e56059b106b8baa5c9d35ce Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 13:32:33 -0500 Subject: [PATCH 035/137] Remove unused imports. --- src/main/java/com/gmail/nossr50/config/ConfigLoader.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index b85bf6a53..d12968216 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -1,22 +1,14 @@ package com.gmail.nossr50.config; -import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; -import java.io.FileWriter; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.metrics.MetricsManager; public abstract class ConfigLoader { protected static final mcMMO plugin = mcMMO.p; From a485308fca5bc6984025899b9e5cdf739c1d5cdd Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 13:37:56 -0500 Subject: [PATCH 036/137] Yes, we do. --- src/main/java/com/gmail/nossr50/config/AdvancedConfig.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 214ea0fdb..91a270c1b 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -17,9 +17,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { } @Override - protected void loadKeys() { - // TODO Do we need to use this? - } + protected void loadKeys() {} /* GENERAL */ public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); } From 5cd542002e10b7ad4f49217fd09fb2925fcaf50f Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 14:04:54 -0500 Subject: [PATCH 037/137] Only remove seed on greenThumb - Green Terra's already had the seed removed the first time. --- .../nossr50/skills/herbalism/Herbalism.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 9c3f44fbf..27450291d 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -320,22 +320,19 @@ public class Herbalism { * @return true if the ability was successful, false otherwise */ private static boolean processGreenThumbPlants(BlockState blockState, Player player) { - PlayerInventory playerInventory = player.getInventory(); - ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); - - if (!playerInventory.containsAtLeast(seed, 1)) { - return false; - } - PlayerProfile playerProfile = Users.getPlayer(player).getProfile(); if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) { - playerInventory.removeItem(seed); - player.updateInventory(); // Needed until replacement available - return convertGreenTerraPlants(blockState); } else if (SkillTools.activationSuccessful(player, SkillType.HERBALISM, greenThumbMaxChance, greenThumbMaxLevel)) { + PlayerInventory playerInventory = player.getInventory(); + ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); + + if (!playerInventory.containsAtLeast(seed, 1)) { + return false; + } + playerInventory.removeItem(seed); player.updateInventory(); // Needed until replacement available From 1fe471b0057e0d5cd42b2f7d5f3c8c833b155fcf Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 15:32:33 -0500 Subject: [PATCH 038/137] Fix Green Thumb not removing seeds when only one was left. Also fixed Green Thumb not working on Cobblestone. --- src/main/java/com/gmail/nossr50/listeners/PlayerListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 86e6eebd4..6b075c69d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -353,10 +353,10 @@ public class PlayerListener implements Listener { /* GREEN THUMB CHECK */ if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(blockState)) { - heldItem.setAmount(heldItem.getAmount() - 1); + player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1)); if (Herbalism.processGreenThumbBlocks(blockState, player) && SkillTools.blockBreakSimulate(block, player, false)) { - blockState.update(); + blockState.update(true); } } From e716e38386da3e748739b164f2ec57ffc6339a91 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 16:31:01 -0500 Subject: [PATCH 039/137] Dividing by 4 was wrong. --- src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 27450291d..b9079540e 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -274,7 +274,7 @@ public class Herbalism { * @return true if the ability was successful, false otherwise */ private static boolean convertGreenThumbPlants(BlockState blockState, int skillLevel) { - int greenThumbStage = Math.min(skillLevel, greenThumbStageMaxLevel) / 4; + int greenThumbStage = Math.min(skillLevel, greenThumbStageMaxLevel) / greenThumbStageChangeLevel; switch(blockState.getType()) { case CROPS: From 1eb225cae181d0d353630345bfcf1fbe9f7060df Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 16:35:33 -0500 Subject: [PATCH 040/137] Stages are capped at 4. --- src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index b9079540e..5599a23bf 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -274,7 +274,7 @@ public class Herbalism { * @return true if the ability was successful, false otherwise */ private static boolean convertGreenThumbPlants(BlockState blockState, int skillLevel) { - int greenThumbStage = Math.min(skillLevel, greenThumbStageMaxLevel) / greenThumbStageChangeLevel; + int greenThumbStage = Math.min(Math.min(skillLevel, greenThumbStageMaxLevel) / greenThumbStageChangeLevel, 4); switch(blockState.getType()) { case CROPS: From afe28d54c65f69e25f9bdadb7c96e2dd278c443a Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 23:49:55 -0500 Subject: [PATCH 041/137] Fix Herbalism not replanting crops properly. --- .../nossr50/listeners/BlockListener.java | 8 +- .../nossr50/skills/herbalism/Herbalism.java | 116 +++--------------- 2 files changed, 22 insertions(+), 102 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index f4cc8ee7f..f68f26033 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -165,13 +165,11 @@ public class BlockListener implements Listener { if (Permissions.skillEnabled(player, SkillType.HERBALISM)) { //Double drops - if (Herbalism.herbalismBlockCheck(blockState, player)) { - blockState.update(); - } + Herbalism.herbalismBlockCheck(blockState, player); //Triple drops - if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && Herbalism.herbalismBlockCheck(blockState, player)) { - blockState.update(); + if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) { + Herbalism.herbalismBlockCheck(blockState, player); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 5599a23bf..5594e515f 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.herbalism; import java.util.ArrayList; import java.util.List; -import org.bukkit.CropState; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -13,8 +12,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import org.bukkit.material.CocoaPlant; -import org.bukkit.material.CocoaPlant.CocoaPlantSize; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; @@ -160,9 +157,9 @@ public class Herbalism { * @param player The {@link Player} using this ability * @return true if the ability was successful, false otherwise */ - public static boolean herbalismBlockCheck(BlockState blockState, Player player) { + public static void herbalismBlockCheck(BlockState blockState, Player player) { if (Config.getInstance().getHerbalismAFKDisabled() && player.isInsideVehicle()) { - return false; + return; } Material blockType = blockState.getType(); @@ -173,7 +170,6 @@ public class Herbalism { int xp = 0; int dropAmount = 1; ItemStack dropItem = null; - boolean update = false; if (herbalismBlock != null) { if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) { @@ -184,7 +180,7 @@ public class Herbalism { else if (herbalismBlock.hasGreenThumbPermission(player)){ dropItem = herbalismBlock.getDropItem(); xp = herbalismBlock.getXpGain(); - update = processGreenThumbPlants(blockState, player); + processGreenThumbPlants(blockState, player); } else { if (!mcMMO.placeStore.isTrue(blockState)) { @@ -218,36 +214,6 @@ public class Herbalism { } Users.getPlayer(player).beginXpGain(SkillType.HERBALISM, xp); - return update; - } - - /** - * Convert plants affected by the Green Terra ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @return true if the ability was successful, false otherwise - */ - private static boolean convertGreenTerraPlants(BlockState blockState) { - switch (blockState.getType()) { - case CROPS: - case CARROT: - case POTATO: - blockState.setRawData(CropState.MEDIUM.getData()); - return true; - - case NETHER_WARTS: - blockState.setRawData((byte) 0x2); - return true; - - case COCOA: - CocoaPlant plant = (CocoaPlant) blockState.getData(); - plant.setSize(CocoaPlantSize.MEDIUM); - blockState.setData(plant); - return true; - - default: - return false; - } } /** @@ -266,80 +232,36 @@ public class Herbalism { return convertGreenTerraBlocks(blockState, player); } - /** - * Convert plants affected by the Green Thumb ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param skillLevel The player's Herbalism skill level - * @return true if the ability was successful, false otherwise - */ - private static boolean convertGreenThumbPlants(BlockState blockState, int skillLevel) { - int greenThumbStage = Math.min(Math.min(skillLevel, greenThumbStageMaxLevel) / greenThumbStageChangeLevel, 4); - - switch(blockState.getType()) { - case CROPS: - case CARROT: - case POTATO: - blockState.setRawData((byte) greenThumbStage); - return true; - - case NETHER_WARTS: - if (greenThumbStage > 2) { - blockState.setRawData((byte) 0x2); - } - else if (greenThumbStage == 2) { - blockState.setRawData((byte) 0x1); - } - else { - blockState.setRawData((byte) 0x0); - } - return true; - - case COCOA: - CocoaPlant plant = (CocoaPlant) blockState.getData(); - - if (greenThumbStage > 1) { - plant.setSize(CocoaPlantSize.MEDIUM); - } - else { - plant.setSize(CocoaPlantSize.SMALL); - } - blockState.setData(plant); - return true; - - default: - return false; - } - } - /** * Process the Green Thumb ability for plants. * * @param blockState The {@link BlockState} to check ability activation for * @param player The {@link Player} using this ability - * @return true if the ability was successful, false otherwise */ - private static boolean processGreenThumbPlants(BlockState blockState, Player player) { + private static void processGreenThumbPlants(BlockState blockState, Player player) { + PlayerInventory playerInventory = player.getInventory(); + ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); + + if (!playerInventory.containsAtLeast(seed, 1)) { + return; + } + PlayerProfile playerProfile = Users.getPlayer(player).getProfile(); if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) { - return convertGreenTerraPlants(blockState); - } - else if (SkillTools.activationSuccessful(player, SkillType.HERBALISM, greenThumbMaxChance, greenThumbMaxLevel)) { - PlayerInventory playerInventory = player.getInventory(); - ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); - - if (!playerInventory.containsAtLeast(seed, 1)) { - return false; - } - playerInventory.removeItem(seed); player.updateInventory(); // Needed until replacement available - return convertGreenThumbPlants(blockState, playerProfile.getSkillLevel(SkillType.HERBALISM)); + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimer(blockState), 0); + return; } + else if (SkillTools.activationSuccessful(player, SkillType.HERBALISM, greenThumbMaxChance, greenThumbMaxLevel)) { + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available - return false; + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimer(blockState, playerProfile.getSkillLevel(SkillType.HERBALISM)), 0); + return; + } } /** From ec8221610a471f9cb7fa065f2eb7c961dda9c866 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 23:57:30 -0500 Subject: [PATCH 042/137] Add a few more checks for sanity on the new ability buffs. --- .../java/com/gmail/nossr50/listeners/InventoryListener.java | 5 +---- .../java/com/gmail/nossr50/listeners/PlayerListener.java | 3 +++ .../java/com/gmail/nossr50/skills/utilities/SkillTools.java | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 385201cd9..75cae3f9f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -14,7 +14,6 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.FurnaceInventory; import org.bukkit.inventory.ItemStack; @@ -134,8 +133,6 @@ public class InventoryListener implements Listener{ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryClickEvent(InventoryClickEvent event) { - if (event.getInventory() instanceof AnvilInventory) { - SkillTools.removeAbilityBuff(event.getCurrentItem()); - } + SkillTools.removeAbilityBuff(event.getCurrentItem()); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 6b075c69d..a1e5d4449 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -146,7 +146,10 @@ public class PlayerListener implements Listener { if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) { event.setCancelled(true); + return; } + + SkillTools.removeAbilityBuff(event.getItemDrop().getItemStack()); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java index 5b6825123..d3203ba64 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java @@ -30,6 +30,7 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.spout.SpoutConfig; import com.gmail.nossr50.spout.SpoutTools; +import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ParticleEffectUtils; import com.gmail.nossr50.util.Permissions; @@ -544,6 +545,10 @@ public class SkillTools { return item; } + if (!ItemChecks.isPickaxe(item) && !ItemChecks.isShovel(item)) { + return item; + } + if (item.containsEnchantment(Enchantment.DIG_SPEED)) { ItemMeta itemMeta = item.getItemMeta(); From 219667965f40af819a6e56010f87046fe01f584b Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 07:23:18 -0500 Subject: [PATCH 043/137] Add a few checks to prevent a player from joining a party more than once. --- .../java/com/gmail/nossr50/party/PartyManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index ac5838c8a..a4e543e56 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -294,6 +294,10 @@ public final class PartyManager { return; } + if (mcMMOPlayer.getParty() == party) { + return; + } + player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName())); addToParty(player, mcMMOPlayer, party); } @@ -339,6 +343,10 @@ public final class PartyManager { public static void joinInvitedParty(Player player, McMMOPlayer mcMMOPlayer) { Party invite = mcMMOPlayer.getPartyInvite(); + if (mcMMOPlayer.getParty() == invite) { + return; + } + if (!parties.contains(invite)) { parties.add(invite); } @@ -356,6 +364,10 @@ public final class PartyManager { * @param party The party */ public static void addToParty(OfflinePlayer player, McMMOPlayer mcMMOPlayer, Party party) { + if (mcMMOPlayer.getParty() == party) { + return; + } + informPartyMembersJoin(player, party); mcMMOPlayer.setParty(party); party.getMembers().add(player); From da1e03cbfcb91ae664d313afc60cec6729a924ad Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 07:30:06 -0500 Subject: [PATCH 044/137] Eclipse is dumb and wasn't including these two files for some reason. --- .../skills/herbalism/GreenTerraTimer.java | 46 +++++++++++++ .../skills/herbalism/GreenThumbTimer.java | 64 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java create mode 100644 src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java new file mode 100644 index 000000000..b29c05c3e --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java @@ -0,0 +1,46 @@ +package com.gmail.nossr50.skills.herbalism; + +import org.bukkit.CropState; +import org.bukkit.block.BlockState; +import org.bukkit.material.CocoaPlant; +import org.bukkit.material.CocoaPlant.CocoaPlantSize; + +/** + * Convert plants affected by the Green Terra ability. + * + * @param blockState The {@link BlockState} to check ability activation for + */ +public class GreenTerraTimer implements Runnable { + private BlockState blockState; + + public GreenTerraTimer(BlockState blockState) { + this.blockState = blockState; + } + + @Override + public void run() { + switch (blockState.getType()) { + case CROPS: + case CARROT: + case POTATO: + blockState.setRawData(CropState.MEDIUM.getData()); + blockState.update(true); + return; + + case NETHER_WARTS: + blockState.setRawData((byte) 0x2); + blockState.update(true); + return; + + case COCOA: + CocoaPlant plant = (CocoaPlant) blockState.getData(); + plant.setSize(CocoaPlantSize.MEDIUM); + blockState.setData(plant); + blockState.update(true); + return; + + default: + return; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java new file mode 100644 index 000000000..1cd2b6301 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java @@ -0,0 +1,64 @@ +package com.gmail.nossr50.skills.herbalism; + +import org.bukkit.block.BlockState; +import org.bukkit.material.CocoaPlant; +import org.bukkit.material.CocoaPlant.CocoaPlantSize; + +/** + * Convert plants affected by the Green Thumb ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param skillLevel The player's Herbalism skill level + */ +public class GreenThumbTimer implements Runnable { + private BlockState blockState; + private int skillLevel; + + public GreenThumbTimer(BlockState blockState, int skillLevel) { + this.blockState = blockState; + this.skillLevel = skillLevel; + } + + @Override + public void run() { + int greenThumbStage = Math.min(Math.min(skillLevel, Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4); + + switch(blockState.getType()) { + case CROPS: + case CARROT: + case POTATO: + blockState.setRawData((byte) greenThumbStage); + blockState.update(true); + return; + + case NETHER_WARTS: + if (greenThumbStage > 2) { + blockState.setRawData((byte) 0x2); + } + else if (greenThumbStage == 2) { + blockState.setRawData((byte) 0x1); + } + else { + blockState.setRawData((byte) 0x0); + } + blockState.update(true); + return; + + case COCOA: + CocoaPlant plant = (CocoaPlant) blockState.getData(); + + if (greenThumbStage > 1) { + plant.setSize(CocoaPlantSize.MEDIUM); + } + else { + plant.setSize(CocoaPlantSize.SMALL); + } + blockState.setData(plant); + blockState.update(true); + return; + + default: + return; + } + } +} From 35139815a6813e20f03e5b9cc51fc57d3ce15a42 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Mon, 25 Feb 2013 13:42:11 +0100 Subject: [PATCH 045/137] Added alias for /party owner: "/party leader" --- .../com/gmail/nossr50/party/commands/PartySubcommandType.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java b/src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java index 925dd6d63..fa9432447 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java @@ -33,6 +33,9 @@ public enum PartySubcommandType { else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) { return QUIT; } + else if (commandName.equalsIgnoreCase("leader")) { + return OWNER; + } else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) { return EXPSHARE; } From ca8204d8f478ada16bb23f3bcd25f4f8c5c4453d Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Mon, 25 Feb 2013 13:56:24 +0100 Subject: [PATCH 046/137] Display 'leader' alias instead of 'owner' in /party help --- .../java/com/gmail/nossr50/party/commands/PartyHelpCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java index 9e63d4666..0531f6ffa 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java @@ -17,7 +17,7 @@ public class PartyHelpCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); - sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party owner")); + sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader")); sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); return true; From 19068dee0303cd5a1dac9cf9d4f25d9f970bb73e Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 08:01:06 -0500 Subject: [PATCH 047/137] Fix Tree Feller not working but still awarding XP. --- .../java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java | 2 +- .../java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java index 9c767f705..e382dc0db 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java @@ -223,7 +223,7 @@ public final class TreeFeller { blockState.setRawData((byte) 0x0); blockState.setType(Material.AIR); - blockState.update(); + blockState.update(true); } Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index d1d834c5b..1c36a8d19 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -146,7 +146,8 @@ public final class Woodcutting { } else { Location location = blockState.getLocation(); - ItemStack item = blockState.getData().toItemStack(); + Tree tree = (Tree) blockState.getData(); + ItemStack item = new ItemStack(Material.LOG, 1, tree.getSpecies().getData()); switch (((Tree) blockState.getData()).getSpecies()) { case GENERIC: From 9888fe6e096081eb3a42004b9c8b9a9d2c002045 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 08:02:35 -0500 Subject: [PATCH 048/137] We now need to watch these species too. --- .../java/com/gmail/nossr50/listeners/WorldListener.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java index 1460958c7..b4eef1ffb 100644 --- a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java @@ -5,7 +5,6 @@ import java.util.ArrayList; import org.bukkit.Chunk; import org.bukkit.Location; -import org.bukkit.TreeType; import org.bukkit.World; import org.bukkit.block.BlockState; import org.bukkit.event.EventHandler; @@ -29,12 +28,6 @@ public class WorldListener implements Listener { */ @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) public void onStructureGrow(StructureGrowEvent event) { - TreeType species = event.getSpecies(); - - if (species == TreeType.BROWN_MUSHROOM || species == TreeType.RED_MUSHROOM) { - return; - } - Location location = event.getLocation(); if (mcMMO.placeStore.isTrue(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld())) { From 52467075b432e7b0a42f2a844d3e8339408dc722 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 09:18:53 -0500 Subject: [PATCH 049/137] Need to force updates here. --- src/main/java/com/gmail/nossr50/listeners/BlockListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index f68f26033..0224ded51 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -237,14 +237,14 @@ public class BlockListener implements Listener { if (Permissions.hylianLuck(player) && ItemChecks.isSword(heldItem)) { if (Herbalism.processHylianLuck(blockState, player)) { + blockState.update(true); event.setCancelled(true); - blockState.update(); } } else if (BlockChecks.affectedByFluxMining(blockState) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState)) { if (Smelting.processFluxMining(blockState, player)) { + blockState.update(true); event.setCancelled(true); - blockState.update(); } } } From 3bd9a300551e1a0a27382c854642ce2442515d63 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 09:23:49 -0500 Subject: [PATCH 050/137] Javadoc fix --- src/main/java/com/gmail/nossr50/util/BlockChecks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index 29989cc2e..e769b381f 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -316,7 +316,7 @@ public final class BlockChecks { * Determine if a given block can activate Herbalism abilities * * @param blockState The {@link BlockState} of the block to check - * @return true if the block can be made mossy, false otherwise + * @return true if the block can be activate Herbalism abilities, false otherwise */ public static boolean canActivateHerbalism(BlockState blockState) { switch (blockState.getType()) { From 2373ca82badca87d9dfe3ebad19918d594f8ddcf Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 09:58:25 -0500 Subject: [PATCH 051/137] Added "Shroom Thumb" ability to Herbalism. Closes #724 --- Changelog.txt | 1 + .../gmail/nossr50/config/AdvancedConfig.java | 3 + .../nossr50/listeners/PlayerListener.java | 6 ++ .../nossr50/skills/herbalism/Herbalism.java | 59 +++++++++++++++++++ .../skills/herbalism/HerbalismCommand.java | 27 ++++++++- .../com/gmail/nossr50/util/BlockChecks.java | 17 ++++++ .../com/gmail/nossr50/util/Permissions.java | 1 + src/main/resources/advanced.yml | 5 ++ .../resources/locale/locale_en_US.properties | 4 ++ src/main/resources/plugin.yml | 3 + 10 files changed, 124 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index f1caec032..75bb0f930 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -39,6 +39,7 @@ Version 1.4.00-dev + Added ability for config files to automatically update with new keys, and prune out old ones + Added config option to make .new config files instead over writing over old ones when updating + Added "Holy Hound" ability to Taming + + Added "Shroom Thumb" ability to Herbalism = Fixed Green Thumb on wheat not working properly at rank 4 = Fixed Green Thumb and Green Terra consuming twice the amount of seed needed = Fixed Green Terra not also checking Green Thumb permissions diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 91a270c1b..9c2750fc4 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -111,6 +111,9 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); } public int getHylianLuckMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); } + public double getShroomThumbChanceMax() { return config.getDouble("Skills.Herbalism.ShroomThumb_ChanceMax", 50.0D); } + public int getShroomThumbMaxLevel() { return config.getInt("Skills.Herbalism.ShroomThumb_MaxBonusLevel", 1500); } + /* MINING */ public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); } public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index a1e5d4449..b5b136a2f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -363,6 +363,12 @@ public class PlayerListener implements Listener { } } + /* SHROOM THUMB CHECK */ + else if (BlockChecks.canMakeShroomy(blockState)) { + if (Herbalism.processGreenThumbBlocks(blockState, player) && SkillTools.blockBreakSimulate(block, player, false)) { + blockState.update(true); + } + } break; case RIGHT_CLICK_AIR: diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 5594e515f..61f69e361 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -27,6 +27,7 @@ import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class Herbalism { @@ -46,6 +47,9 @@ public class Herbalism { public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax(); public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel(); + public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax(); + public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel(); + /** * Handle the farmers diet skill. * @@ -314,4 +318,59 @@ public class Herbalism { player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); return true; } + + /** + * Process the Shroom Thumb ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + * @return true if the ability was successful, false otherwise + */ + public static boolean processShroomThumb(BlockState blockState, Player player) { + PlayerInventory playerInventory = player.getInventory(); + + if (!playerInventory.contains(Material.BROWN_MUSHROOM)) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM))); + return false; + } + + if (!playerInventory.contains(Material.RED_MUSHROOM)) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM))); + return false; + } + + playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM)); + playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM)); + player.updateInventory(); + + if (!SkillTools.activationSuccessful(player, SkillType.HERBALISM, shroomThumbMaxChance, shroomThumbMaxLevel)) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail")); + return false; + } + + return convertShroomThumb(blockState, player); + } + + /** + * Convert blocks affected by the Green Thumb & Green Terra abilities. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + * @return true if the ability was successful, false otherwise + */ + private static boolean convertShroomThumb(BlockState blockState, Player player) { + if (!Permissions.shroomThumb(player)) { + return false; + } + + switch (blockState.getType()){ + case DIRT: + case GRASS: + blockState.setType(Material.MYCEL); + return true; + + default: + return false; + } + } } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismCommand.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismCommand.java index 104c99c81..cf56d610e 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismCommand.java @@ -18,6 +18,8 @@ public class HerbalismCommand extends SkillCommand { private String doubleDropChanceLucky; private String hylianLuckChance; private String hylianLuckChanceLucky; + private String shroomThumbChance; + private String shroomThumbChanceLucky; private boolean hasHylianLuck; private boolean canGreenTerra; @@ -25,6 +27,7 @@ public class HerbalismCommand extends SkillCommand { private boolean canGreenThumbBlocks; private boolean canFarmersDiet; private boolean canDoubleDrop; + private boolean canShroomThumb; private boolean doubleDropsDisabled; public HerbalismCommand() { @@ -57,6 +60,11 @@ public class HerbalismCommand extends SkillCommand { String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance); hylianLuckChance = hylianLuckStrings[0]; hylianLuckChanceLucky = hylianLuckStrings[1]; + + //SHROOM THUMB + String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance); + shroomThumbChance = shroomThumbStrings[0]; + shroomThumbChanceLucky = shroomThumbStrings[1]; } @Override @@ -68,11 +76,12 @@ public class HerbalismCommand extends SkillCommand { canFarmersDiet = Permissions.farmersDiet(player); canDoubleDrop = Permissions.doubleDrops(player, skill); doubleDropsDisabled = skill.getDoubleDropsDisabled(); + canShroomThumb = Permissions.shroomThumb(player); } @Override protected boolean effectsHeaderPermissions() { - return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat; + return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb; } @Override @@ -99,6 +108,10 @@ public class HerbalismCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11"))); } + if (canShroomThumb) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13"))); + } + if (canDoubleDrop && !doubleDropsDisabled) { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9"))); } @@ -106,7 +119,7 @@ public class HerbalismCommand extends SkillCommand { @Override protected boolean statsHeaderPermissions() { - return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat; + return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb; } @Override @@ -145,6 +158,16 @@ public class HerbalismCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance)); } } + + if (canShroomThumb) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance)); + } + } + if (canDoubleDrop && !doubleDropsDisabled) { if (isLucky) { player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky)); diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index e769b381f..7265a1d11 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -345,4 +345,21 @@ public final class BlockChecks { return false; } } + + /** + * Determine if a given block can be made into Mycelium + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block can be made in Mycelium, false otherwise + */ + public static boolean canMakeShroomy(BlockState blockState) { + switch (blockState.getType()) { + case DIRT: + case GRASS: + return true; + + default: + return false; + } + } } diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index 46d907b75..b9371a0d1 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -146,6 +146,7 @@ public final class Permissions { public static boolean greenThumbBlock(Permissible permissible, Material material) { return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.blocks." + material.toString().replace("_", "").toLowerCase()); } public static boolean greenThumbPlant(Permissible permissible, Material material) { return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.plants." + material.toString().replace("_", "").toLowerCase()); } public static boolean hylianLuck(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.herbalism.hylianluck"); } + public static boolean shroomThumb(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.herbalism.shroomthumb"); } /* MINING */ public static boolean biggerBombs(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.mining.blastmining.biggerbombs"); } diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 982a771e8..39baed646 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -156,6 +156,11 @@ Skills: # HylianLuck_MaxBonusLevel: On this level, Hylian Luck chance will be HylianLuck_ChanceMax HylianLuck_ChanceMax: 10.0 HylianLuck_MaxBonusLevel: 1000 + + # ShroomThumb_ChanceMax: Maximum chance of ShroomThumb + # ShroomThumb_MaxBonusLevel: On this level, ShroomThumb chance will be ShroomThumb_ChanceMax + ShroomThumb_ChanceMax: 50.0 + ShroomThumb_MaxBonusLevel: 1500 # # Settings for Mining ### diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 9bdfe6e4d..12b685448 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -131,6 +131,8 @@ Herbalism.Ability.GTh=[[GREEN]]**GREEN THUMB** Herbalism.Ability.HylianLuck=[[RED]]Hylian Luck Chance: [[YELLOW]]{0} Herbalism.Ability.Lower=[[GRAY]]**YOU LOWER YOUR HOE** Herbalism.Ability.Ready=[[GREEN]]**YOU READY YOUR HOE** +Herbalism.Ability.ShroomThumb.Chance=[[RED]]Shroom Thumb Chance: [[YELLOW]]{0} +Herbalism.Ability.ShroomThumb.Fail=[[RED]]**SHROOM THUMB FAIL** Herbalism.Effect.0=Green Terra (ABILITY) Herbalism.Effect.1=Spread the Terra, 3x Drops Herbalism.Effect.2=Green Thumb (Wheat) @@ -143,6 +145,8 @@ Herbalism.Effect.8=Double Drops (All Herbs) Herbalism.Effect.9=Double the normal loot Herbalism.Effect.10=Hylian Luck Herbalism.Effect.11=Gives a small chance of finding rare items +Herbalism.Effect.12=Shroom Thumb +Herbalism.Effect.13=Spread mycelium to dirt & grass Herbalism.HylianLuck=[[GREEN]]The luck of Hyrule is with you today! Herbalism.Listener=Herbalism: Herbalism.SkillName=HERBALISM diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 98ed35871..99a00f362 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -277,6 +277,7 @@ permissions: mcmmo.ability.herbalism.greenterra: true mcmmo.ability.herbalism.greenthumb.all: true mcmmo.ability.herbalism.hylianluck: true + mcmmo.ability.herbalism.shroomthumb: true mcmmo.ability.herbalism.doubledrops: description: Allows double drop chance from Herbalism mcmmo.ability.herbalism.farmersdiet: @@ -368,6 +369,8 @@ permissions: mcmmo.ability.herbalism.greenthumb.plants.crops: true mcmmo.ability.herbalism.hylianluck: description: Allows access to the Hylian Luck ability + mcmmo.ability.herbalism.shroomthumb: + description: Allows access to the Shroom Thumb ability mcmmo.ability.mining.*: default: false description: Allows access to all Mining abilities From 26c2134484df0cd6b3afab52dd82a795d0ca8430 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 09:59:35 -0500 Subject: [PATCH 052/137] That's not the right function... --- src/main/java/com/gmail/nossr50/listeners/PlayerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index b5b136a2f..a55554c12 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -365,7 +365,7 @@ public class PlayerListener implements Listener { /* SHROOM THUMB CHECK */ else if (BlockChecks.canMakeShroomy(blockState)) { - if (Herbalism.processGreenThumbBlocks(blockState, player) && SkillTools.blockBreakSimulate(block, player, false)) { + if (Herbalism.processShroomThumb(blockState, player) && SkillTools.blockBreakSimulate(block, player, false)) { blockState.update(true); } } From 8001a928ea6a21a96b9ac74650a62bc2fbe16e1b Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 11:51:29 -0500 Subject: [PATCH 053/137] Ensure one type of mushroom is held before checking Shroom Terra. Fixes #734 --- src/main/java/com/gmail/nossr50/listeners/PlayerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index a55554c12..a5a30477f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -364,7 +364,7 @@ public class PlayerListener implements Listener { } /* SHROOM THUMB CHECK */ - else if (BlockChecks.canMakeShroomy(blockState)) { + else if ((heldItem.getType() == Material.RED_MUSHROOM || heldItem.getType() == Material.BROWN_MUSHROOM) && BlockChecks.canMakeShroomy(blockState)) { if (Herbalism.processShroomThumb(blockState, player) && SkillTools.blockBreakSimulate(block, player, false)) { blockState.update(true); } From 4c10fdf34a917ffda9feffd51e003f4b8cbb7881 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Mon, 25 Feb 2013 16:00:09 -0500 Subject: [PATCH 054/137] Use Debug Filter here --- src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java index e16ea35e6..af677f2cc 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java @@ -81,7 +81,7 @@ public enum SkillType { } } - mcMMO.p.getLogger().warning("[DEBUG] Invalid mcMMO skill (" + skillName + ")"); + mcMMO.p.getLogger().warning("[Debug] Invalid mcMMO skill (" + skillName + ")"); return null; } From 21b8626366fabb8439d7751b806697ae68ae533a Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 16:54:29 -0500 Subject: [PATCH 055/137] Put our managers on payroll, rather than firing them at the end of their shift. --- .../nossr50/listeners/EntityListener.java | 12 +-- .../nossr50/listeners/InventoryListener.java | 11 +-- .../nossr50/listeners/PlayerListener.java | 15 ++-- .../gmail/nossr50/skills/SkillManager.java | 15 +++- .../skills/archery/ArcheryManager.java | 2 +- .../nossr50/skills/mining/MiningManager.java | 4 +- .../skills/smelting/SmeltingManager.java | 2 +- .../nossr50/skills/swords/SwordsManager.java | 4 +- .../nossr50/skills/taming/TamingManager.java | 2 +- .../skills/unarmed/UnarmedManager.java | 4 +- .../nossr50/skills/utilities/CombatTools.java | 74 ++++++++----------- 11 files changed, 65 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index cd3d7a3e8..c8c9799b2 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -32,15 +32,14 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.acrobatics.Acrobatics; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.mining.BlastMining; -import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.taming.Taming; -import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.utilities.CombatTools; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -328,8 +327,7 @@ public class EntityListener implements Listener { Player player = plugin.getTNTPlayer(id); if (Permissions.biggerBombs(player)) { - MiningManager miningManager = new MiningManager(Users.getPlayer(player)); - miningManager.biggerBombs(event); + SkillManagerStore.getInstance().getMiningManager(player.getName()).biggerBombs(event); } } } @@ -350,8 +348,7 @@ public class EntityListener implements Listener { if (plugin.tntIsTracked(id)) { Player player = plugin.getTNTPlayer(id); - MiningManager miningManager = new MiningManager(Users.getPlayer(player)); - miningManager.blastMiningDropProcessing(event); + SkillManagerStore.getInstance().getMiningManager(player.getName()).blastMiningDropProcessing(event); plugin.removeFromTNTTracker(id); } @@ -430,8 +427,7 @@ public class EntityListener implements Listener { return; } - TamingManager tamingManager = new TamingManager(Users.getPlayer(player)); - tamingManager.awardTamingXP(event); + SkillManagerStore.getInstance().getTamingManager(player.getName()).awardTamingXP(event); } @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 75cae3f9f..b127aed13 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -19,7 +19,7 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.skills.smelting.SmeltingManager; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Users; @@ -84,8 +84,7 @@ public class InventoryListener implements Listener{ Player player = plugin.getFurnacePlayer(furnaceBlock); if (player != null) { - SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player)); - smeltingManager.fuelEfficiency(event); + SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event); } } } @@ -104,8 +103,7 @@ public class InventoryListener implements Listener{ Player player = plugin.getFurnacePlayer(furnaceBlock); if (player != null) { - SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player)); - smeltingManager.smeltProcessing(event); + SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event); } } } @@ -124,8 +122,7 @@ public class InventoryListener implements Listener{ McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer()); if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) { - SmeltingManager smeltingManager = new SmeltingManager(mcMMOPlayer); - smeltingManager.vanillaXPBoost(event); + SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index a5a30477f..a039fd5a0 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -34,14 +34,13 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.mining.BlastMining; -import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.utilities.AbilityType; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; @@ -296,8 +295,7 @@ public class PlayerListener implements Listener { } /* BLAST MINING CHECK */ else if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) { - MiningManager miningManager = new MiningManager(Users.getPlayer(player)); - miningManager.detonate(event); + SkillManagerStore.getInstance().getMiningManager(player.getName()).detonate(event); } break; @@ -305,8 +303,7 @@ public class PlayerListener implements Listener { case RIGHT_CLICK_AIR: /* BLAST MINING CHECK */ if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) { - MiningManager miningManager = new MiningManager(Users.getPlayer(player)); - miningManager.detonate(event); + SkillManagerStore.getInstance().getMiningManager(player.getName()).detonate(event); } break; @@ -397,12 +394,10 @@ public class PlayerListener implements Listener { Material type = heldItem.getType(); if (type == Material.RAW_FISH) { - TamingManager tamingManager = new TamingManager(Users.getPlayer(player)); - tamingManager.summonOcelot(); + SkillManagerStore.getInstance().getTamingManager(player.getName()).summonOcelot(); } else if (type == Material.BONE) { - TamingManager tamingManager = new TamingManager(Users.getPlayer(player)); - tamingManager.summonWolf(); + SkillManagerStore.getInstance().getTamingManager(player.getName()).summonWolf(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManager.java b/src/main/java/com/gmail/nossr50/skills/SkillManager.java index f020a8af6..71a2cdbb3 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManager.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManager.java @@ -1,18 +1,19 @@ package com.gmail.nossr50.skills; +import org.bukkit.entity.Player; + import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.skills.utilities.PerksUtils; import com.gmail.nossr50.skills.utilities.SkillType; public abstract class SkillManager { protected McMMOPlayer mcMMOPlayer; - protected int skillLevel; protected int activationChance; protected SkillType skill; public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) { this.mcMMOPlayer = mcMMOPlayer; - this.skillLevel = mcMMOPlayer.getProfile().getSkillLevel(skill); this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill); this.skill = skill; } @@ -21,8 +22,16 @@ public abstract class SkillManager { return mcMMOPlayer; } + public Player getPlayer() { + return mcMMOPlayer.getPlayer(); + } + + public PlayerProfile getProfile() { + return mcMMOPlayer.getProfile(); + } + public int getSkillLevel() { - return skillLevel; + return mcMMOPlayer.getProfile().getSkillLevel(skill); } public int getActivationChance() { diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 6ed8e9c18..c5503a1fa 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -75,7 +75,7 @@ public class ArcheryManager extends SkillManager { * @param event The event to modify. */ public void skillShot(EntityDamageEvent event) { - if (skillLevel >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(mcMMOPlayer.getPlayer(), skill)) { + if (getSkillLevel() >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(mcMMOPlayer.getPlayer(), skill)) { SkillShotEventHandler eventHandler = new SkillShotEventHandler(this, event); eventHandler.calculateDamageBonus(); diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 1a75ceb38..bf6d55aa6 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -22,7 +22,7 @@ public class MiningManager extends SkillManager{ * @param event The PlayerInteractEvent */ public void detonate(PlayerInteractEvent event) { - if (skillLevel < BlastMining.rank1) { + if (getSkillLevel() < BlastMining.rank1) { return; } @@ -57,7 +57,7 @@ public class MiningManager extends SkillManager{ return; } - if (skillLevel < BlastMining.rank1) { + if (getSkillLevel() < BlastMining.rank1) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index 846cb764b..71fbc29fc 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -60,7 +60,7 @@ public class SmeltingManager extends SkillManager { } public void vanillaXPBoost(FurnaceExtractEvent event) { - if (skillLevel < Smelting.vanillaXPBoostRank1Level || !Permissions.vanillaXpBoost(mcMMOPlayer.getPlayer(), skill)) { + if (getSkillLevel() < Smelting.vanillaXPBoostRank1Level || !Permissions.vanillaXpBoost(mcMMOPlayer.getPlayer(), skill)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 3ad14f88e..d00d91188 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -20,7 +20,7 @@ public class SwordsManager extends SkillManager { public void bleedCheck(LivingEntity defender) { BleedEventHandler eventHandler = new BleedEventHandler(this, defender); - float chance = (float) ((Swords.bleedMaxChance / Swords.bleedMaxBonusLevel) * skillLevel); + float chance = (float) ((Swords.bleedMaxChance / Swords.bleedMaxBonusLevel) * getSkillLevel()); if (chance > Swords.bleedMaxChance) chance = (float) Swords.bleedMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { @@ -33,7 +33,7 @@ public class SwordsManager extends SkillManager { CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage); eventHandler.calculateSkillModifier(); - float chance = (float) ((Swords.counterAttackMaxChance / Swords.counterAttackMaxBonusLevel) * skillLevel); + float chance = (float) ((Swords.counterAttackMaxChance / Swords.counterAttackMaxBonusLevel) * getSkillLevel()); if (chance > Swords.counterAttackMaxChance) chance = (float) Swords.counterAttackMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { 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 8d851bf65..3258c2575 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -79,7 +79,7 @@ public class TamingManager extends SkillManager { public void gore(EntityDamageEvent event) { GoreEventHandler eventHandler = new GoreEventHandler(this, event); - float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * skillLevel); + float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * getSkillLevel()); if (chance > Taming.goreMaxChance) chance = (float) Taming.goreMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index c1a910f14..2c2b6f8ce 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -28,7 +28,7 @@ public class UnarmedManager extends SkillManager { if (eventHandler.isHoldingItem()) { eventHandler.calculateSkillModifier(); - float chance = (float) ((Unarmed.disarmMaxChance / Unarmed.disarmMaxBonusLevel) * skillLevel); + float chance = (float) ((Unarmed.disarmMaxChance / Unarmed.disarmMaxBonusLevel) * getSkillLevel()); if (chance > Unarmed.disarmMaxChance) chance = (float) Unarmed.disarmMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { @@ -47,7 +47,7 @@ public class UnarmedManager extends SkillManager { public void deflectCheck(EntityDamageEvent event) { DeflectEventHandler eventHandler = new DeflectEventHandler(this, event); - float chance = (float) ((Unarmed.deflectMaxChance / Unarmed.deflectMaxBonusLevel) * skillLevel); + float chance = (float) ((Unarmed.deflectMaxChance / Unarmed.deflectMaxBonusLevel) * getSkillLevel()); if (chance > Unarmed.deflectMaxChance) chance = (float) Unarmed.deflectMaxChance; if (chance > Misc.getRandom().nextInt(activationChance)) { diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index f72bb42f2..6bd831951 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -29,17 +29,12 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.acrobatics.Acrobatics; -import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; -import com.gmail.nossr50.skills.archery.ArcheryManager; -import com.gmail.nossr50.skills.axes.AxeManager; import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.runnables.CombatXpGiver; import com.gmail.nossr50.skills.swords.Swords; -import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.Taming; -import com.gmail.nossr50.skills.taming.TamingManager; -import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -85,7 +80,7 @@ public final class CombatTools { if (Permissions.skillEnabled(player, SkillType.SWORDS)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - SwordsManager swordsManager = new SwordsManager(mcMMOPlayer); + String playerName = player.getName(); boolean canSerratedStrike = Permissions.serratedStrikes(player); //So we don't have to check the same permission twice if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) { @@ -93,11 +88,11 @@ public final class CombatTools { } if (Permissions.bleed(player)) { - swordsManager.bleedCheck(target); + SkillManagerStore.getInstance().getSwordsManager(playerName).bleedCheck(target); } if (profile.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) { - swordsManager.serratedStrikes(target, event.getDamage()); + SkillManagerStore.getInstance().getSwordsManager(playerName).serratedStrikes(target, event.getDamage()); } startGainXp(mcMMOPlayer, target, SkillType.SWORDS); @@ -116,26 +111,27 @@ public final class CombatTools { if (Permissions.skillEnabled(player, SkillType.AXES)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - AxeManager axeManager = new AxeManager(mcMMOPlayer); + String playerName = player.getName(); + boolean canSkullSplit = Permissions.skullSplitter(player); //So we don't have to check the same permission twice if (profile.getToolPreparationMode(ToolType.AXE) && canSkullSplit) { SkillTools.abilityCheck(player, SkillType.AXES); } - if (Permissions.bonusDamage(player, axeManager.getSkill())) { - axeManager.bonusDamage(event); + if (Permissions.bonusDamage(player, SkillType.AXES)) { + SkillManagerStore.getInstance().getAxeManager(playerName).bonusDamage(event); } if (!target.isDead() && Permissions.criticalStrikes(player)) { - axeManager.criticalHitCheck(event, target); + SkillManagerStore.getInstance().getAxeManager(playerName).criticalHitCheck(event, target); } if (!target.isDead() && Permissions.armorImpact(player)) { - axeManager.impact(event, target); + SkillManagerStore.getInstance().getAxeManager(playerName).impact(event, target); } if (!target.isDead() && profile.getAbilityMode(AbilityType.SKULL_SPLITTER) && canSkullSplit) { - axeManager.skullSplitter(target, event.getDamage()); + SkillManagerStore.getInstance().getAxeManager(playerName).skullSplitter(target, event.getDamage()); } startGainXp(mcMMOPlayer, target, SkillType.AXES); @@ -154,32 +150,31 @@ public final class CombatTools { if (Permissions.skillEnabled(player, SkillType.UNARMED)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - UnarmedManager unarmedManager = new UnarmedManager(mcMMOPlayer); + String playerName = player.getName(); + boolean canBerserk = Permissions.berserk(player); //So we don't have to check the same permission twice if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) { SkillTools.abilityCheck(player, SkillType.UNARMED); } - if (Permissions.bonusDamage(player, unarmedManager.getSkill())) { - unarmedManager.bonusDamage(event); + if (Permissions.bonusDamage(player, SkillType.UNARMED)) { + SkillManagerStore.getInstance().getUnarmedManager(playerName).bonusDamage(event); } if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) { - unarmedManager.berserkDamage(event); + SkillManagerStore.getInstance().getUnarmedManager(playerName).berserkDamage(event); } if (target instanceof Player && Permissions.disarm(player)) { - unarmedManager.disarmCheck(target); + SkillManagerStore.getInstance().getUnarmedManager(playerName).disarmCheck(target); } startGainXp(mcMMOPlayer, target, SkillType.UNARMED); } } else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) { - TamingManager tamingManager = new TamingManager(Users.getPlayer(player)); - tamingManager.beastLore(target); - event.setCancelled(true); + SkillManagerStore.getInstance().getTamingManager(player.getName()).beastLore(target); } } @@ -205,19 +200,18 @@ public final class CombatTools { if (Permissions.skillEnabled(master, SkillType.TAMING)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(master); - TamingManager tamingManager = new TamingManager(mcMMOPlayer); - int skillLevel = tamingManager.getSkillLevel(); + int skillLevel = SkillManagerStore.getInstance().getTamingManager(master.getName()).getSkillLevel(); if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) { - tamingManager.fastFoodService(wolf, event.getDamage()); + SkillManagerStore.getInstance().getTamingManager(master.getName()).fastFoodService(wolf, event.getDamage()); } if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) { - tamingManager.sharpenedClaws(event); + SkillManagerStore.getInstance().getTamingManager(master.getName()).sharpenedClaws(event); } if (Permissions.gore(master)) { - tamingManager.gore(event); + SkillManagerStore.getInstance().getTamingManager(master.getName()).gore(event); } startGainXp(mcMMOPlayer, target, SkillType.TAMING); @@ -261,24 +255,20 @@ public final class CombatTools { if (damager instanceof Player) { if (SkillType.SWORDS.getPVPEnabled() && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) { - SwordsManager swordsManager = new SwordsManager(Users.getPlayer(player)); - swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage()); + SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); } if (SkillType.ACROBATICS.getPVPEnabled() && Permissions.dodge(player)) { - AcrobaticsManager acrobaticsManager = new AcrobaticsManager(Users.getPlayer(player)); - acrobaticsManager.dodgeCheck(event); + SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event); } } else { if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) { - SwordsManager swordsManager = new SwordsManager(Users.getPlayer(player)); - swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage()); + SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); } if (SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) && Permissions.dodge(player)) { - AcrobaticsManager acrobaticsManager = new AcrobaticsManager(Users.getPlayer(player)); - acrobaticsManager.dodgeCheck(event); + SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event); } } } @@ -298,26 +288,24 @@ public final class CombatTools { if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(shooter); - ArcheryManager archeryManager = new ArcheryManager(mcMMOPlayer); - archeryManager.skillShot(event); + SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).skillShot(event); if (target instanceof Player) { if (SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) { - UnarmedManager unarmedManager = new UnarmedManager(Users.getPlayer((Player) target)); - unarmedManager.deflectCheck(event); + SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck(event); } if (Permissions.daze(shooter)) { - archeryManager.dazeCheck((Player) target, event); + SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).dazeCheck((Player) target, event); } } if (!(shooter.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(shooter)) { - archeryManager.trackArrows(target); + SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).trackArrows(target); } - archeryManager.distanceXpBonus(target); + SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).distanceXpBonus(target); startGainXp(mcMMOPlayer, target, SkillType.ARCHERY); } } From 3607d0b9a1b295a37349000a5b294cd9c4a525e0 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 16:58:06 -0500 Subject: [PATCH 056/137] Eclipse - still being stupid. --- .../nossr50/skills/SkillManagerStore.java | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java new file mode 100644 index 000000000..64d391e69 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java @@ -0,0 +1,98 @@ +package com.gmail.nossr50.skills; + +import java.util.HashMap; + +import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; +import com.gmail.nossr50.skills.archery.ArcheryManager; +import com.gmail.nossr50.skills.axes.AxeManager; +import com.gmail.nossr50.skills.mining.MiningManager; +import com.gmail.nossr50.skills.smelting.SmeltingManager; +import com.gmail.nossr50.skills.swords.SwordsManager; +import com.gmail.nossr50.skills.taming.TamingManager; +import com.gmail.nossr50.skills.unarmed.UnarmedManager; +import com.gmail.nossr50.util.Users; + +public class SkillManagerStore { + private static SkillManagerStore instance; + + private HashMap acrobaticsManagers = new HashMap(); + private HashMap archeryManagers = new HashMap(); + private HashMap axeManagers = new HashMap(); + private HashMap miningManagers = new HashMap(); + private HashMap smeltingManagers = new HashMap(); + private HashMap swordsManagers = new HashMap(); + private HashMap tamingManagers = new HashMap(); + private HashMap unarmedManagers = new HashMap(); + + public static SkillManagerStore getInstance() { + if (instance == null) { + instance = new SkillManagerStore(); + } + + return instance; + } + + public AcrobaticsManager getAcrobaticsManager(String playerName) { + if (!acrobaticsManagers.containsKey(playerName)) { + acrobaticsManagers.put(playerName, new AcrobaticsManager(Users.getPlayer(playerName))); + } + + return acrobaticsManagers.get(playerName); + } + + public ArcheryManager getArcheryManager(String playerName) { + if (!archeryManagers.containsKey(playerName)) { + archeryManagers.put(playerName, new ArcheryManager(Users.getPlayer(playerName))); + } + + return archeryManagers.get(playerName); + } + + public AxeManager getAxeManager(String playerName) { + if (!axeManagers.containsKey(playerName)) { + axeManagers.put(playerName, new AxeManager(Users.getPlayer(playerName))); + } + + return axeManagers.get(playerName); + } + + public MiningManager getMiningManager(String playerName) { + if (!miningManagers.containsKey(playerName)) { + miningManagers.put(playerName, new MiningManager(Users.getPlayer(playerName))); + } + + return miningManagers.get(playerName); + } + + public SmeltingManager getSmeltingManager(String playerName) { + if (!smeltingManagers.containsKey(playerName)) { + smeltingManagers.put(playerName, new SmeltingManager(Users.getPlayer(playerName))); + } + + return smeltingManagers.get(playerName); + } + + public SwordsManager getSwordsManager(String playerName) { + if (!swordsManagers.containsKey(playerName)) { + swordsManagers.put(playerName, new SwordsManager(Users.getPlayer(playerName))); + } + + return swordsManagers.get(playerName); + } + + public TamingManager getTamingManager(String playerName) { + if (!tamingManagers.containsKey(playerName)) { + tamingManagers.put(playerName, new TamingManager(Users.getPlayer(playerName))); + } + + return tamingManagers.get(playerName); + } + + public UnarmedManager getUnarmedManager(String playerName) { + if (!unarmedManagers.containsKey(playerName)) { + unarmedManagers.put(playerName, new UnarmedManager(Users.getPlayer(playerName))); + } + + return unarmedManagers.get(playerName); + } +} From 5026bdcbd49a235bdde28dd0aeaa01c646356fd2 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Mon, 25 Feb 2013 16:43:37 -0500 Subject: [PATCH 057/137] Add new child.yml config for picking parents of child skills --- Changelog.txt | 1 + .../nossr50/datatypes/PlayerProfile.java | 13 ++-- src/main/java/com/gmail/nossr50/mcMMO.java | 4 +- .../nossr50/skills/child/ChildConfig.java | 60 +++++++++++++++++++ .../nossr50/skills/child/FamilyTree.java | 49 +++++++++++++++ .../smelting/SmeltResourceEventHandler.java | 14 +++-- src/main/resources/child.yml | 11 ++++ 7 files changed, 138 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java create mode 100644 src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java create mode 100644 src/main/resources/child.yml diff --git a/Changelog.txt b/Changelog.txt index 75bb0f930..a1b4207c3 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -40,6 +40,7 @@ Version 1.4.00-dev + Added config option to make .new config files instead over writing over old ones when updating + Added "Holy Hound" ability to Taming + Added "Shroom Thumb" ability to Herbalism + + Added child.yml config file to choose parents for child skills = Fixed Green Thumb on wheat not working properly at rank 4 = Fixed Green Thumb and Green Terra consuming twice the amount of seed needed = Fixed Green Terra not also checking Green Thumb permissions diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index b2c62bba0..6243d03bd 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -6,10 +6,12 @@ import java.io.FileReader; import java.io.FileWriter; import java.util.ArrayList; import java.util.HashMap; +import java.util.Set; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.Database; +import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.utilities.AbilityType; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.skills.utilities.ToolType; @@ -902,13 +904,12 @@ public class PlayerProfile { } public int getChildSkillLevel(SkillType skillType) { - switch (skillType) { - case SMELTING: - return ((getSkillLevel(SkillType.MINING) / 4) + (getSkillLevel(SkillType.REPAIR) / 4)); //TODO: Make this cleaner somehow - - default: - return 0; + Set parents = FamilyTree.getParents(skillType); + int sum = 0; + for (SkillType parent : parents) { + sum += Math.min(getSkillLevel(parent), 1000); } + return sum / parents.size(); } public int getSkillXpLevel(SkillType skillType) { diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 5fb634214..74972690f 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -44,6 +44,7 @@ import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.runnables.PartiesLoader; import com.gmail.nossr50.party.runnables.PartyAutoKick; import com.gmail.nossr50.runnables.SaveTimer; +import com.gmail.nossr50.skills.child.ChildConfig; import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.RepairManagerFactory; import com.gmail.nossr50.skills.repair.Repairable; @@ -266,8 +267,7 @@ public class mcMMO extends JavaPlugin { TreasuresConfig.getInstance(); HiddenConfig.getInstance(); AdvancedConfig.getInstance(); - - + new ChildConfig(); List repairables = new ArrayList(); diff --git a/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java b/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java new file mode 100644 index 000000000..9419946c4 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java @@ -0,0 +1,60 @@ +package com.gmail.nossr50.skills.child; + +import java.util.EnumSet; +import java.util.List; + +import org.bukkit.configuration.file.YamlConfiguration; + +import com.gmail.nossr50.config.AutoUpdateConfigLoader; +import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.StringUtils; + +public class ChildConfig extends AutoUpdateConfigLoader { + public ChildConfig() { + super("child.yml"); + loadKeys(); + } + + @Override + protected void loadKeys() { + config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml"))); + + for (SkillType skill : SkillType.values()) { + if (skill.isChildSkill()) { + plugin.debug("Finding parents of " + skill.name()); + List parentNames = config.getStringList(StringUtils.getCapitalized(skill.name())); + EnumSet parentSkills = EnumSet.noneOf(SkillType.class); + boolean useDefaults = false; // If we had an error we back out and use defaults + for (String name : parentNames) { + try { + SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase()); + FamilyTree.enforceNotChildSkill(parentSkill); + parentSkills.add(parentSkill); + } catch (IllegalArgumentException ex) { + plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!"); + useDefaults = true; + break; + } + } + + if (useDefaults) { + parentSkills.clear(); + for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) { + /* We do less checks in here because it's from inside our jar. + * If they're dedicated enough to have modified it, they can have the errors it may produce. + * Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration. + */ + parentSkills.add(SkillType.valueOf(name.toUpperCase())); + } + } + + // Register them + for (SkillType parentSkill : parentSkills) { + plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name()); + FamilyTree.registerParent(skill, parentSkill); + } + } + } + FamilyTree.closeRegistration(); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java b/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java new file mode 100644 index 000000000..382619507 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java @@ -0,0 +1,49 @@ +package com.gmail.nossr50.skills.child; + +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Set; + +import com.gmail.nossr50.skills.utilities.SkillType; + +public class FamilyTree { + private static HashMap> tree = new HashMap>(); + + public static Set getParents(SkillType childSkill) { + enforceChildSkill(childSkill); + + // We do not check if we have the child skill in question, as not having it would mean we did something wrong, and an NPE is desired. + return tree.get(childSkill); + } + + protected static void registerParent(SkillType childSkill, SkillType parentSkill) { + enforceChildSkill(childSkill); + enforceNotChildSkill(parentSkill); + + if (!tree.containsKey(childSkill)) { + tree.put(childSkill, EnumSet.noneOf(SkillType.class)); + } + + tree.get(childSkill).add(parentSkill); + } + + protected static void closeRegistration() { + for (SkillType childSkill : tree.keySet()) { + Set immutableSet = Collections.unmodifiableSet(tree.get(childSkill)); + tree.put(childSkill, immutableSet); + } + } + + protected static void enforceChildSkill(SkillType skill) { + if (!skill.isChildSkill()) { + throw new IllegalArgumentException(skill.name() + " is not a child skill!"); + } + } + + protected static void enforceNotChildSkill(SkillType skill) { + if (skill.isChildSkill()) { + throw new IllegalArgumentException(skill.name() + " is a child skill!"); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltResourceEventHandler.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltResourceEventHandler.java index 835b3ba0c..c8e6947fb 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltResourceEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltResourceEventHandler.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.skills.smelting; +import java.util.Set; + import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.FurnaceSmeltEvent; @@ -7,6 +9,7 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Permissions; @@ -37,12 +40,11 @@ public class SmeltResourceEventHandler { McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer(); Player player = mcMMOPlayer.getPlayer(); - if (Permissions.skillEnabled(player, SkillType.MINING)) { - mcMMOPlayer.beginXpGain(SkillType.MINING, xp / 2); - } - - if (Permissions.skillEnabled(player, SkillType.REPAIR)) { - mcMMOPlayer.beginXpGain(SkillType.REPAIR, xp / 2); + Set parentSkills = FamilyTree.getParents(SkillType.SMELTING); + for (SkillType parentSkill : parentSkills) { + if (Permissions.skillEnabled(player, parentSkill)) { + mcMMOPlayer.beginXpGain(parentSkill, xp / parentSkills.size()); + } } } diff --git a/src/main/resources/child.yml b/src/main/resources/child.yml new file mode 100644 index 000000000..da5380a9c --- /dev/null +++ b/src/main/resources/child.yml @@ -0,0 +1,11 @@ +# +# mcMMO child skill configuration +# You do not need to modify this file except to change parents of child skills +# +# If you wish a child skill to be the parent of another child skill, you must also make your changes to the child.yml within the jar +# WARNING: THIS IS NOT SUPPORTED, IF YOU DO SO YOU ARE RESPONSIBLE FOR THE ISSUES THAT MAY ARISE. That said, watch out for circular dependencies, those are bad. +# +##### +Smelting: + - Mining + - Repair \ No newline at end of file From d46b134dbb6168b4ac144c71f42fda8ffc558ab0 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 25 Feb 2013 18:00:15 -0500 Subject: [PATCH 058/137] Don't pass our events around so much. --- .../gmail/nossr50/config/AdvancedConfig.java | 1 + .../gmail/nossr50/skills/SkillManager.java | 4 +++ .../nossr50/skills/acrobatics/Acrobatics.java | 30 ++++++++++++++--- .../skills/acrobatics/AcrobaticsManager.java | 32 ++++++++++++++----- .../nossr50/skills/utilities/CombatTools.java | 13 +++----- src/main/resources/advanced.yml | 2 ++ 6 files changed, 60 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 9c2750fc4..c5e3b3b95 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -25,6 +25,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { /* ACROBATICS */ public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); } public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); } + public int getDodgeDamageModifier() { return config.getInt("Skills.Acrobatics.Dodge_DamageModifer", 2); } public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); } public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); } diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManager.java b/src/main/java/com/gmail/nossr50/skills/SkillManager.java index 71a2cdbb3..84ddc8c09 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManager.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManager.java @@ -41,4 +41,8 @@ public abstract class SkillManager { public SkillType getSkill() { return skill; } + + public void applyXpGain(int xp) { + mcMMOPlayer.beginXpGain(skill, xp); + } } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index 618c8269e..97c6059eb 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -1,6 +1,8 @@ package com.gmail.nossr50.skills.acrobatics; import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LightningStrike; import org.bukkit.entity.Player; import com.gmail.nossr50.config.AdvancedConfig; @@ -16,6 +18,7 @@ public final class Acrobatics { public static double dodgeMaxChance = AdvancedConfig.getInstance().getDodgeChanceMax(); public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel(); public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier(); + public static int dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier(); public static double rollMaxChance = AdvancedConfig.getInstance().getRollChanceMax(); public static int rollMaxBonusLevel = AdvancedConfig.getInstance().getRollMaxBonusLevel(); @@ -38,12 +41,25 @@ public final class Acrobatics { return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player); } + public static boolean canDodge(Player player, Entity damager) { + if (Permissions.dodge(player)) { + if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) { + return true; + } + else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) { + return true; + } + } + + return false; + } + public static int processRoll(Player player, int damage) { if (player.isSneaking() && Permissions.gracefulRoll(player)) { return processGracefulRoll(player, damage); } - int modifiedDamage = calculateModifiedDamage(damage, rollThreshold); + int modifiedDamage = calculateModifiedRollDamage(damage, rollThreshold); if (!isFatal(player, modifiedDamage) && isSuccessfulRoll(player, rollMaxChance, rollMaxBonusLevel, 1)) { player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); @@ -59,7 +75,7 @@ public final class Acrobatics { } private static int processGracefulRoll(Player player, int damage) { - int modifiedDamage = calculateModifiedDamage(damage, gracefulRollThreshold); + int modifiedDamage = calculateModifiedRollDamage(damage, gracefulRollThreshold); if (!isFatal(player, modifiedDamage) && isSuccessfulRoll(player, gracefulRollMaxChance, gracefulRollMaxBonusLevel, gracefulRollSuccessModifier)) { player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); @@ -74,15 +90,19 @@ public final class Acrobatics { return damage; } - private static boolean isFatal(Player player, int damage) { + protected static boolean isFatal(Player player, int damage) { return player.getHealth() - damage < 1; } - private static int calculateModifiedDamage(int damage, int damageThreshold) { + protected static int calculateModifiedDodgeDamage(int damage, int damageModifier) { + return Math.max(damage / damageModifier, 1); + } + + protected static int calculateModifiedRollDamage(int damage, int damageThreshold) { return Math.max(damage - damageThreshold, 0); } - private static boolean isSuccessfulRoll(Player player, double maxChance, int maxLevel, int successModifier) { + protected static boolean isSuccessfulRoll(Player player, double maxChance, int maxLevel, int successModifier) { double successChance = (maxChance / maxLevel) * Math.min(Users.getPlayer(player).getProfile().getSkillLevel(SkillType.ACROBATICS), maxLevel) * successModifier; return successChance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, SkillType.ACROBATICS)); diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index f1c3f364d..396d9ceb0 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -1,11 +1,15 @@ package com.gmail.nossr50.skills.acrobatics; -import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.entity.Player; import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.ParticleEffectUtils; public class AcrobaticsManager extends SkillManager { public AcrobaticsManager (McMMOPlayer mcMMOPlayer) { @@ -17,15 +21,27 @@ public class AcrobaticsManager extends SkillManager { * * @param event The event to check */ - public void dodgeCheck(EntityDamageEvent event) { - DodgeEventHandler eventHandler = new DodgeEventHandler(this, event); + public int dodgeCheck(int damage) { + int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier); + Player player = getPlayer(); - double chance = (Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * eventHandler.skillModifier; + if (!Acrobatics.isFatal(player, modifiedDamage) && SkillTools.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) { + ParticleEffectUtils.playDodgeEffect(player); - if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) { - eventHandler.modifyEventDamage(); - eventHandler.sendAbilityMessage(); - eventHandler.processXpGain(eventHandler.damage * Acrobatics.dodgeXpModifier); + PlayerProfile playerProfile = getProfile(); + + if (playerProfile.useChatNotifications()) { + player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc")); + } + + // Why do we check respawn cooldown here? + if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) { + applyXpGain(damage * Acrobatics.dodgeXpModifier); + } + + return modifiedDamage; } + + return damage; } } diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index 6bd831951..d7566b853 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -8,7 +8,6 @@ import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.IronGolem; -import org.bukkit.entity.LightningStrike; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; @@ -253,23 +252,19 @@ public final class CombatTools { ItemStack heldItem = player.getItemInHand(); + if (Acrobatics.canDodge(player, damager)) { + event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event.getDamage())); + } + if (damager instanceof Player) { if (SkillType.SWORDS.getPVPEnabled() && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) { SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); } - - if (SkillType.ACROBATICS.getPVPEnabled() && Permissions.dodge(player)) { - SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event); - } } else { if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) { SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); } - - if (SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) && Permissions.dodge(player)) { - SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event); - } } } } diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 39baed646..0d60c90b6 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -22,8 +22,10 @@ Skills: Acrobatics: # Dodge_ChanceMax: Maximum chance of dodging when on Dodge_MaxBonusLevel or higher # Dodge_MaxBonusLevel: On this level or higher, the dodge chance will not go higher than Dodge_ChanceMax + # Dodge_DamageModifer: Dodge damage will be divided by this multiplier Dodge_ChanceMax: 20.0 Dodge_MaxBonusLevel: 800 + Dodge_DamageModifier: 2 # Roll_ChanceMax: Maximum chance of rolling when on Roll_MaxBonusLevel or higher # Roll_MaxBonusLevel: On this level or higher, the roll chance will not go higher than Roll_ChanceMax From d409610a552f7088fd8939a87fec6f474d323c36 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 08:19:21 -0500 Subject: [PATCH 059/137] Move Roll checks into the manager. --- .../nossr50/listeners/EntityListener.java | 2 +- .../nossr50/skills/acrobatics/Acrobatics.java | 36 ----------- .../acrobatics/AcrobaticsEventHandler.java | 60 ------------------ .../skills/acrobatics/AcrobaticsManager.java | 50 ++++++++++++++- .../skills/acrobatics/DodgeEventHandler.java | 62 ------------------- 5 files changed, 49 insertions(+), 161 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/acrobatics/DodgeEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index c8c9799b2..f3cfda655 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -180,7 +180,7 @@ public class EntityListener implements Listener { switch (cause) { case FALL: if (Acrobatics.canRoll(player)) { - event.setDamage(Acrobatics.processRoll(player, event.getDamage())); + event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).processRoll(event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index 97c6059eb..392ff59d1 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -54,42 +54,6 @@ public final class Acrobatics { return false; } - public static int processRoll(Player player, int damage) { - if (player.isSneaking() && Permissions.gracefulRoll(player)) { - return processGracefulRoll(player, damage); - } - - int modifiedDamage = calculateModifiedRollDamage(damage, rollThreshold); - - if (!isFatal(player, modifiedDamage) && isSuccessfulRoll(player, rollMaxChance, rollMaxBonusLevel, 1)) { - player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); - applyXpGain(player, damage, rollXpModifier); - - return modifiedDamage; - } - else if (!isFatal(player, damage)) { - applyXpGain(player, damage, fallXpModifier); - } - - return damage; - } - - private static int processGracefulRoll(Player player, int damage) { - int modifiedDamage = calculateModifiedRollDamage(damage, gracefulRollThreshold); - - if (!isFatal(player, modifiedDamage) && isSuccessfulRoll(player, gracefulRollMaxChance, gracefulRollMaxBonusLevel, gracefulRollSuccessModifier)) { - player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); - applyXpGain(player, damage, rollXpModifier); - - return modifiedDamage; - } - else if (!isFatal(player, damage)) { - applyXpGain(player, damage, fallXpModifier); - } - - return damage; - } - protected static boolean isFatal(Player player, int damage) { return player.getHealth() - damage < 1; } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java deleted file mode 100644 index 740782d10..000000000 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.gmail.nossr50.skills.acrobatics; - -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; - -public abstract class AcrobaticsEventHandler { - protected AcrobaticsManager manager; - - protected EntityDamageEvent event; - protected int damage; - protected int skillModifier; - protected int modifiedDamage; - - protected AcrobaticsEventHandler(AcrobaticsManager manager, EntityDamageEvent event) { - this.manager = manager; - this.event = event; - this.damage = event.getDamage(); - } - - /** - * Calculate the skill modifier applied for this event. - */ - protected abstract void calculateSkillModifier(); - - /** - * Calculate the modified damage for this event. - */ - protected abstract void calculateModifiedDamage(); - - /** - * Modify the damage dealt by this event. - */ - protected abstract void modifyEventDamage(); - - /** - * Send the ability message for this event. - */ - protected abstract void sendAbilityMessage(); - - /** - * Process Xp gain from this event. - */ - protected abstract void processXpGain(int xp); - - /** - * Check to ensure you're not gaining XP after you die. - * - * @param damage The damage to be dealt - * @return true if the damage is fatal, false otherwise - */ - protected boolean isFatal(int damage) { - Player player = manager.getMcMMOPlayer().getPlayer(); - - if (player.getHealth() - damage < 1) { - return true; - } - - return false; - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 396d9ceb0..d8d3b058d 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -10,6 +10,7 @@ import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ParticleEffectUtils; +import com.gmail.nossr50.util.Permissions; public class AcrobaticsManager extends SkillManager { public AcrobaticsManager (McMMOPlayer mcMMOPlayer) { @@ -17,9 +18,10 @@ public class AcrobaticsManager extends SkillManager { } /** - * Check for dodge damage reduction. + * Handle the damage reduction and XP gain from the Dodge ability * - * @param event The event to check + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the dodge was successful, the original event damage otherwise */ public int dodgeCheck(int damage) { int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier); @@ -44,4 +46,48 @@ public class AcrobaticsManager extends SkillManager { return damage; } + + /** + * Handle the damage reduction and XP gain from the Roll ability + * + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the roll was successful, the original event damage otherwise + */ + public int processRoll(int damage) { + Player player = getPlayer(); + + if (player.isSneaking() && Permissions.gracefulRoll(player)) { + return processGracefulRoll(player, damage); + } + + int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold); + + if (!Acrobatics.isFatal(player, modifiedDamage) && Acrobatics.isSuccessfulRoll(player, Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) { + player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); + applyXpGain(damage * Acrobatics.rollXpModifier); + + return modifiedDamage; + } + else if (!Acrobatics.isFatal(player, damage)) { + applyXpGain(damage * Acrobatics.fallXpModifier); + } + + return damage; + } + + private int processGracefulRoll(Player player, int damage) { + int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold); + + if (!Acrobatics.isFatal(player, modifiedDamage) && Acrobatics.isSuccessfulRoll(player, Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) { + player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); + applyXpGain(damage * Acrobatics.rollXpModifier); + + return modifiedDamage; + } + else if (!Acrobatics.isFatal(player, damage)) { + applyXpGain(damage * Acrobatics.fallXpModifier); + } + + return damage; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/DodgeEventHandler.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/DodgeEventHandler.java deleted file mode 100644 index 02428739b..000000000 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/DodgeEventHandler.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.gmail.nossr50.skills.acrobatics; - -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.ParticleEffectUtils; - -public class DodgeEventHandler extends AcrobaticsEventHandler { - protected DodgeEventHandler(AcrobaticsManager manager, EntityDamageEvent event) { - super(manager, event); - - calculateSkillModifier(); - calculateModifiedDamage(); - } - - @Override - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Acrobatics.dodgeMaxBonusLevel); - } - - @Override - protected void calculateModifiedDamage() { - int modifiedDamage = damage / 2; - - if (modifiedDamage <= 0) { - modifiedDamage = 1; - } - - this.modifiedDamage = modifiedDamage; - } - - @Override - protected void modifyEventDamage() { - event.setDamage(modifiedDamage); - } - - @Override - protected void sendAbilityMessage() { - McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer(); - Player dodgingPlayer = mcMMOPlayer.getPlayer(); - - ParticleEffectUtils.playDodgeEffect(dodgingPlayer); - - if (mcMMOPlayer.getProfile().useChatNotifications()) { - dodgingPlayer.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc")); - } - } - - @Override - protected void processXpGain(int xp) { - McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer(); - - if (System.currentTimeMillis() >= mcMMOPlayer.getProfile().getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) { - manager.getMcMMOPlayer().beginXpGain(SkillType.ACROBATICS, xp); - } - } -} From 070189a7fdaf9627e1165d86da5261615dfc168d Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 08:19:55 -0500 Subject: [PATCH 060/137] Don't need those anymore. --- .../java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index 392ff59d1..4238748e1 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.PerksUtils; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; @@ -71,8 +70,4 @@ public final class Acrobatics { return successChance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, SkillType.ACROBATICS)); } - - private static void applyXpGain(Player player, int baseXp, int multiplier) { - Users.getPlayer(player).beginXpGain(SkillType.ACROBATICS, baseXp * multiplier); - } } \ No newline at end of file From f5290c3256799143db0b6e94213a79b92e121692 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 08:22:08 -0500 Subject: [PATCH 061/137] Name 'em all the same. --- .../java/com/gmail/nossr50/listeners/EntityListener.java | 2 +- .../gmail/nossr50/skills/acrobatics/AcrobaticsManager.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index f3cfda655..ec872a03b 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -180,7 +180,7 @@ public class EntityListener implements Listener { switch (cause) { case FALL: if (Acrobatics.canRoll(player)) { - event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).processRoll(event.getDamage())); + event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).rollCheck(event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index d8d3b058d..7afe50e6d 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -53,11 +53,11 @@ public class AcrobaticsManager extends SkillManager { * @param damage The amount of damage initially dealt by the event * @return the modified event damage if the roll was successful, the original event damage otherwise */ - public int processRoll(int damage) { + public int rollCheck(int damage) { Player player = getPlayer(); if (player.isSneaking() && Permissions.gracefulRoll(player)) { - return processGracefulRoll(player, damage); + return gracefulRollCheck(player, damage); } int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold); @@ -75,7 +75,7 @@ public class AcrobaticsManager extends SkillManager { return damage; } - private int processGracefulRoll(Player player, int damage) { + private int gracefulRollCheck(Player player, int damage) { int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold); if (!Acrobatics.isFatal(player, modifiedDamage) && Acrobatics.isSuccessfulRoll(player, Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) { From ec8581a8353fc4cb9463950581364facf739659d Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 09:41:47 -0500 Subject: [PATCH 062/137] Pass less events. --- .../gmail/nossr50/skills/SkillManager.java | 4 - .../gmail/nossr50/skills/archery/Archery.java | 17 ++++ .../skills/archery/ArcheryManager.java | 82 +++++++++++-------- .../archery/ArrowTrackingEventHandler.java | 27 ------ .../skills/archery/DazeEventHandler.java | 55 ------------- .../nossr50/skills/utilities/CombatTools.java | 32 ++++---- 6 files changed, 80 insertions(+), 137 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/archery/ArrowTrackingEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/archery/DazeEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManager.java b/src/main/java/com/gmail/nossr50/skills/SkillManager.java index 84ddc8c09..612b7a2dd 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManager.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManager.java @@ -38,10 +38,6 @@ public abstract class SkillManager { return activationChance; } - public SkillType getSkill() { - return skill; - } - public void applyXpGain(int xp) { mcMMOPlayer.beginXpGain(skill, xp); } diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index df000e1d8..ce393d1ca 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -5,11 +5,16 @@ import java.util.Iterator; import java.util.List; import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.skills.utilities.SkillTools; +import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; public class Archery { private static List trackedEntities = new ArrayList(); @@ -27,6 +32,18 @@ public class Archery { public static double distanceXpModifer = 0.025; + public static boolean canDaze(Player player, LivingEntity target) { + return target instanceof Player && Permissions.daze(player); + } + + public static boolean canSkillShot(Player player) { + return SkillTools.unlockLevelReached(player, SkillType.ARCHERY, skillShotIncreaseLevel) && Permissions.bonusDamage(player, SkillType.ARCHERY); + } + + public static boolean canTrackArrows(Player player) { + return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player); + } + protected static void incrementTrackerValue(LivingEntity livingEntity) { for (TrackedEntity trackedEntity : trackedEntities) { if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) { diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index c5503a1fa..38820c456 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -3,21 +3,29 @@ package com.gmail.nossr50.skills.archery; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; public class ArcheryManager extends SkillManager { public ArcheryManager (McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, SkillType.ARCHERY); } + /** + * Calculate bonus XP awarded for Archery when hitting a far-away target. + * + * @param target The {@link LivingEntity} damaged by the arrow + */ public void distanceXpBonus(LivingEntity target) { - Player player = mcMMOPlayer.getPlayer(); + Player player = getPlayer(); Location shooterLocation = player.getLocation(); Location targetLocation = target.getLocation(); @@ -25,61 +33,65 @@ public class ArcheryManager extends SkillManager { return; } - double squaredDistance = shooterLocation.distanceSquared(targetLocation); - // Cap distance at 100^2 to prevent teleport exploit. // TODO: Better way to handle this would be great... - if (squaredDistance > 10000) { - squaredDistance = 10000; - } + double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000); - int bonusXp = (int) (squaredDistance * Archery.distanceXpModifer); - mcMMOPlayer.beginXpGain(SkillType.ARCHERY, bonusXp); + applyXpGain((int) (squaredDistance * Archery.distanceXpModifer)); } /** * Track arrows fired for later retrieval. * - * @param livingEntity Entity damaged by the arrow + * @param target The {@link LivingEntity} damaged by the arrow */ - public void trackArrows(LivingEntity livingEntity) { - ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity); - - double chance = (Archery.retrieveMaxChance / Archery.retrieveMaxBonusLevel) * eventHandler.skillModifier; - - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.addToTracker(); + public void trackArrows(LivingEntity target) { + if (SkillTools.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) { + Archery.incrementTrackerValue(target); } } /** - * Check for Daze. + * Handle the effects of the Daze ability * - * @param defender Defending player - * @param event The event to modify + * @param defender The player being affected by Daze + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the dodge was successful, the original event damage otherwise */ - public void dazeCheck(Player defender, EntityDamageEvent event) { - DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender); + public int dazeCheck(Player defender, int damage) { + Player attacker = getPlayer(); - double chance = (Archery.dazeMaxBonus / Archery.dazeMaxBonusLevel) * eventHandler.skillModifier; + if (SkillTools.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) { + Location dazedLocation = defender.getLocation(); + dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181)); - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.handleDazeEffect(); - eventHandler.sendAbilityMessages(); + defender.teleport(dazedLocation); + defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10)); + + if (Users.getPlayer(defender).getProfile().useChatNotifications()) { + defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy")); + } + + if (getProfile().useChatNotifications()) { + attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed")); + } + + return damage + Archery.dazeModifier; } + + return damage; } /** - * Handle archery bonus damage. + * Handle the effects of the Skill Shot ability * - * @param event The event to modify. + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage */ - public void skillShot(EntityDamageEvent event) { - if (getSkillLevel() >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(mcMMOPlayer.getPlayer(), skill)) { - SkillShotEventHandler eventHandler = new SkillShotEventHandler(this, event); + public int skillShotCheck(int damage) { + double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage); + int archeryBonus = (int) (damage * damageBonusPercent); - eventHandler.calculateDamageBonus(); - eventHandler.modifyEventDamage(); - } + return damage + archeryBonus; } } diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArrowTrackingEventHandler.java b/src/main/java/com/gmail/nossr50/skills/archery/ArrowTrackingEventHandler.java deleted file mode 100644 index 6b662c62d..000000000 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArrowTrackingEventHandler.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.gmail.nossr50.skills.archery; - -import org.bukkit.entity.LivingEntity; - -import com.gmail.nossr50.skills.utilities.SkillTools; - -public class ArrowTrackingEventHandler { - private ArcheryManager manager; - private LivingEntity entity; - - protected int skillModifier; - - protected ArrowTrackingEventHandler (ArcheryManager manager, LivingEntity entity) { - this.manager = manager; - this.entity = entity; - - calculateSkillModifier(); - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Archery.retrieveMaxBonusLevel); - } - - protected void addToTracker() { - Archery.incrementTrackerValue(entity); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/archery/DazeEventHandler.java b/src/main/java/com/gmail/nossr50/skills/archery/DazeEventHandler.java deleted file mode 100644 index 6d12652ab..000000000 --- a/src/main/java/com/gmail/nossr50/skills/archery/DazeEventHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.gmail.nossr50.skills.archery; - -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Users; - -public class DazeEventHandler { - private ArcheryManager manager; - private McMMOPlayer mcMMOPlayer; - private EntityDamageEvent event; - private Player defender; - - protected int skillModifier; - - protected DazeEventHandler (ArcheryManager manager, EntityDamageEvent event, Player defender) { - this.manager = manager; - this.mcMMOPlayer = manager.getMcMMOPlayer(); - this.event = event; - this.defender = defender; - - calculateSkillModifier(); - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Archery.dazeMaxBonusLevel); - } - - protected void handleDazeEffect() { - Location location = defender.getLocation(); - location.setPitch(90 - Misc.getRandom().nextInt(181)); - - defender.teleport(location); - defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10)); - - event.setDamage(event.getDamage() + Archery.dazeModifier); - } - - protected void sendAbilityMessages() { - if (Users.getPlayer(defender).getProfile().useChatNotifications()) { - defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy")); - } - - if (mcMMOPlayer.getProfile().useChatNotifications()) { - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed")); - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index d7566b853..7d1199fd2 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.utilities; import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.Animals; import org.bukkit.entity.Arrow; @@ -30,6 +29,7 @@ import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.acrobatics.Acrobatics; +import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.runnables.CombatXpGiver; import com.gmail.nossr50.skills.swords.Swords; @@ -282,26 +282,26 @@ public final class CombatTools { } if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) { - McMMOPlayer mcMMOPlayer = Users.getPlayer(shooter); - SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).skillShot(event); + String playerName = shooter.getName(); - if (target instanceof Player) { - if (SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) { - SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck(event); - } - - - if (Permissions.daze(shooter)) { - SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).dazeCheck((Player) target, event); - } + if (Archery.canSkillShot(shooter)) { + event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).skillShotCheck(event.getDamage())); } - if (!(shooter.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(shooter)) { - SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).trackArrows(target); + if (target instanceof Player && SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) { + SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck(event); } - SkillManagerStore.getInstance().getArcheryManager(shooter.getName()).distanceXpBonus(target); - startGainXp(mcMMOPlayer, target, SkillType.ARCHERY); + if (Archery.canDaze(shooter, target)) { + event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).dazeCheck((Player) target, event.getDamage())); + } + + if (Archery.canTrackArrows(shooter)) { + SkillManagerStore.getInstance().getArcheryManager(playerName).trackArrows(target); + } + + SkillManagerStore.getInstance().getArcheryManager(playerName).distanceXpBonus(target); + startGainXp(Users.getPlayer(shooter), target, SkillType.ARCHERY); } } From 07a0f438251f6ed7159cb5efee6710f8e5b3e6f8 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 09:42:22 -0500 Subject: [PATCH 063/137] Don't need that anymore. --- .../skills/archery/SkillShotEventHandler.java | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/archery/SkillShotEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/skills/archery/SkillShotEventHandler.java b/src/main/java/com/gmail/nossr50/skills/archery/SkillShotEventHandler.java deleted file mode 100644 index 8be742915..000000000 --- a/src/main/java/com/gmail/nossr50/skills/archery/SkillShotEventHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.gmail.nossr50.skills.archery; - -import org.bukkit.event.entity.EntityDamageEvent; - -public class SkillShotEventHandler { - private ArcheryManager manager; - private EntityDamageEvent event; - - protected double damageBonusPercent; - - protected SkillShotEventHandler(ArcheryManager manager, EntityDamageEvent event) { - this.manager = manager; - this.event = event; - } - - protected void calculateDamageBonus() { - this.damageBonusPercent = ((manager.getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage); - - if (damageBonusPercent > Archery.skillShotMaxBonusPercentage) { - damageBonusPercent = Archery.skillShotMaxBonusPercentage; - } - } - - protected void modifyEventDamage() { - int damage = event.getDamage(); - int archeryBonus = (int) (damage * damageBonusPercent); - - event.setDamage(damage + archeryBonus); - } -} From f767edba93f4e81fc24684e72778a0fd3bfb6409 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 09:53:01 -0500 Subject: [PATCH 064/137] Add SpoutHudAPI for other GUI-related plugins to tweak our XP Bar. --- .../com/gmail/nossr50/api/SpoutHudAPI.java | 28 +++++++++++++++++++ .../com/gmail/nossr50/spout/SpoutConfig.java | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java diff --git a/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java b/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java new file mode 100644 index 000000000..dfb3b3df9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java @@ -0,0 +1,28 @@ +package com.gmail.nossr50.api; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.spout.SpoutConfig; +import com.gmail.nossr50.spout.huds.HudType; +import com.gmail.nossr50.util.Users; + +public class SpoutHudAPI { + + /** + * Disable the mcMMO XP bar for a player. + *
+ * This function is designed for API usage. + */ + public static void disableXpBar(Player player) { + Users.getPlayer(player).getProfile().setHudType(HudType.DISABLED); + } + + /** + * Disable the mcMMO XP bar for the server. + *
+ * This function is designed for API usage. + */ + public static void disableXpBar() { + SpoutConfig.getInstance().setXPBarEnabled(false); + } +} diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java b/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java index fc025cf0f..cc8a3c88c 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java @@ -42,6 +42,8 @@ public class SpoutConfig extends ConfigLoader { /* XP Bar */ public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); } + public void setXPBarEnabled(boolean enabled) { config.set("XP.Bar.Enabled", enabled); } + public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); } public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); } public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); } From d8904827ec6831038ab5c21ef11aca1e75988f09 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 10:01:37 -0500 Subject: [PATCH 065/137] This should have the same effect. --- .../nossr50/skills/archery/TrackedEntity.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java index b59e6584d..a8db0ff97 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO; public class TrackedEntity implements Runnable { private LivingEntity livingEntity; private int arrowCount; - private int previousTicksLived; private int taskId; private BukkitScheduler scheduler; @@ -19,19 +18,6 @@ public class TrackedEntity implements Runnable { this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000); } - //LivingEntity.isDead() isn't a reliable way to know if an entity is still active - //This method must not be called more than once per server tick - private boolean isActive() { - int currentTicksLived = livingEntity.getTicksLived(); - - if (currentTicksLived == previousTicksLived) { - return false; - } - - previousTicksLived = currentTicksLived; - return true; - } - protected LivingEntity getLivingEntity() { return livingEntity; } @@ -46,7 +32,7 @@ public class TrackedEntity implements Runnable { @Override public void run() { - if (!isActive()) { + if (!livingEntity.isValid()) { Archery.removeFromTracker(this); scheduler.cancelTask(taskId); } From 56bd782625de048e71937ea4593b5ab66a0f0ef9 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 10:02:25 -0500 Subject: [PATCH 066/137] Getting it through Bukkit is bad. --- .../java/com/gmail/nossr50/skills/archery/TrackedEntity.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java index a8db0ff97..49c01c067 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.archery; -import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.scheduler.BukkitScheduler; @@ -14,7 +13,7 @@ public class TrackedEntity implements Runnable { protected TrackedEntity(LivingEntity livingEntity) { this.livingEntity = livingEntity; - this.scheduler = Bukkit.getScheduler(); + this.scheduler = mcMMO.p.getServer().getScheduler(); this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000); } From 3aec0e5ef43d88a290eb2e0c200de69733c69b18 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 10:07:00 -0500 Subject: [PATCH 067/137] Using UUID is safer. --- .../java/com/gmail/nossr50/skills/archery/Archery.java | 2 +- .../com/gmail/nossr50/skills/archery/TrackedEntity.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index ce393d1ca..7ebc022cc 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -75,7 +75,7 @@ public class Archery { for (Iterator entityIterator = trackedEntities.iterator(); entityIterator.hasNext(); ) { TrackedEntity trackedEntity = entityIterator.next(); - if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) { + if (trackedEntity.getID() == livingEntity.getUniqueId()) { Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount()); entityIterator.remove(); return; diff --git a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java index 49c01c067..b78d01f90 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.skills.archery; +import java.util.UUID; + import org.bukkit.entity.LivingEntity; import org.bukkit.scheduler.BukkitScheduler; @@ -7,12 +9,14 @@ import com.gmail.nossr50.mcMMO; public class TrackedEntity implements Runnable { private LivingEntity livingEntity; + private UUID id; private int arrowCount; private int taskId; private BukkitScheduler scheduler; protected TrackedEntity(LivingEntity livingEntity) { this.livingEntity = livingEntity; + this.id = livingEntity.getUniqueId(); this.scheduler = mcMMO.p.getServer().getScheduler(); this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000); } @@ -21,6 +25,10 @@ public class TrackedEntity implements Runnable { return livingEntity; } + protected UUID getID() { + return id; + } + protected int getArrowCount() { return arrowCount; } From 38cd3951715b3215c9f50731f797e27c0d69dd69 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 10:13:40 -0500 Subject: [PATCH 068/137] Clean up the bleed list a bit. --- .../nossr50/skills/runnables/BleedTimer.java | 33 ++++--------------- .../nossr50/util/ParticleEffectUtils.java | 4 +-- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java b/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java index ec187030d..711169d4b 100644 --- a/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java +++ b/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java @@ -6,8 +6,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import org.bukkit.Effect; -import org.bukkit.Material; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -35,7 +33,7 @@ public class BleedTimer implements Runnable { for (Entry entry : bleedList.entrySet()) { LivingEntity entity = entry.getKey(); - if (entry.getValue() <= 0 || entity.isDead()) { + if (entry.getValue() <= 0 || !entity.isValid()) { remove(entity); break; } @@ -64,7 +62,7 @@ public class BleedTimer implements Runnable { else { CombatTools.dealDamage(entity, 2); entry.setValue(entry.getValue() - 1); - entity.getWorld().playEffect(entity.getEyeLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE); + ParticleEffectUtils.playBleedEffect(entity); } } @@ -127,44 +125,27 @@ public class BleedTimer implements Runnable { if (lock) { if (bleedAddList.containsKey(entity)) { newTicks += bleedAddList.get(entity); - - if (newTicks > MAX_BLEED_TICKS) { - newTicks = MAX_BLEED_TICKS; - } - - bleedAddList.put(entity, newTicks); + bleedAddList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); } else { - if (newTicks > MAX_BLEED_TICKS) { - newTicks = MAX_BLEED_TICKS; - } - - bleedAddList.put(entity, newTicks); + bleedAddList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); } } else { if (bleedList.containsKey(entity)) { newTicks += bleedList.get(entity); - - if (newTicks > MAX_BLEED_TICKS) { - newTicks = MAX_BLEED_TICKS; - } - - bleedList.put(entity, newTicks); + bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); // Need to find a better way to ensure that the entity stays in bleedList // when some ticks are added but already marked for removal. // Suggestion: Why not use Iterator.remove() and drop the lock boolean? + // TODO: Actually implement this suggestion? if (bleedRemoveList.contains(entity)) { bleedRemoveList.remove(entity); } } else { - if (newTicks > MAX_BLEED_TICKS) { - newTicks = MAX_BLEED_TICKS; - } - - bleedList.put(entity, newTicks); + bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); } } } diff --git a/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java b/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java index 79f9c1cb5..56dcbdc38 100644 --- a/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java @@ -20,12 +20,12 @@ public final class ParticleEffectUtils { private ParticleEffectUtils() {}; - public static void playBleedEffect(Player player) { + public static void playBleedEffect(LivingEntity livingEntity) { if (!Config.getInstance().getBleedEffectEnabled()) { return; } - player.getWorld().playEffect(player.getEyeLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE); + livingEntity.getWorld().playEffect(livingEntity.getEyeLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE); } public static void playDodgeEffect(Player player) { From ae1eda915b01056ee85ec01c628381e2e77ccc46 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 10:32:06 -0500 Subject: [PATCH 069/137] Use an iterator rather than that stupid lock boolean. --- .../nossr50/skills/runnables/BleedTimer.java | 93 +++---------------- 1 file changed, 14 insertions(+), 79 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java b/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java index 711169d4b..a076f6c00 100644 --- a/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java +++ b/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java @@ -1,15 +1,13 @@ package com.gmail.nossr50.skills.runnables; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.CombatTools; import com.gmail.nossr50.util.ParticleEffectUtils; @@ -17,28 +15,18 @@ import com.gmail.nossr50.util.ParticleEffectUtils; public class BleedTimer implements Runnable { private final static int MAX_BLEED_TICKS = 10; private static Map bleedList = new HashMap(); - private static Map bleedAddList = new HashMap(); - private static List bleedRemoveList = new ArrayList(); - private static boolean lock = false; @Override public void run() { - updateBleedList(); - bleedSimulate(); - } - - private void bleedSimulate() { - lock = true; - - for (Entry entry : bleedList.entrySet()) { + for (Iterator> bleedIterator = bleedList.entrySet().iterator(); bleedIterator.hasNext();) { + Entry entry = bleedIterator.next(); LivingEntity entity = entry.getKey(); if (entry.getValue() <= 0 || !entity.isValid()) { - remove(entity); - break; + bleedIterator.remove(); + continue; } - // Player bleed simulation if (entity instanceof Player) { Player player = (Player) entity; @@ -46,10 +34,10 @@ public class BleedTimer implements Runnable { continue; } - //Never kill with Bleeding + // Never kill with Bleeding if (player.getHealth() - 1 > 0) { CombatTools.dealDamage(player, 1); - ParticleEffectUtils.playBleedEffect(player); + ParticleEffectUtils.playBleedEffect(entity); } entry.setValue(entry.getValue() - 1); @@ -58,29 +46,12 @@ public class BleedTimer implements Runnable { player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Stopped")); } } - // Bleed monsters/animals else { CombatTools.dealDamage(entity, 2); - entry.setValue(entry.getValue() - 1); ParticleEffectUtils.playBleedEffect(entity); + entry.setValue(entry.getValue() - 1); } } - - // Unlock list now that we are done - lock = false; - } - - private void updateBleedList() { - if (lock) { - mcMMO.p.getLogger().warning("mcBleedTimer attempted to update the bleedList but the list was locked!"); - } - else { - bleedList.keySet().removeAll(bleedRemoveList); - bleedRemoveList.clear(); - - bleedList.putAll(bleedAddList); - bleedAddList.clear(); - } } /** @@ -101,15 +72,8 @@ public class BleedTimer implements Runnable { * @param entity LivingEntity to remove */ public static void remove(LivingEntity entity) { - if (lock) { - if (!bleedRemoveList.contains(entity)) { - bleedRemoveList.add(entity); - } - } - else { - if (bleedList.containsKey(entity)) { - bleedList.remove(entity); - } + if (bleedList.containsKey(entity)) { + bleedList.remove(entity); } } @@ -122,41 +86,12 @@ public class BleedTimer implements Runnable { public static void add(LivingEntity entity, int ticks) { int newTicks = ticks; - if (lock) { - if (bleedAddList.containsKey(entity)) { - newTicks += bleedAddList.get(entity); - bleedAddList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); - } - else { - bleedAddList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); - } + if (bleedList.containsKey(entity)) { + newTicks += bleedList.get(entity); + bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); } else { - if (bleedList.containsKey(entity)) { - newTicks += bleedList.get(entity); - bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); - - // Need to find a better way to ensure that the entity stays in bleedList - // when some ticks are added but already marked for removal. - // Suggestion: Why not use Iterator.remove() and drop the lock boolean? - // TODO: Actually implement this suggestion? - if (bleedRemoveList.contains(entity)) { - bleedRemoveList.remove(entity); - } - } - else { - bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); - } + bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS)); } } - - /** - * Check to see if a LivingEntity is in the bleedList - * - * @param entity LivingEntity to check if in the bleedList - * @return true if in the list, false if not - */ - public static boolean contains(LivingEntity entity) { - return (bleedList.containsKey(entity) || bleedAddList.containsKey(entity)); - } } From 0cd07cf2fd4e527732d2ef52ec5f099673a8ca86 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 12:03:37 -0500 Subject: [PATCH 070/137] The functions, they do nothing! --- src/main/java/com/gmail/nossr50/config/AdvancedConfig.java | 1 - src/main/java/com/gmail/nossr50/config/Config.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index c5e3b3b95..87bfb4496 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -5,7 +5,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { private AdvancedConfig() { super("advanced.yml"); - loadKeys(); } public static AdvancedConfig getInstance() { diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 56fa64429..d36059fc7 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -15,7 +15,6 @@ public class Config extends AutoUpdateConfigLoader { private Config() { super("config.yml"); - loadKeys(); } public static Config getInstance() { From 55138f159961842da3a129a4846587d0b97a47b9 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 12:38:17 -0500 Subject: [PATCH 071/137] Managers control everything relating to players. --- .../nossr50/listeners/EntityListener.java | 3 +- .../nossr50/skills/acrobatics/Acrobatics.java | 37 --------------- .../skills/acrobatics/AcrobaticsManager.java | 46 +++++++++++++++++-- .../gmail/nossr50/skills/archery/Archery.java | 17 ------- .../skills/archery/ArcheryManager.java | 18 ++++++++ .../nossr50/skills/utilities/CombatTools.java | 10 ++-- 6 files changed, 64 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index ec872a03b..c1cc7ab7c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -33,7 +33,6 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.skills.SkillManagerStore; -import com.gmail.nossr50.skills.acrobatics.Acrobatics; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; @@ -179,7 +178,7 @@ public class EntityListener implements Listener { switch (cause) { case FALL: - if (Acrobatics.canRoll(player)) { + if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canRoll()) { event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).rollCheck(event.getDamage())); if (event.getDamage() == 0) { diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index 4238748e1..36ba599ca 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -1,17 +1,7 @@ package com.gmail.nossr50.skills.acrobatics; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LightningStrike; -import org.bukkit.entity.Player; - import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.skills.utilities.PerksUtils; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; public final class Acrobatics { public static double dodgeMaxChance = AdvancedConfig.getInstance().getDodgeChanceMax(); @@ -36,27 +26,6 @@ public final class Acrobatics { private Acrobatics() {}; - public static boolean canRoll(Player player) { - return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player); - } - - public static boolean canDodge(Player player, Entity damager) { - if (Permissions.dodge(player)) { - if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) { - return true; - } - else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) { - return true; - } - } - - return false; - } - - protected static boolean isFatal(Player player, int damage) { - return player.getHealth() - damage < 1; - } - protected static int calculateModifiedDodgeDamage(int damage, int damageModifier) { return Math.max(damage / damageModifier, 1); } @@ -64,10 +33,4 @@ public final class Acrobatics { protected static int calculateModifiedRollDamage(int damage, int damageThreshold) { return Math.max(damage - damageThreshold, 0); } - - protected static boolean isSuccessfulRoll(Player player, double maxChance, int maxLevel, int successModifier) { - double successChance = (maxChance / maxLevel) * Math.min(Users.getPlayer(player).getProfile().getSkillLevel(SkillType.ACROBATICS), maxLevel) * successModifier; - - return successChance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, SkillType.ACROBATICS)); - } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 7afe50e6d..1c5fb4ffb 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -1,5 +1,8 @@ package com.gmail.nossr50.skills.acrobatics; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LightningStrike; import org.bukkit.entity.Player; import com.gmail.nossr50.datatypes.McMMOPlayer; @@ -17,6 +20,25 @@ public class AcrobaticsManager extends SkillManager { super(mcMMOPlayer, SkillType.ACROBATICS); } + public boolean canRoll() { + Player player = getPlayer(); + + return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player); + } + + public boolean canDodge(Entity damager) { + if (Permissions.dodge(getPlayer())) { + if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) { + return true; + } + else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) { + return true; + } + } + + return false; + } + /** * Handle the damage reduction and XP gain from the Dodge ability * @@ -27,7 +49,7 @@ public class AcrobaticsManager extends SkillManager { int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier); Player player = getPlayer(); - if (!Acrobatics.isFatal(player, modifiedDamage) && SkillTools.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) { + if (!isFatal(modifiedDamage) && SkillTools.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) { ParticleEffectUtils.playDodgeEffect(player); PlayerProfile playerProfile = getProfile(); @@ -62,32 +84,46 @@ public class AcrobaticsManager extends SkillManager { int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold); - if (!Acrobatics.isFatal(player, modifiedDamage) && Acrobatics.isSuccessfulRoll(player, Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) { + if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) { player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); applyXpGain(damage * Acrobatics.rollXpModifier); return modifiedDamage; } - else if (!Acrobatics.isFatal(player, damage)) { + else if (!isFatal(damage)) { applyXpGain(damage * Acrobatics.fallXpModifier); } return damage; } + /** + * Handle the damage reduction and XP gain from the Graceful Roll ability + * + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the roll was successful, the original event damage otherwise + */ private int gracefulRollCheck(Player player, int damage) { int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold); - if (!Acrobatics.isFatal(player, modifiedDamage) && Acrobatics.isSuccessfulRoll(player, Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) { + if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) { player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); applyXpGain(damage * Acrobatics.rollXpModifier); return modifiedDamage; } - else if (!Acrobatics.isFatal(player, damage)) { + else if (!isFatal(damage)) { applyXpGain(damage * Acrobatics.fallXpModifier); } return damage; } + + private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) { + return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance); + } + + private boolean isFatal(int damage) { + return getPlayer().getHealth() - damage < 1; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index 7ebc022cc..797d68ea7 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -5,16 +5,11 @@ import java.util.Iterator; import java.util.List; import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; public class Archery { private static List trackedEntities = new ArrayList(); @@ -32,18 +27,6 @@ public class Archery { public static double distanceXpModifer = 0.025; - public static boolean canDaze(Player player, LivingEntity target) { - return target instanceof Player && Permissions.daze(player); - } - - public static boolean canSkillShot(Player player) { - return SkillTools.unlockLevelReached(player, SkillType.ARCHERY, skillShotIncreaseLevel) && Permissions.bonusDamage(player, SkillType.ARCHERY); - } - - public static boolean canTrackArrows(Player player) { - return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player); - } - protected static void incrementTrackerValue(LivingEntity livingEntity) { for (TrackedEntity trackedEntity : trackedEntities) { if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) { diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 38820c456..dc2016988 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.skills.archery; import org.bukkit.Location; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; @@ -12,6 +13,7 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class ArcheryManager extends SkillManager { @@ -19,6 +21,22 @@ public class ArcheryManager extends SkillManager { super(mcMMOPlayer, SkillType.ARCHERY); } + public boolean canDaze(LivingEntity target) { + return target instanceof Player && Permissions.daze(getPlayer()); + } + + public boolean canSkillShot() { + Player player = getPlayer(); + + return SkillTools.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill); + } + + public boolean canTrackArrows() { + Player player = getPlayer(); + + return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player); + } + /** * Calculate bonus XP awarded for Archery when hitting a far-away target. * diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index 7d1199fd2..1e0671b9b 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -28,8 +28,6 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.skills.SkillManagerStore; -import com.gmail.nossr50.skills.acrobatics.Acrobatics; -import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.runnables.CombatXpGiver; import com.gmail.nossr50.skills.swords.Swords; @@ -252,7 +250,7 @@ public final class CombatTools { ItemStack heldItem = player.getItemInHand(); - if (Acrobatics.canDodge(player, damager)) { + if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canDodge(damager)) { event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event.getDamage())); } @@ -284,7 +282,7 @@ public final class CombatTools { if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) { String playerName = shooter.getName(); - if (Archery.canSkillShot(shooter)) { + if (SkillManagerStore.getInstance().getArcheryManager(playerName).canSkillShot()) { event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).skillShotCheck(event.getDamage())); } @@ -292,11 +290,11 @@ public final class CombatTools { SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck(event); } - if (Archery.canDaze(shooter, target)) { + if (SkillManagerStore.getInstance().getArcheryManager(playerName).canDaze(target)) { event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).dazeCheck((Player) target, event.getDamage())); } - if (Archery.canTrackArrows(shooter)) { + if (SkillManagerStore.getInstance().getArcheryManager(playerName).canTrackArrows()) { SkillManagerStore.getInstance().getArcheryManager(playerName).trackArrows(target); } From a28d673eb7e716b3800db373d70a339edb924310 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 15:59:16 -0500 Subject: [PATCH 072/137] Reworking the AxeManager. --- .../gmail/nossr50/config/AdvancedConfig.java | 1 + .../axes/AxeBonusDamageEventHandler.java | 31 ---- .../gmail/nossr50/skills/axes/AxeManager.java | 143 ++++++++++++++---- .../com/gmail/nossr50/skills/axes/Axes.java | 15 ++ .../skills/axes/CriticalHitEventHandler.java | 61 -------- .../skills/axes/ImpactEventHandler.java | 104 ------------- .../axes/SkullSplitterEventHandler.java | 23 --- .../nossr50/skills/utilities/CombatTools.java | 29 ++-- src/main/resources/advanced.yml | 2 + 9 files changed, 145 insertions(+), 264 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/axes/AxeBonusDamageEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/axes/CriticalHitEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/axes/SkullSplitterEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 87bfb4496..f6d0f130b 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -65,6 +65,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); } public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); } + public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact_Chance", 25.0D); } public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); } public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxeBonusDamageEventHandler.java b/src/main/java/com/gmail/nossr50/skills/axes/AxeBonusDamageEventHandler.java deleted file mode 100644 index 2caf3edc1..000000000 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxeBonusDamageEventHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.gmail.nossr50.skills.axes; - -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class AxeBonusDamageEventHandler { - private int skillLevel; - private EntityDamageByEntityEvent event; - private int damageBonus; - - public AxeBonusDamageEventHandler(AxeManager manager, EntityDamageByEntityEvent event) { - this.skillLevel = manager.getSkillLevel(); - this.event = event; - } - - protected void calculateDamageBonus() { - int increaseLevel = Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus; - - /* Add 1 DMG for every 50 skill levels (default value) */ - damageBonus = skillLevel / increaseLevel; - - if (damageBonus > Axes.bonusDamageMaxBonus) { - damageBonus = Axes.bonusDamageMaxBonus; - } - } - - protected void modifyEventDamage() { - int damage = event.getDamage(); - - event.setDamage(damage + damageBonus); - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java index d3bcf5f71..fc720f869 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java @@ -1,67 +1,148 @@ package com.gmail.nossr50.skills.axes; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.utilities.AbilityType; +import com.gmail.nossr50.skills.utilities.CombatTools; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.skills.utilities.ToolType; +import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.ParticleEffectUtils; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; public class AxeManager extends SkillManager { public AxeManager(McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, SkillType.AXES); } - /** - * Apply bonus to damage done by axes. - * - * @param event The event to modify - */ - public void bonusDamage(EntityDamageByEntityEvent event) { - AxeBonusDamageEventHandler eventHandler = new AxeBonusDamageEventHandler(this, event); + public boolean canUseAxeMastery() { + return Permissions.bonusDamage(getPlayer(), skill); + } - eventHandler.calculateDamageBonus(); - eventHandler.modifyEventDamage(); + public boolean canCriticalHit(LivingEntity target) { + return target.isValid() && Permissions.criticalStrikes(getPlayer()); + } + + public boolean canImpact(LivingEntity target) { + return target.isValid() && Permissions.armorImpact(getPlayer()) && Axes.hasArmor(target); + } + + public boolean canGreaterImpact(LivingEntity target) { + return target.isValid() && Permissions.greaterImpact(getPlayer()) && !Axes.hasArmor(target); + } + + public boolean canUseSkullSplitter(LivingEntity target) { + return target.isValid() && getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer()); + } + + public boolean canActivateAbility() { + return getProfile().getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer()); } /** - * Check for critical chances on axe damage. + * Handle the effects of the Axe Mastery ability * - * @param event The event to modify + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage */ - public void criticalHitCheck(EntityDamageByEntityEvent event, LivingEntity target) { - CriticalHitEventHandler eventHandler = new CriticalHitEventHandler(this, event, target); + public int axeMasteryCheck(int damage) { + int axeBonus = Math.min(getSkillLevel() / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus); - double chance = (Axes.criticalHitMaxChance / Axes.criticalHitMaxBonusLevel) * eventHandler.skillModifier; + return damage + axeBonus; + } - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.modifyEventDamage(); - eventHandler.sendAbilityMessages(); + /** + * Handle the effects of the Critical Hit ability + * + * @param target The {@link LivingEntity} being affected by the ability + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the ability was successful, the original event damage otherwise + */ + public int criticalHitCheck(LivingEntity target, int damage) { + Player player = getPlayer(); + + if (SkillTools.activationSuccessful(player, skill, Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) { + player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit")); + + if (target instanceof Player) { + ((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck")); + + return (int) (damage * Axes.criticalHitPVPModifier); + } + + return (int) (damage * Axes.criticalHitPVEModifier); + } + + return damage; + } + + /** + * Handle the effects of the Impact ability + * + * @param target The {@link LivingEntity} being affected by Impact + */ + public void impactCheck(LivingEntity target) { + int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel); + + for (ItemStack armor : target.getEquipment().getArmorContents()) { + if (ItemChecks.isArmor(armor) && SkillTools.activationSuccessful(getPlayer(), skill, Axes.impactChance)) { + double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior + double modifiedDurabilityDamage = durabilityDamage * durabilityModifier; + double maxDurabilityDamage = (ModChecks.isCustomArmor(armor) ? ModChecks.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability()) * Axes.impactMaxDurabilityDamageModifier; + + armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability())); + } } } /** - * Check for Impact ability. + * Handle the effects of the Greater Impact ability * - * @param event The event to modify + * @param target The {@link LivingEntity} being affected by the ability + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the ability was successful, the original event damage otherwise */ - public void impact(EntityDamageByEntityEvent event, LivingEntity target) { - ImpactEventHandler eventHandler = new ImpactEventHandler(this, event, target); + public int greaterImpactCheck(LivingEntity target, int damage) { + Player player = getPlayer(); - if (!eventHandler.applyImpact()) { - eventHandler.applyGreaterImpact(); + if (SkillTools.activationSuccessful(player, skill, Axes.greaterImpactChance)) { + ParticleEffectUtils.playGreaterImpactEffect(target); + target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier)); + + if (getProfile().useChatNotifications()) { + player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc")); + } + + if (target instanceof Player) { + Player defender = (Player) target; + + if (Users.getPlayer(defender).getProfile().useChatNotifications()) { + defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck")); + } + } + + return damage + Axes.greaterImpactBonusDamage; } + + return damage; } /** - * Check for Skull Splitter ability. + * Handle the effects of the Skull Splitter ability * - * @param target The entity hit by Skull Splitter - * @param damage The base damage to deal + * @param target The {@link LivingEntity} being affected by the ability + * @param damage The amount of damage initially dealt by the event */ - public void skullSplitter(LivingEntity target, int damage) { - SkullSplitterEventHandler eventHandler = new SkullSplitterEventHandler(mcMMOPlayer.getPlayer(), damage, target); - eventHandler.applyAbilityEffects(); + public void skullSplitterCheck(LivingEntity target, int damage) { + CombatTools.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill); } } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java index 0fd7d60a5..6beb94881 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java @@ -1,6 +1,10 @@ package com.gmail.nossr50.skills.axes; +import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.ItemStack; + import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.util.ItemChecks; public class Axes { public static int bonusDamageMaxBonus = AdvancedConfig.getInstance().getBonusDamageAxesBonusMax(); @@ -12,6 +16,7 @@ public class Axes { public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getAxesCriticalPVEModifier(); public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel(); + public static double impactChance = AdvancedConfig.getInstance().getImpactChance(); public static double impactMaxDurabilityDamageModifier = AdvancedConfig.getInstance().getArmorImpactMaxDurabilityDamage() / 100D; public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance(); @@ -19,4 +24,14 @@ public class Axes { public static int greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage(); public static int skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier(); + + protected static boolean hasArmor(LivingEntity target) { + for (ItemStack itemStack : target.getEquipment().getArmorContents()) { + if (ItemChecks.isArmor(itemStack)) { + return true; + } + } + + return false; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/CriticalHitEventHandler.java b/src/main/java/com/gmail/nossr50/skills/axes/CriticalHitEventHandler.java deleted file mode 100644 index 4b8d3d875..000000000 --- a/src/main/java/com/gmail/nossr50/skills/axes/CriticalHitEventHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.gmail.nossr50.skills.axes; - -import org.bukkit.Effect; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.util.Users; - -public class CriticalHitEventHandler { - private AxeManager manager; - private EntityDamageByEntityEvent event; - private int damage; - - protected LivingEntity defender; - protected int skillModifier; - - public CriticalHitEventHandler(AxeManager manager, EntityDamageByEntityEvent event, LivingEntity defender) { - this.manager = manager; - this.event = event; - this.defender = defender; - this.damage = event.getDamage(); - - calculateSkillModifier(); - } - - protected void modifyEventDamage() { - if (defender instanceof Player) { - event.setDamage((int) (damage * Axes.criticalHitPVPModifier)); - } - else { - event.setDamage((int) (damage * Axes.criticalHitPVEModifier)); - } - } - - protected void sendAbilityMessages() { - McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer(); - Player attacker = mcMMOPlayer.getPlayer(); - - attacker.playEffect(defender.getEyeLocation(), Effect.MOBSPAWNER_FLAMES, 0); - - if (mcMMOPlayer.getProfile().useChatNotifications()) { - attacker.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit")); - } - - if (defender instanceof Player) { - Player defendingPlayer = (Player) defender; - - if (Users.getPlayer(defendingPlayer).getProfile().useChatNotifications()) { - defendingPlayer.sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck")); - } - } - } - - private void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Axes.criticalHitMaxBonusLevel); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java b/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java deleted file mode 100644 index daa081487..000000000 --- a/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.gmail.nossr50.skills.axes; - -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.inventory.EntityEquipment; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.util.ItemChecks; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.ParticleEffectUtils; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class ImpactEventHandler { - private AxeManager manager; - private Player player; - private EntityDamageByEntityEvent event; - private short durabilityDamage = 1; - private EntityEquipment entityEquipment; - protected LivingEntity defender; - boolean impactApplied; - - public ImpactEventHandler(AxeManager manager, EntityDamageByEntityEvent event, LivingEntity defender) { - this.manager = manager; - this.player = manager.getMcMMOPlayer().getPlayer(); - this.event = event; - this.defender = defender; - this.entityEquipment = defender.getEquipment(); - } - - protected boolean applyImpact() { - // Every 50 Skill Levels you gain 1 durability damage (default values) - durabilityDamage += (short) (manager.getSkillLevel() / Axes.impactIncreaseLevel); - // getArmorContents.length can't be used because it's always equal to 4 (no armor = air block) - boolean hasArmor = false; - - for (ItemStack itemStack : entityEquipment.getArmorContents()) { - if (ItemChecks.isArmor(itemStack)) { - hasArmor = true; - - if (Misc.getRandom().nextInt(100) < 25) { - damageArmor(itemStack); - } - } - } - - return hasArmor; - } - - private void damageArmor(ItemStack armor) { - // Modifier simulate the durability enchantment behavior - float modifier = 1; - - if (armor.containsEnchantment(Enchantment.DURABILITY)) { - modifier /= armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1; - } - - float modifiedDurabilityDamage = durabilityDamage * modifier; - short maxDurabilityDamage = ModChecks.isCustomArmor(armor) ? ModChecks.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability(); - maxDurabilityDamage *= Axes.impactMaxDurabilityDamageModifier; - - if (modifiedDurabilityDamage > maxDurabilityDamage) { - modifiedDurabilityDamage = maxDurabilityDamage; - } - - armor.setDurability((short) (modifiedDurabilityDamage + armor.getDurability())); - } - - protected void applyGreaterImpact() { - if (!Permissions.greaterImpact(player)) { - return; - } - - if (Misc.getRandom().nextInt(manager.getActivationChance()) <= Axes.greaterImpactChance) { - handleGreaterImpactEffect(); - sendAbilityMessge(); - } - } - - private void handleGreaterImpactEffect() { - event.setDamage(event.getDamage() + Axes.greaterImpactBonusDamage); - - ParticleEffectUtils.playGreaterImpactEffect(defender); - defender.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier)); - } - - private void sendAbilityMessge() { - if (manager.getMcMMOPlayer().getProfile().useChatNotifications()) { - player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc")); - } - - if (defender instanceof Player) { - Player defendingPlayer = (Player) defender; - - if (Users.getPlayer(defendingPlayer).getProfile().useChatNotifications()) { - defendingPlayer.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck")); - } - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/axes/SkullSplitterEventHandler.java b/src/main/java/com/gmail/nossr50/skills/axes/SkullSplitterEventHandler.java deleted file mode 100644 index d4f8ef05f..000000000 --- a/src/main/java/com/gmail/nossr50/skills/axes/SkullSplitterEventHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gmail.nossr50.skills.axes; - -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.skills.utilities.CombatTools; -import com.gmail.nossr50.skills.utilities.SkillType; - -public class SkullSplitterEventHandler { - private Player player; - private LivingEntity target; - private int damage; - - protected SkullSplitterEventHandler(Player player, int damage, LivingEntity target) { - this.player = player; - this.target = target; - this.damage = damage; - } - - protected void applyAbilityEffects() { - CombatTools.applyAbilityAoE(player, target, damage / Axes.skullSplitterModifier, SkillType.AXES); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index 1e0671b9b..566859c6c 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -28,6 +28,7 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.skills.SkillManagerStore; +import com.gmail.nossr50.skills.axes.AxeManager; import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.runnables.CombatXpGiver; import com.gmail.nossr50.skills.swords.Swords; @@ -106,32 +107,32 @@ public final class CombatTools { } if (Permissions.skillEnabled(player, SkillType.AXES)) { - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); - PlayerProfile profile = mcMMOPlayer.getProfile(); - String playerName = player.getName(); + AxeManager axeManager = SkillManagerStore.getInstance().getAxeManager(player.getName()); - boolean canSkullSplit = Permissions.skullSplitter(player); //So we don't have to check the same permission twice - if (profile.getToolPreparationMode(ToolType.AXE) && canSkullSplit) { + if (axeManager.canActivateAbility()) { SkillTools.abilityCheck(player, SkillType.AXES); } - if (Permissions.bonusDamage(player, SkillType.AXES)) { - SkillManagerStore.getInstance().getAxeManager(playerName).bonusDamage(event); + if (axeManager.canUseAxeMastery()) { + event.setDamage(axeManager.axeMasteryCheck(event.getDamage())); } - if (!target.isDead() && Permissions.criticalStrikes(player)) { - SkillManagerStore.getInstance().getAxeManager(playerName).criticalHitCheck(event, target); + if (axeManager.canCriticalHit(target)) { + event.setDamage(axeManager.criticalHitCheck(target, event.getDamage())); } - if (!target.isDead() && Permissions.armorImpact(player)) { - SkillManagerStore.getInstance().getAxeManager(playerName).impact(event, target); + if (axeManager.canImpact(target)) { + axeManager.impactCheck(target); + } + else if (axeManager.canGreaterImpact(target)){ + event.setDamage(axeManager.greaterImpactCheck(target, event.getDamage())); } - if (!target.isDead() && profile.getAbilityMode(AbilityType.SKULL_SPLITTER) && canSkullSplit) { - SkillManagerStore.getInstance().getAxeManager(playerName).skullSplitter(target, event.getDamage()); + if (axeManager.canUseSkullSplitter(target)) { + axeManager.skullSplitterCheck(target, event.getDamage()); } - startGainXp(mcMMOPlayer, target, SkillType.AXES); + startGainXp(axeManager.getMcMMOPlayer(), target, SkillType.AXES); } } else if (heldItemType == Material.AIR) { diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 0d60c90b6..e9a028b85 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -95,8 +95,10 @@ Skills: GreaterImpact_BonusDamage: 2 # ArmorImpact_IncreaseLevel: Every "IncreaseLevel" the durability damage goes up with 1 + # ArmorImpact_Chance: Chance of hitting with ArmorImpact # ArmorImpact_MaxPercentageDurabilityDamage: Durability damage cap for ArmorImpact, 20% means that you can never destroy a piece of armor in less than 5 hits ArmorImpact_IncreaseLevel: 50 + ArmorImpact_Chance: 25.0 ArmorImpact_MaxPercentageDurabilityDamage: 20.0 # SkullSplitter_DamageModifier: Damage will get divided by this modifier From 38c38915335b53f66843651a7525a6c43d65ac23 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 16:00:15 -0500 Subject: [PATCH 073/137] Minor JD fixes. --- .../java/com/gmail/nossr50/skills/archery/ArcheryManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index dc2016988..ca95cdf9f 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -72,9 +72,9 @@ public class ArcheryManager extends SkillManager { /** * Handle the effects of the Daze ability * - * @param defender The player being affected by Daze + * @param defender The player being affected by the ability * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the dodge was successful, the original event damage otherwise + * @return the modified event damage if the ability was successful, the original event damage otherwise */ public int dazeCheck(Player defender, int damage) { Player attacker = getPlayer(); From 4392e6b9ababb26e5c62bf0d2ad59e5f1425c3be Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 16:06:13 -0500 Subject: [PATCH 074/137] Minor tweaks. --- .../nossr50/skills/acrobatics/AcrobaticsManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 1c5fb4ffb..060b09050 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -43,7 +43,7 @@ public class AcrobaticsManager extends SkillManager { * Handle the damage reduction and XP gain from the Dodge ability * * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the dodge was successful, the original event damage otherwise + * @return the modified event damage if the ability was successful, the original event damage otherwise */ public int dodgeCheck(int damage) { int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier); @@ -73,13 +73,13 @@ public class AcrobaticsManager extends SkillManager { * Handle the damage reduction and XP gain from the Roll ability * * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the roll was successful, the original event damage otherwise + * @return the modified event damage if the ability was successful, the original event damage otherwise */ public int rollCheck(int damage) { Player player = getPlayer(); if (player.isSneaking() && Permissions.gracefulRoll(player)) { - return gracefulRollCheck(player, damage); + return gracefulRollCheck(damage); } int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold); @@ -101,13 +101,13 @@ public class AcrobaticsManager extends SkillManager { * Handle the damage reduction and XP gain from the Graceful Roll ability * * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the roll was successful, the original event damage otherwise + * @return the modified event damage if the ability was successful, the original event damage otherwise */ - private int gracefulRollCheck(Player player, int damage) { + private int gracefulRollCheck(int damage) { int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold); if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) { - player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); + getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); applyXpGain(damage * Acrobatics.rollXpModifier); return modifiedDamage; From f388948f04982a016faebd933da05e6fe3d739fc Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 18:06:30 -0500 Subject: [PATCH 075/137] Hire an Excavation manager. --- .../nossr50/listeners/BlockListener.java | 8 ++- .../nossr50/skills/SkillManagerStore.java | 10 +++ .../nossr50/skills/excavation/Excavation.java | 64 ++++--------------- .../skills/excavation/ExcavationManager.java | 59 +++++++++++++++++ .../nossr50/skills/utilities/CombatTools.java | 7 +- 5 files changed, 86 insertions(+), 62 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 0224ded51..74dc1dfd5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -29,7 +29,8 @@ import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.runnables.StickyPistonTracker; -import com.gmail.nossr50.skills.excavation.Excavation; +import com.gmail.nossr50.skills.SkillManagerStore; +import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.mining.Mining; import com.gmail.nossr50.skills.repair.Repair; @@ -202,10 +203,11 @@ public class BlockListener implements Listener { /* EXCAVATION */ else if (BlockChecks.affectedByGigaDrillBreaker(blockState) && ItemChecks.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) { - Excavation.excavationBlockCheck(blockState, player); + ExcavationManager excavationManager = SkillManagerStore.getInstance().getExcavationManager(player.getName()); + excavationManager.excavationBlockCheck(blockState); if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { - Excavation.gigaDrillBreaker(blockState, player); + excavationManager.gigaDrillBreaker(blockState); } } diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java index 64d391e69..c03b0a483 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java @@ -5,6 +5,7 @@ import java.util.HashMap; import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; import com.gmail.nossr50.skills.archery.ArcheryManager; import com.gmail.nossr50.skills.axes.AxeManager; +import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.swords.SwordsManager; @@ -18,6 +19,7 @@ public class SkillManagerStore { private HashMap acrobaticsManagers = new HashMap(); private HashMap archeryManagers = new HashMap(); private HashMap axeManagers = new HashMap(); + private HashMap excavationManagers = new HashMap(); private HashMap miningManagers = new HashMap(); private HashMap smeltingManagers = new HashMap(); private HashMap swordsManagers = new HashMap(); @@ -56,6 +58,14 @@ public class SkillManagerStore { return axeManagers.get(playerName); } + public ExcavationManager getExcavationManager(String playerName) { + if (!excavationManagers.containsKey(playerName)) { + excavationManagers.put(playerName, new ExcavationManager(Users.getPlayer(playerName))); + } + + return excavationManagers.get(playerName); + } + public MiningManager getMiningManager(String playerName) { if (!miningManagers.containsKey(playerName)) { miningManagers.put(playerName, new MiningManager(Users.getPlayer(playerName))); diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index 6d935ca45..5fcfb2556 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -3,75 +3,23 @@ package com.gmail.nossr50.skills.excavation; import java.util.ArrayList; import java.util.List; -import org.bukkit.Location; import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.TreasuresConfig; -import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.skills.utilities.PerksUtils; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; public class Excavation { - /** - * Process treasure drops & XP gain for Excavation. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - */ - public static void excavationBlockCheck(BlockState blockState, Player player) { - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); - int xp = Config.getInstance().getXp(SkillType.EXCAVATION, blockState.getType()); - - if (xp == 0 && ModChecks.isCustomExcavationBlock(blockState)) { - xp = ModChecks.getCustomBlock(blockState).getXpGain(); - } - - if (Permissions.excavationTreasureHunter(player)) { - List treasures = getTreasures(blockState); - - if (!treasures.isEmpty()) { - int skillLevel = mcMMOPlayer.getProfile().getSkillLevel(SkillType.EXCAVATION); - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.EXCAVATION); - Location location = blockState.getLocation(); - - for (ExcavationTreasure treasure : treasures) { - if (skillLevel >= treasure.getDropLevel() && Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) { - xp += treasure.getXp(); - Misc.dropItem(location, treasure.getDrop()); - } - } - } - } - - mcMMOPlayer.beginXpGain(SkillType.EXCAVATION, xp); - } - - /** - * Process the Giga Drill Breaker ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - */ - public static void gigaDrillBreaker(BlockState blockState, Player player) { - Excavation.excavationBlockCheck(blockState, player); - Excavation.excavationBlockCheck(blockState, player); - } - /** * Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block. * * @param blockState The {@link BlockState} of the block to check. * @return the list of treasures that could be found */ - private static List getTreasures(BlockState blockState) { + protected static List getTreasures(BlockState blockState) { switch (blockState.getType()) { case DIRT: return TreasuresConfig.getInstance().excavationFromDirt; @@ -98,4 +46,14 @@ public class Excavation { return new ArrayList(); } } + + protected static int getBlockXP(BlockState blockState) { + int xp = Config.getInstance().getXp(SkillType.EXCAVATION, blockState.getType()); + + if (xp == 0 && ModChecks.isCustomExcavationBlock(blockState)) { + xp = ModChecks.getCustomBlock(blockState).getXpGain(); + } + + return xp; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java new file mode 100644 index 000000000..d47fdc4fc --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -0,0 +1,59 @@ +package com.gmail.nossr50.skills.excavation; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; + +public class ExcavationManager extends SkillManager { + public ExcavationManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.EXCAVATION); + } + + /** + * Process treasure drops & XP gain for Excavation. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + */ + public void excavationBlockCheck(BlockState blockState) { + int xp = Excavation.getBlockXP(blockState); + + if (Permissions.excavationTreasureHunter(getPlayer())) { + List treasures = Excavation.getTreasures(blockState); + + if (!treasures.isEmpty()) { + int skillLevel = getSkillLevel(); + Location location = blockState.getLocation(); + + for (ExcavationTreasure treasure : treasures) { + if (skillLevel >= treasure.getDropLevel() && Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) { + xp += treasure.getXp(); + Misc.dropItem(location, treasure.getDrop()); + } + } + } + } + + applyXpGain(xp); + } + + /** + * Process the Giga Drill Breaker ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + */ + public void gigaDrillBreaker(BlockState blockState) { + excavationBlockCheck(blockState); + excavationBlockCheck(blockState); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index 566859c6c..de07ffdf6 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -97,12 +97,7 @@ public final class CombatTools { } } else if (ItemChecks.isAxe(heldItem)) { - if (targetIsPlayer || targetIsTamedPet) { - if (!SkillType.AXES.getPVPEnabled()) { - return; - } - } - else if (!SkillType.AXES.getPVEEnabled()) { + if (((targetIsPlayer || targetIsTamedPet) && !SkillType.AXES.getPVPEnabled()) || (!targetIsPlayer && !targetIsTamedPet && !SkillType.AXES.getPVEEnabled())) { return; } From 3db676253117f4bd4cba9872585c2ec14fe4cec0 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 18:08:28 -0500 Subject: [PATCH 076/137] Javadoc updates. --- .../com/gmail/nossr50/skills/excavation/ExcavationManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index d47fdc4fc..8d55517c9 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -22,7 +22,6 @@ public class ExcavationManager extends SkillManager { * Process treasure drops & XP gain for Excavation. * * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability */ public void excavationBlockCheck(BlockState blockState) { int xp = Excavation.getBlockXP(blockState); @@ -50,7 +49,6 @@ public class ExcavationManager extends SkillManager { * Process the Giga Drill Breaker ability. * * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability */ public void gigaDrillBreaker(BlockState blockState) { excavationBlockCheck(blockState); From e46ed07b946849ca50dd73234d6ec12e95cb95bc Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 18:12:40 -0500 Subject: [PATCH 077/137] Goodbye, unused imports. --- .../com/gmail/nossr50/skills/excavation/ExcavationManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index 8d55517c9..ae214ad49 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -4,7 +4,6 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; From 0201ed332fbd00cbc48001495d0cd500da6d4e81 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 18:21:14 -0500 Subject: [PATCH 078/137] Quit passing this event around. --- .../nossr50/listeners/EntityListener.java | 16 +++---- .../gmail/nossr50/skills/fishing/Fishing.java | 44 +++++++++---------- .../nossr50/skills/herbalism/Herbalism.java | 7 ++- .../nossr50/skills/utilities/SkillTools.java | 8 ++-- 4 files changed, 34 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index c1cc7ab7c..a0963eda9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -388,23 +388,23 @@ public class EntityListener implements Listener { case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ - Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, event); - break; + event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, newFoodLevel)); + return; case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ - Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, event); - break; + event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, newFoodLevel)); + return; case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ - Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, event); - break; + event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, newFoodLevel)); + return; case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ - Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, event); - break; + event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, newFoodLevel)); + return; default: return; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index 18ba8a36d..3f917c5a2 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -8,7 +8,6 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.inventory.ItemStack; @@ -26,30 +25,28 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; public final class Fishing { - static final AdvancedConfig ADVANCED_CONFIG = AdvancedConfig.getInstance(); - // The order of the values is extremely important, a few methods depend on it to work properly protected enum Tier { FIVE(5) { - @Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier5();} - @Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank5();} - @Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank5();}}, + @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier5();} + @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank5();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5();}}, FOUR(4) { - @Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier4();} - @Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank4();} - @Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank4();}}, + @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier4();} + @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank4();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4();}}, THREE(3) { - @Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier3();} - @Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank3();} - @Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank3();}}, + @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier3();} + @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank3();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3();}}, TWO(2) { - @Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier2();} - @Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank2();} - @Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank2();}}, + @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier2();} + @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank2();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2();}}, ONE(1) { - @Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier1();} - @Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank1();} - @Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank1();}}; + @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier1();} + @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank1();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1();}}; int numerical; @@ -67,7 +64,7 @@ public final class Fishing { } // TODO: Get rid of that - public static int fishermansDietRankLevel1 = ADVANCED_CONFIG.getFishermanDietRankChange(); + public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange(); public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2; public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5; @@ -80,14 +77,13 @@ public final class Fishing { * @param rankChange ??? * @param event Event to process */ - public static void beginFishermansDiet(Player player, int rankChange, FoodLevelChangeEvent event) { + public static int beginFishermansDiet(Player player, int rankChange, int eventFoodLevel) { // TODO: The permission should probably not be checked here - // TODO: Also I don't like the idea of moving event around if (!Permissions.fishermansDiet(player)) { - return; + return eventFoodLevel; } - SkillTools.handleFoodSkills(player, SkillType.FISHING, event, fishermansDietRankLevel1, fishermansDietMaxLevel, rankChange); + return SkillTools.handleFoodSkills(player, SkillType.FISHING, eventFoodLevel, fishermansDietRankLevel1, fishermansDietMaxLevel, rankChange); } /** @@ -198,7 +194,7 @@ public final class Fishing { activationChance = (int) (activationChance * 0.909); } - if (Misc.getRandom().nextInt(activationChance) > getLootTier(skillLevel) * ADVANCED_CONFIG.getFishingMagicMultiplier()) { + if (Misc.getRandom().nextInt(activationChance) > getLootTier(skillLevel) * AdvancedConfig.getInstance().getFishingMagicMultiplier()) { return false; } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 61f69e361..d50549528 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -9,7 +9,6 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; -import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -57,12 +56,12 @@ public class Herbalism { * @param rankChange The # of levels to change rank for the food * @param event The actual FoodLevelChange event */ - public static void farmersDiet(Player player, int rankChange, FoodLevelChangeEvent event) { + public static int farmersDiet(Player player, int rankChange, int eventFoodLevel) { if (!Permissions.farmersDiet(player)) { - return; + return eventFoodLevel; } - SkillTools.handleFoodSkills(player, SkillType.HERBALISM, event, farmersDietRankLevel1, farmersDietMaxLevel, rankChange); + return SkillTools.handleFoodSkills(player, SkillType.HERBALISM, eventFoodLevel, farmersDietRankLevel1, farmersDietMaxLevel, rankChange); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java index d3203ba64..d90a0eb42 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java @@ -7,7 +7,6 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; -import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; @@ -38,12 +37,11 @@ import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class SkillTools { - public static void handleFoodSkills(Player player, SkillType skill, FoodLevelChangeEvent event, int baseLevel, int maxLevel, int rankChange) { + public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) { int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill); int currentFoodLevel = player.getFoodLevel(); - int newFoodLevel = event.getFoodLevel(); - int foodChange = newFoodLevel - currentFoodLevel; + int foodChange = eventFoodLevel - currentFoodLevel; for (int i = baseLevel; i <= maxLevel; i+= rankChange) { if (skillLevel >= i) { @@ -51,7 +49,7 @@ public class SkillTools { } } - event.setFoodLevel(currentFoodLevel + foodChange); + return currentFoodLevel + foodChange; } /** From 18510ba851acd20c5cb5a133376414ffbaf2f6a9 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 18:26:52 -0500 Subject: [PATCH 079/137] Don't check the permissions here. --- .../gmail/nossr50/listeners/EntityListener.java | 16 ++++++++++++---- .../gmail/nossr50/skills/fishing/Fishing.java | 5 ----- .../nossr50/skills/herbalism/Herbalism.java | 4 ---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index a0963eda9..e789ba304 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -388,22 +388,30 @@ public class EntityListener implements Listener { case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ - event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, newFoodLevel)); + if (Permissions.farmersDiet(player)) { + event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, newFoodLevel)); + } return; case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ - event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, newFoodLevel)); + if (Permissions.farmersDiet(player)) { + event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, newFoodLevel)); + } return; case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ - event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, newFoodLevel)); + if (Permissions.fishermansDiet(player)) { + event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, newFoodLevel)); + } return; case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ - event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, newFoodLevel)); + if (Permissions.fishermansDiet(player)) { + event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, newFoodLevel)); + } return; default: diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index 3f917c5a2..80403f66f 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -78,11 +78,6 @@ public final class Fishing { * @param event Event to process */ public static int beginFishermansDiet(Player player, int rankChange, int eventFoodLevel) { - // TODO: The permission should probably not be checked here - if (!Permissions.fishermansDiet(player)) { - return eventFoodLevel; - } - return SkillTools.handleFoodSkills(player, SkillType.FISHING, eventFoodLevel, fishermansDietRankLevel1, fishermansDietMaxLevel, rankChange); } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index d50549528..b3d043903 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -57,10 +57,6 @@ public class Herbalism { * @param event The actual FoodLevelChange event */ public static int farmersDiet(Player player, int rankChange, int eventFoodLevel) { - if (!Permissions.farmersDiet(player)) { - return eventFoodLevel; - } - return SkillTools.handleFoodSkills(player, SkillType.HERBALISM, eventFoodLevel, farmersDietRankLevel1, farmersDietMaxLevel, rankChange); } From cbbe436a691cae5a9ee7ffb22771d665e72e304e Mon Sep 17 00:00:00 2001 From: NuclearW Date: Tue, 26 Feb 2013 18:46:15 -0500 Subject: [PATCH 080/137] Added party itemShare mode: EQUAL Slightly cleaner way of handling equal item sharing. Reset the item share modifier back to base when a player leaves the party Added a new config file for the itemWeights Removed the debug messages. Added Lapis_Ore to itemweights.yml Drop the item on the ground if the winningPlayer's inventory is full. Unneccesary Added a feature which allows the party leader to toggle item share categories.... That should be the rest. ItemWeights to Item_Weights --- Changelog.txt | 3 + .../nossr50/config/ItemWeightsConfig.java | 34 +++++++ .../gmail/nossr50/datatypes/McMMOPlayer.java | 15 +++ .../java/com/gmail/nossr50/party/Party.java | 53 ++++++++++ .../com/gmail/nossr50/party/PartyManager.java | 2 + .../com/gmail/nossr50/party/ShareHandler.java | 99 +++++++++++++++---- .../party/commands/PartyInfoCommand.java | 5 + .../party/commands/PartyItemShareCommand.java | 53 ++++++++-- .../com/gmail/nossr50/util/ItemChecks.java | 12 ++- src/main/resources/itemweights.yml | 16 +++ .../resources/locale/locale_en_US.properties | 2 + 11 files changed, 266 insertions(+), 28 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/ItemWeightsConfig.java create mode 100644 src/main/resources/itemweights.yml diff --git a/Changelog.txt b/Changelog.txt index a1b4207c3..8a41a5296 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -41,6 +41,9 @@ Version 1.4.00-dev + Added "Holy Hound" ability to Taming + Added "Shroom Thumb" ability to Herbalism + Added child.yml config file to choose parents for child skills + + Added '/party itemshare ' command to choose party item share mode + + Added '/party itemshare ' command to control items that are shared + + Added itemweights.yml file to determine which items are more valuable for party itemshare = Fixed Green Thumb on wheat not working properly at rank 4 = Fixed Green Thumb and Green Terra consuming twice the amount of seed needed = Fixed Green Terra not also checking Green Thumb permissions diff --git a/src/main/java/com/gmail/nossr50/config/ItemWeightsConfig.java b/src/main/java/com/gmail/nossr50/config/ItemWeightsConfig.java new file mode 100644 index 000000000..9a1dbe00d --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/ItemWeightsConfig.java @@ -0,0 +1,34 @@ +package com.gmail.nossr50.config; + +import org.bukkit.Material; + +import com.gmail.nossr50.util.StringUtils; + +public class ItemWeightsConfig extends ConfigLoader { + private static ItemWeightsConfig instance; + + private ItemWeightsConfig() { + super("itemweights.yml"); + } + + public static ItemWeightsConfig getInstance() { + if (instance == null) { + instance = new ItemWeightsConfig(); + } + + return instance; + } + + @Override + protected void loadKeys() {} + + public int getItemWeight(Material material) { + String materialName = StringUtils.getPrettyItemString(material).replace(" ", "_"); + int itemWeight = config.getInt("Item_Weights.Default"); + + if (config.getInt("Item_Weights." + materialName) > 0) { + itemWeight = config.getInt("Item_Weights." + materialName); + } + return itemWeight; + } +} diff --git a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java index 29e6b373a..ccc45af41 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java @@ -28,6 +28,7 @@ public class McMMOPlayer { private boolean ptpEnabled = true; private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired(); private long ptpTimeout; + private int itemShareModifier; private boolean partyChatMode; private boolean adminChatMode; @@ -242,6 +243,20 @@ public class McMMOPlayer { ptpTimeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); } + public int getItemShareModifier() { + if (itemShareModifier < 10) { + setItemShareModifier(10); + } + return itemShareModifier; + } + + public void setItemShareModifier(int modifier) { + if (modifier < 10) { + modifier = 10; + } + itemShareModifier = modifier; + } + public boolean getAdminChatMode() { return adminChatMode; } diff --git a/src/main/java/com/gmail/nossr50/party/Party.java b/src/main/java/com/gmail/nossr50/party/Party.java index b4a672bc2..6d7ccc7c9 100644 --- a/src/main/java/com/gmail/nossr50/party/Party.java +++ b/src/main/java/com/gmail/nossr50/party/Party.java @@ -14,6 +14,10 @@ public class Party { private boolean locked; private ShareHandler.ShareMode xpShareMode = ShareHandler.ShareMode.NONE; private ShareHandler.ShareMode itemShareMode = ShareHandler.ShareMode.NONE; + private boolean shareLootDrops = true; + private boolean shareMiningDrops = true; + private boolean shareHerbalismDrops = true; + private boolean shareWoodcuttingDrops = true; public List getMembers() { return members; @@ -47,6 +51,39 @@ public class Party { return locked; } + public boolean sharingLootDrops() { + return shareLootDrops; + } + + public boolean sharingMiningDrops() { + return shareMiningDrops; + } + + public boolean sharingHerbalismDrops() { + return shareHerbalismDrops; + } + + public boolean sharingWoodcuttingDrops() { + return shareWoodcuttingDrops; + } + + public List getItemShareCategories() { //TODO Locale the category names! + List shareCategories = new ArrayList(); + if (sharingLootDrops()) { + shareCategories.add("Loot"); + } + if (sharingMiningDrops()) { + shareCategories.add("Mining"); + } + if (sharingHerbalismDrops()) { + shareCategories.add("Herbalism"); + } + if (sharingWoodcuttingDrops()) { + shareCategories.add("Woodcutting"); + } + return shareCategories; + } + public void setName(String name) { this.name = name; } @@ -78,4 +115,20 @@ public class Party { public ShareHandler.ShareMode getItemShareMode() { return itemShareMode; } + + public void setSharingLootDrops(boolean enabled) { + this.shareLootDrops = enabled; + } + + public void setSharingMiningDrops(boolean enabled) { + this.shareMiningDrops = enabled; + } + + public void setSharingHerbalismDrops(boolean enabled) { + this.shareHerbalismDrops = enabled; + } + + public void setSharingWoodcuttingDrops(boolean enabled) { + this.shareWoodcuttingDrops = enabled; + } } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index a4e543e56..72603d5f8 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -223,6 +223,7 @@ public final class PartyManager { if (mcMMOPlayer != null) { mcMMOPlayer.removeParty(); + mcMMOPlayer.setItemShareModifier(10); } } @@ -239,6 +240,7 @@ public final class PartyManager { if (mcMMOPlayer != null) { mcMMOPlayer.removeParty(); + mcMMOPlayer.setItemShareModifier(10); } } diff --git a/src/main/java/com/gmail/nossr50/party/ShareHandler.java b/src/main/java/com/gmail/nossr50/party/ShareHandler.java index 41431780a..d00f63bb2 100644 --- a/src/main/java/com/gmail/nossr50/party/ShareHandler.java +++ b/src/main/java/com/gmail/nossr50/party/ShareHandler.java @@ -8,8 +8,10 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.ItemWeightsConfig; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Users; @@ -34,6 +36,9 @@ public final class ShareHandler { private ShareHandler() {} + private static List nearMembers; + private static int partySize; + /** * Distribute Xp amongst party members. * @@ -48,7 +53,7 @@ public final class ShareHandler { switch (party.getXpShareMode()) { case EQUAL: Player player = mcMMOPlayer.getPlayer(); - List nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); + nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); if (nearMembers.isEmpty()) { return false; @@ -86,38 +91,95 @@ public final class ShareHandler { Item item = event.getItem(); ItemStack itemStack = item.getItemStack(); Party party = mcMMOPlayer.getParty(); + Player player = mcMMOPlayer.getPlayer(); + Player winningPlayer = null; + + ItemStack newStack = itemStack.clone(); + newStack.setAmount(1); + + if (ItemChecks.isMobDrop(itemStack) && !party.sharingLootDrops()) { + return false; + } + else if (ItemChecks.isMiningDrop(itemStack) && !party.sharingMiningDrops()) { + return false; + } + else if (ItemChecks.isHerbalismDrop(itemStack) && !party.sharingHerbalismDrops()) { + return false; + } + else if (ItemChecks.isWoodcuttingDrop(itemStack) && !party.sharingWoodcuttingDrops()) { + return false; + } switch (party.getItemShareMode()) { case EQUAL: - - return false; - case RANDOM: - Player player = mcMMOPlayer.getPlayer(); - List nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); + McMMOPlayer mcMMOTarget; + nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); if (nearMembers.isEmpty()) { return false; } - int partySize = nearMembers.size() + 1; + nearMembers.add(player); + partySize = nearMembers.size(); + + event.setCancelled(true); + item.remove(); + int itemWeight = ItemWeightsConfig.getInstance().getItemWeight(itemStack.getType()); + + for (int i = 0; i < itemStack.getAmount(); i++) { + int highestRoll = 0; + + for (Player member : nearMembers) { + McMMOPlayer mcMMOMember = Users.getPlayer(member); + int itemShareModifier = mcMMOMember.getItemShareModifier(); + int diceRoll = Misc.getRandom().nextInt(itemShareModifier); + + if (diceRoll > highestRoll) { + highestRoll = diceRoll; + + if (winningPlayer != null) { + McMMOPlayer mcMMOWinning = Users.getPlayer(winningPlayer); + mcMMOWinning.setItemShareModifier(mcMMOWinning.getItemShareModifier() + itemWeight); + } + + winningPlayer = member; + } + else { + mcMMOMember.setItemShareModifier(itemShareModifier + itemWeight); + } + } + + mcMMOTarget = Users.getPlayer(winningPlayer); + mcMMOTarget.setItemShareModifier(mcMMOTarget.getItemShareModifier() - itemWeight); + + if (winningPlayer.getInventory().addItem(newStack).size() != 0) { + winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), newStack); + } + winningPlayer.updateInventory(); + } + return true; + case RANDOM: + nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); + + if (nearMembers.isEmpty()) { + return false; + } + partySize = nearMembers.size() + 1; event.setCancelled(true); item.remove(); - Player targetPlayer; - - ItemStack newStack = itemStack.clone(); - newStack.setAmount(1); - - //TODO Improve this, if possible make this faster. for (int i = 0; i < itemStack.getAmount(); i++) { int randomMember = Misc.getRandom().nextInt(partySize); if (randomMember >= nearMembers.size()) { - targetPlayer = player; + winningPlayer = player; } else { - targetPlayer = nearMembers.get(randomMember); + winningPlayer = nearMembers.get(randomMember); } - targetPlayer.getInventory().addItem(newStack); - targetPlayer.updateInventory(); + + if (winningPlayer.getInventory().addItem(newStack).size() != 0) { + winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), newStack); + } + winningPlayer.updateInventory(); } return true; case NONE: @@ -125,5 +187,4 @@ public final class ShareHandler { return false; } } -} - +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java index f5333109f..ac85a4e1a 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java @@ -12,6 +12,7 @@ import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.util.Users; public class PartyInfoCommand implements CommandExecutor { @@ -51,6 +52,7 @@ public class PartyInfoCommand implements CommandExecutor { private void displayShareModeInfo() { boolean xpShareEnabled = Config.getInstance().getExpShareEnabled(); boolean itemShareEnabled = Config.getInstance().getItemShareEnabled(); + boolean itemSharingActive = playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE; if (!xpShareEnabled && !itemShareEnabled) { return; @@ -73,6 +75,9 @@ public class PartyInfoCommand implements CommandExecutor { } player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo); + if (itemSharingActive) { + player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories())); + } } private void displayPartyHeader() { diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java index 903419295..c325b5df9 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java @@ -30,22 +30,50 @@ public class PartyItemShareCommand implements CommandExecutor { if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { handleChangingShareMode(ShareMode.NONE); } -// else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) { -// handleChangingShareMode(ShareMode.EQUAL); -// } + else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) { + handleChangingShareMode(ShareMode.EQUAL); + } else if (args[1].equalsIgnoreCase("random")) { handleChangingShareMode(ShareMode.RANDOM); } else { -// sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); } return true; + + case 3: + playerParty = Users.getPlayer((Player) sender).getParty(); + boolean toggle = false; + + if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("on")|| args[2].equalsIgnoreCase("enabled")) { + toggle = true; + } + else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("off")|| args[2].equalsIgnoreCase("disabled")) { + toggle = false; + } + + if (args[1].equalsIgnoreCase("loot")) { + playerParty.setSharingLootDrops(toggle); + } + else if (args[1].equalsIgnoreCase("mining")) { + playerParty.setSharingMiningDrops(toggle); + } + else if (args[1].equalsIgnoreCase("herbalism")) { + playerParty.setSharingHerbalismDrops(toggle); + } + else if (args[1].equalsIgnoreCase("woodcutting")) { + playerParty.setSharingWoodcuttingDrops(toggle); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + } + notifyToggleItemShareCategory((Player) sender, args, toggle); + return true; default: -// sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); return true; } } @@ -57,4 +85,15 @@ public class PartyItemShareCommand implements CommandExecutor { member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())))); } } + + private void notifyToggleItemShareCategory(Player sender, String[] args, boolean toggle) { + String state = "disabled"; + if (toggle) { + state = "enabled"; + } + + for (Player member : playerParty.getOnlineMembers()) { + member.sendMessage(LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(args[1]), state)); + } + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 6ebc5edba..5f5c309ad 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -579,16 +579,23 @@ public class ItemChecks { case POTATO: case COCOA: case NETHER_WARTS: - case APPLE: case BROWN_MUSHROOM: case RED_MUSHROOM: case RED_ROSE: case YELLOW_FLOWER: case CACTUS: case SUGAR_CANE: - //TODO Add the rest + case MELON: + case PUMPKIN: + case WATER_LILY: + case VINE: return true; + case INK_SACK: + if (is.getData().getData() == DyeColor.BROWN.getDyeData()) { + return true; + } + default: return false; } @@ -635,6 +642,7 @@ public class ItemChecks { case LOG: case LEAVES: case SAPLING: + case APPLE: return true; default: diff --git a/src/main/resources/itemweights.yml b/src/main/resources/itemweights.yml new file mode 100644 index 000000000..7e4a36fa0 --- /dev/null +++ b/src/main/resources/itemweights.yml @@ -0,0 +1,16 @@ +Item_Weights: + Default: 5 + Emerald: 150 + Emerald_Ore: 150 + Diamond: 100 + Diamond_Ore: 100 + Gold_Ingot: 50 + Gold_Ore: 50 + Iron_Ingot: 40 + Iron_Ore: 40 + Lapis_Ore: 30 + Redstone: 30 + Redstone_Ore: 30 + Glowstone_Dust: 20 + Coal: 10 + Coal_Ore: 10 \ No newline at end of file diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 12b685448..5177e7736 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -452,6 +452,7 @@ Commands.Party.Status=[[DARK_GRAY]]NAME: [[WHITE]]{0} {1} Commands.Party.ShareMode=[[DARK_GRAY]]SHARE MODE: Commands.Party.ItemShare=[[GRAY]]ITEM [[DARK_AQUA]]({0}) Commands.Party.ExpShare=[[GRAY]]EXP [[DARK_AQUA]]({0}) +Commands.Party.ItemShareCategories=[[DARK_GRAY]]Sharing Items: [[GRAY]][[ITALIC]]{0} Commands.Party.MembersNear=[[DARK_GRAY]]NEAR YOU [[DARK_AQUA]]{0}[[DARK_GRAY]]/[[DARK_AQUA]]{1} Commands.Party.Accept=[[RED]]- Accept party invite Commands.Party.Chat.Off=Party Chat only [[RED]]Off @@ -465,6 +466,7 @@ Commands.Party.Join=[[GRAY]]Joined Party: {0} Commands.Party.Create=[[GRAY]]Created Party: {0} Commands.Party.Rename=[[GRAY]]Party name changed to: [[WHITE]]{0} Commands.Party.SetSharing=[[GRAY]]Party {0} sharing set to: [[DARK_AQUA]]{1} +Commands.Party.ToggleShareCategory=[[GRAY]]Party item sharing for [[GOLD]]{0} [[GRAY]]has been [[DARK_AQUA]]{1} Commands.Party.AlreadyExists=[[DARK_RED]]Party {0} already exists! Commands.Party.Kick=[[RED]]You were kicked from party {0}! Commands.Party.Leave=[[RED]]You have left that party From 4aaaf01ab514d04385d405d100d36a0af296c192 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 19:36:14 -0500 Subject: [PATCH 081/137] Fix NPE for SpoutPlayers --- src/main/java/com/gmail/nossr50/spout/SpoutListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java b/src/main/java/com/gmail/nossr50/spout/SpoutListener.java index 07972fae0..3e7532389 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutListener.java @@ -29,7 +29,7 @@ public class SpoutListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSpoutCraftEnable(SpoutCraftEnableEvent event) { SpoutPlayer spoutPlayer = event.getPlayer(); - McMMOPlayer mcMMOPlayer = Users.getPlayer(spoutPlayer); + McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer().getPlayer()); PlayerProfile profile = mcMMOPlayer.getProfile(); //TODO: Add custom titles based on skills From 294393bd1c6d35cebfe52afb6244131846fc3a42 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 22:38:22 -0500 Subject: [PATCH 082/137] Work on FishingManager. --- .../nossr50/listeners/EntityListener.java | 4 +- .../nossr50/listeners/PlayerListener.java | 8 +- .../nossr50/skills/SkillManagerStore.java | 10 + .../skills/excavation/ExcavationManager.java | 3 +- .../gmail/nossr50/skills/fishing/Fishing.java | 200 +---------------- .../skills/fishing/FishingCommand.java | 3 +- .../skills/fishing/FishingManager.java | 210 ++++++++++++++++++ .../nossr50/skills/utilities/SkillTools.java | 4 + .../gmail/nossr50/spout/SpoutListener.java | 2 +- 9 files changed, 239 insertions(+), 205 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index e789ba304..b176fc245 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -404,13 +404,13 @@ public class EntityListener implements Listener { case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ if (Permissions.fishermansDiet(player)) { - event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, newFoodLevel)); + event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel)); } return; case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ if (Permissions.fishermansDiet(player)) { - event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, newFoodLevel)); + event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel)); } return; diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index a039fd5a0..a4fc61d91 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -36,6 +36,7 @@ import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.fishing.Fishing; +import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.mining.BlastMining; import com.gmail.nossr50.skills.repair.Repair; @@ -164,12 +165,17 @@ public class PlayerListener implements Listener { return; } + FishingManager fishingManager = SkillManagerStore.getInstance().getFishingManager(player.getName()); McMMOPlayer mcMMOPlayer = Users.getPlayer(player); int skillLevel = mcMMOPlayer.getProfile().getSkillLevel(SkillType.FISHING); switch (event.getState()) { case CAUGHT_FISH: - Fishing.beginFishing(mcMMOPlayer, skillLevel, event); + fishingManager.handleFishing((Item) event.getCaught()); + + if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) { + event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop())); + } break; case CAUGHT_ENTITY: diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java index c03b0a483..a0d9078ba 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; import com.gmail.nossr50.skills.archery.ArcheryManager; import com.gmail.nossr50.skills.axes.AxeManager; import com.gmail.nossr50.skills.excavation.ExcavationManager; +import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.swords.SwordsManager; @@ -20,6 +21,7 @@ public class SkillManagerStore { private HashMap archeryManagers = new HashMap(); private HashMap axeManagers = new HashMap(); private HashMap excavationManagers = new HashMap(); + private HashMap fishingManagers = new HashMap(); private HashMap miningManagers = new HashMap(); private HashMap smeltingManagers = new HashMap(); private HashMap swordsManagers = new HashMap(); @@ -66,6 +68,14 @@ public class SkillManagerStore { return excavationManagers.get(playerName); } + public FishingManager getFishingManager(String playerName) { + if (!fishingManagers.containsKey(playerName)) { + fishingManagers.put(playerName, new FishingManager(Users.getPlayer(playerName))); + } + + return fishingManagers.get(playerName); + } + public MiningManager getMiningManager(String playerName) { if (!miningManagers.containsKey(playerName)) { miningManagers.put(playerName, new MiningManager(Users.getPlayer(playerName))); diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index ae214ad49..fdd2838e3 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -8,6 +8,7 @@ import org.bukkit.block.BlockState; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -33,7 +34,7 @@ public class ExcavationManager extends SkillManager { Location location = blockState.getLocation(); for (ExcavationTreasure treasure : treasures) { - if (skillLevel >= treasure.getDropLevel() && Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) { + if (skillLevel >= treasure.getDropLevel() && SkillTools.treasureDropSuccessful(treasure.getDropChance(), activationChance)) { xp += treasure.getXp(); Misc.dropItem(location, treasure.getDrop()); } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index 80403f66f..da9294989 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -1,28 +1,9 @@ package com.gmail.nossr50.skills.fishing; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerFishEvent; -import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.TreasuresConfig; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.treasure.FishingTreasure; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.PerksUtils; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.ItemChecks; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; public final class Fishing { // The order of the values is extremely important, a few methods depend on it to work properly @@ -67,20 +48,10 @@ public final class Fishing { public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange(); public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2; public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5; + public static final double STORM_MODIFIER = 0.909; private Fishing() {} - /** - * Begins Fisherman's Diet ability - * - * @param player Player using the ability - * @param rankChange ??? - * @param event Event to process - */ - public static int beginFishermansDiet(Player player, int rankChange, int eventFoodLevel) { - return SkillTools.handleFoodSkills(player, SkillType.FISHING, eventFoodLevel, fishermansDietRankLevel1, fishermansDietMaxLevel, rankChange); - } - /** * Begins Shake Mob ability * @@ -91,173 +62,4 @@ public final class Fishing { public static void beginShakeMob(Player player, LivingEntity mob, int skillLevel) { ShakeMob.process(player, mob, skillLevel); } - - /** - * Begins Fishing - * - * @param mcMMOPlayer Player fishing - * @param skillLevel Fishing level of the player - * @param event Event to process - */ - public static void beginFishing(McMMOPlayer mcMMOPlayer, int skillLevel, PlayerFishEvent event) { - int treasureXp = 0; - Player player = mcMMOPlayer.getPlayer(); - FishingTreasure treasure = checkForTreasure(player, skillLevel); - - if (treasure != null) { - player.sendMessage(LocaleLoader.getString("Fishing.ItemFound")); - - treasureXp = treasure.getXp(); - ItemStack treasureDrop = treasure.getDrop(); - - if (Permissions.magicHunter(player) && beginMagicHunter(player, skillLevel, treasureDrop, player.getWorld().hasStorm())) { - player.sendMessage(LocaleLoader.getString("Fishing.MagicFound")); - } - - // Drop the original catch at the feet of the player and set the treasure as the real catch - Item caught = (Item) event.getCaught(); - Misc.dropItem(player.getEyeLocation(), caught.getItemStack()); - caught.setItemStack(treasureDrop); - } - - mcMMOPlayer.beginXpGain(SkillType.FISHING, Config.getInstance().getFishingBaseXP() + treasureXp); - if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) { - event.setExpToDrop(event.getExpToDrop() * getVanillaXpMultiplier(skillLevel)); - } - } - - /** - * Checks for treasure - * - * @param player Player fishing - * @param skillLevel Fishing level of the player - * @return Chosen treasure - */ - private static FishingTreasure checkForTreasure(Player player, int skillLevel) { - if (!Config.getInstance().getFishingDropsEnabled() || !Permissions.fishingTreasureHunter(player)) { - return null; - } - - List rewards = new ArrayList(); - - for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) { - int maxLevel = treasure.getMaxLevel(); - - if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) { - rewards.add(treasure); - } - } - - if (rewards.isEmpty()) { - return null; - } - - FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size())); - ItemStack treasureDrop = treasure.getDrop(); - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.FISHING); - - if (Misc.getRandom().nextDouble() * activationChance > treasure.getDropChance()) { - return null; - } - - short maxDurability = treasureDrop.getType().getMaxDurability(); - - if (maxDurability > 0) { - treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability))); - } - - return treasure; - } - - /** - * Processes for treasure - * - * @param player Player fishing - * @param skillLevel Fishing level of the player - * @param itemStack ItemStack to enchant - * @param storm World's weather - * @return True if the ItemStack has been enchanted - */ - private static boolean beginMagicHunter(Player player, int skillLevel, ItemStack itemStack, boolean storm) { - if (!ItemChecks.isEnchantable(itemStack)) { - return false; - } - - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.FISHING); - - if (storm) { - activationChance = (int) (activationChance * 0.909); - } - - if (Misc.getRandom().nextInt(activationChance) > getLootTier(skillLevel) * AdvancedConfig.getInstance().getFishingMagicMultiplier()) { - return false; - } - - List possibleEnchantments = new ArrayList(); - - for (Enchantment enchantment : Enchantment.values()) { - if (enchantment.canEnchantItem(itemStack)) { - possibleEnchantments.add(enchantment); - } - } - - // This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant - Collections.shuffle(possibleEnchantments, Misc.getRandom()); - - boolean enchanted = false; - int specificChance = 1; - - for (Enchantment possibleEnchantment : possibleEnchantments) { - boolean conflicts = false; - - for (Enchantment currentEnchantment : itemStack.getEnchantments().keySet()) { - conflicts = currentEnchantment.conflictsWith(possibleEnchantment); - - if (conflicts) { - break; - } - } - - if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) { - itemStack.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1); - - specificChance++; - enchanted = true; - } - } - - return enchanted; - } - - /** - * Gets the loot tier for a given skill level - * - * @param skillLevel Fishing skill level - * @return Loot tier - */ - public static int getLootTier(int skillLevel) { - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.toNumerical(); - } - } - - return 0; - } - - /** - * Gets the vanilla xp multiplier for a given skill level - * - * @param skillLevel Fishing skill level - * @return Shake Mob probability - */ - public static int getVanillaXpMultiplier(int skillLevel) { - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getVanillaXPBoostModifier(); - } - } - - return 0; - } } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java index 858341503..3b0731670 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.fishing; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillCommand; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Permissions; @@ -26,7 +27,7 @@ public class FishingCommand extends SkillCommand { @Override protected void dataCalculations() { - lootTier = Fishing.getLootTier((int) skillValue); + lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier(); //TREASURE HUNTER double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier(); diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java new file mode 100644 index 000000000..caba1abcb --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -0,0 +1,210 @@ +package com.gmail.nossr50.skills.fishing; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.TreasuresConfig; +import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.treasure.FishingTreasure; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.fishing.Fishing.Tier; +import com.gmail.nossr50.skills.utilities.SkillTools; +import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; + +public class FishingManager extends SkillManager { + + public FishingManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.FISHING); + } + + /** + * Handle the Fisherman's Diet ability + * + * @param rankChange The # of levels to change rank for the food + * @param eventFoodLevel The initial change in hunger from the event + * @return the modified change in hunger for the event + */ + public int handleFishermanDiet(int rankChange, int eventFoodLevel) { + return SkillTools.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange); + } + + /** + * Process the results from a successful fishing trip + * + * @param fishingCatch The {@link Item} initially caught + */ + public void handleFishing(Item fishingCatch) { + int treasureXp = 0; + Player player = getPlayer(); + FishingTreasure treasure = null; + + if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) { + treasure = getFishingTreasure(); + } + + if (treasure != null) { + player.sendMessage(LocaleLoader.getString("Fishing.ItemFound")); + + treasureXp = treasure.getXp(); + ItemStack treasureDrop = treasure.getDrop(); + + if (Permissions.magicHunter(player) && ItemChecks.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) { + player.sendMessage(LocaleLoader.getString("Fishing.MagicFound")); + } + + // Drop the original catch at the feet of the player and set the treasure as the real catch + Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack()); + fishingCatch.setItemStack(treasureDrop); + } + + applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp); + } + + /** + * Handle the vanilla XP boost for Fishing + * + * @param experience The amount of experience initially awarded by the event + * @return the modified event damage + */ + public int handleVanillaXpBoost(int experience) { + return experience * getVanillaXpMultiplier(); + } + + /** + * Process the Treasure Hunter ability for Fishing + * + * @return The {@link FishingTreasure} found, or null if no treasure was found. + */ + private FishingTreasure getFishingTreasure() { + List rewards = new ArrayList(); + int skillLevel = getSkillLevel(); + + for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) { + int maxLevel = treasure.getMaxLevel(); + + if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) { + rewards.add(treasure); + } + } + + if (rewards.isEmpty()) { + return null; + } + + FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size())); + ItemStack treasureDrop = treasure.getDrop(); + + if (!SkillTools.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) { + return null; + } + + short maxDurability = treasureDrop.getType().getMaxDurability(); + + if (maxDurability > 0) { + treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability))); + } + + return treasure; + } + + /** + * Process the Magic Hunter ability + * + * @param treasureDrop The {@link ItemStack} to enchant + * @return true if the item has been enchanted + */ + private boolean handleMagicHunter(ItemStack treasureDrop) { + Player player = getPlayer(); + int activationChance = this.activationChance; + + if (player.getWorld().hasStorm()) { + activationChance *= Fishing.STORM_MODIFIER; + } + + if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) { + return false; + } + + List possibleEnchantments = new ArrayList(); + + for (Enchantment enchantment : Enchantment.values()) { + if (enchantment.canEnchantItem(treasureDrop)) { + possibleEnchantments.add(enchantment); + } + } + + // This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant + Collections.shuffle(possibleEnchantments, Misc.getRandom()); + + boolean enchanted = false; + int specificChance = 1; + + for (Enchantment possibleEnchantment : possibleEnchantments) { + boolean conflicts = false; + + for (Enchantment currentEnchantment : treasureDrop.getEnchantments().keySet()) { + conflicts = currentEnchantment.conflictsWith(possibleEnchantment); + + if (conflicts) { + break; + } + } + + if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) { + treasureDrop.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1); + + specificChance++; + enchanted = true; + } + } + + return enchanted; + } + + /** + * Gets the loot tier + * + * @return the loot tier + */ + public int getLootTier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.toNumerical(); + } + } + + return 0; + } + + + /** + * Gets the vanilla XP multiplier + * + * @return the vanilla XP multiplier + */ + private int getVanillaXpMultiplier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getVanillaXPBoostModifier(); + } + } + + return 0; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java index d90a0eb42..f57b81962 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java @@ -616,4 +616,8 @@ public class SkillTools { public static boolean unlockLevelReached(Player player, SkillType skill, int unlockLevel) { return Users.getPlayer(player).getProfile().getSkillLevel(skill) > unlockLevel; } + + public static boolean treasureDropSuccessful(double dropChance, int activationChance) { + return dropChance > Misc.getRandom().nextDouble() * activationChance; + } } diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java b/src/main/java/com/gmail/nossr50/spout/SpoutListener.java index 3e7532389..07972fae0 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutListener.java @@ -29,7 +29,7 @@ public class SpoutListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSpoutCraftEnable(SpoutCraftEnableEvent event) { SpoutPlayer spoutPlayer = event.getPlayer(); - McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer().getPlayer()); + McMMOPlayer mcMMOPlayer = Users.getPlayer(spoutPlayer); PlayerProfile profile = mcMMOPlayer.getProfile(); //TODO: Add custom titles based on skills From ec1230383480c1897cac37820f8a28f92c496952 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 22:39:35 -0500 Subject: [PATCH 083/137] Straighten up PartyitemShare a bit. --- .../gmail/nossr50/party/commands/PartyItemShareCommand.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java index c325b5df9..b63856376 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java @@ -68,7 +68,7 @@ public class PartyItemShareCommand implements CommandExecutor { else { sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); } - notifyToggleItemShareCategory((Player) sender, args, toggle); + notifyToggleItemShareCategory(args, toggle); return true; default: @@ -86,8 +86,9 @@ public class PartyItemShareCommand implements CommandExecutor { } } - private void notifyToggleItemShareCategory(Player sender, String[] args, boolean toggle) { + private void notifyToggleItemShareCategory(String[] args, boolean toggle) { String state = "disabled"; + if (toggle) { state = "enabled"; } From 90368d4ece1cc0136f117116924c8f90e6e72242 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 22:42:47 -0500 Subject: [PATCH 084/137] Minor cleanup --- src/main/java/com/gmail/nossr50/util/ItemChecks.java | 4 +--- src/main/java/com/gmail/nossr50/util/LogFilter.java | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 5f5c309ad..39c556dc5 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -592,9 +592,7 @@ public class ItemChecks { return true; case INK_SACK: - if (is.getData().getData() == DyeColor.BROWN.getDyeData()) { - return true; - } + return is.getData().getData() == DyeColor.BROWN.getDyeData(); default: return false; diff --git a/src/main/java/com/gmail/nossr50/util/LogFilter.java b/src/main/java/com/gmail/nossr50/util/LogFilter.java index 1371acc40..dc99931df 100644 --- a/src/main/java/com/gmail/nossr50/util/LogFilter.java +++ b/src/main/java/com/gmail/nossr50/util/LogFilter.java @@ -15,11 +15,10 @@ public class LogFilter implements Filter { @Override public boolean isLoggable(LogRecord record) { - if(record.getMessage().contains("[Debug]") && !debug) { + if (record.getMessage().contains("[Debug]") && !debug) { return false; } - else { - return true; - } + + return true; } } From 0bdd5b219fa8e120db213caa3e5e9757e74a2b5b Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 23:31:00 -0500 Subject: [PATCH 085/137] Finish off FishingManager. --- .../nossr50/listeners/PlayerListener.java | 8 +- .../gmail/nossr50/skills/fishing/Fishing.java | 150 ++++++++++- .../skills/fishing/FishingCommand.java | 2 +- .../skills/fishing/FishingManager.java | 96 ++++++- .../nossr50/skills/fishing/ShakeMob.java | 236 ------------------ 5 files changed, 241 insertions(+), 251 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index a4fc61d91..110f54c5e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -27,7 +27,6 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.chat.ChatManager; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.datatypes.PlayerProfile; @@ -35,7 +34,6 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.skills.SkillManagerStore; -import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.mining.BlastMining; @@ -166,8 +164,6 @@ public class PlayerListener implements Listener { } FishingManager fishingManager = SkillManagerStore.getInstance().getFishingManager(player.getName()); - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); - int skillLevel = mcMMOPlayer.getProfile().getSkillLevel(SkillType.FISHING); switch (event.getState()) { case CAUGHT_FISH: @@ -181,8 +177,8 @@ public class PlayerListener implements Listener { case CAUGHT_ENTITY: Entity entity = event.getCaught(); - if (entity instanceof LivingEntity && skillLevel >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shake(player)) { - Fishing.beginShakeMob(player, (LivingEntity) entity, skillLevel); + if (fishingManager.canShake(entity)) { + fishingManager.shakeCheck((LivingEntity) entity); } break; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index da9294989..bb1e03533 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -1,9 +1,17 @@ package com.gmail.nossr50.skills.fishing; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.DyeColor; +import org.bukkit.Material; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionType; import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.util.Misc; public final class Fishing { // The order of the values is extremely important, a few methods depend on it to work properly @@ -53,13 +61,141 @@ public final class Fishing { private Fishing() {} /** - * Begins Shake Mob ability + * Finds the possible drops of an entity * - * @param player Player using the ability - * @param mob Targeted mob - * @param skillLevel Fishing level of the player + * @param target Targeted entity + * @param possibleDrops List of ItemStack that can be dropped */ - public static void beginShakeMob(Player player, LivingEntity mob, int skillLevel) { - ShakeMob.process(player, mob, skillLevel); + protected static void findPossibleDrops(LivingEntity target, Map possibleDrops) { + switch (target.getType()) { + case BLAZE: + possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100); + break; + + case CAVE_SPIDER: + case SPIDER: + possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50); + possibleDrops.put(new ItemStack(Material.STRING), 50); + break; + + case CHICKEN: + possibleDrops.put(new ItemStack(Material.FEATHER), 34); + possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33); + possibleDrops.put(new ItemStack(Material.EGG), 33); + break; + + case COW: + possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2); + possibleDrops.put(new ItemStack(Material.LEATHER), 49); + possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49); + break; + + case CREEPER: + possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1); + possibleDrops.put(new ItemStack(Material.SULPHUR), 99); + break; + + case ENDERMAN: + possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100); + break; + + case GHAST: + possibleDrops.put(new ItemStack(Material.SULPHUR), 50); + possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50); + break; + + case IRON_GOLEM: + possibleDrops.put(new ItemStack(Material.PUMPKIN), 3); + possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12); + possibleDrops.put(new ItemStack(Material.RED_ROSE), 85); + break; + + case MAGMA_CUBE: + possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100); + break; + + case MUSHROOM_COW: + possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5); + possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5); + possibleDrops.put(new ItemStack(Material.LEATHER), 30); + possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30); + possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30); + break; + + case PIG: + possibleDrops.put(new ItemStack(Material.PORK), 100); + break; + + case PIG_ZOMBIE: + possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50); + possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50); + break; + + case SHEEP: + possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100); + break; + + case SKELETON: + possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2); + possibleDrops.put(new ItemStack(Material.BONE), 49); + possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49); + break; + + case SLIME: + possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100); + break; + + case SNOWMAN: + possibleDrops.put(new ItemStack(Material.PUMPKIN), 3); + possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97); + break; + + case SQUID: + possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100); + break; + + case WITCH: + possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1); + possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1); + possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1); + possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9); + possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13); + possibleDrops.put(new ItemStack(Material.SULPHUR), 12); + possibleDrops.put(new ItemStack(Material.REDSTONE), 13); + possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12); + possibleDrops.put(new ItemStack(Material.STICK), 13); + possibleDrops.put(new ItemStack(Material.SUGAR), 12); + possibleDrops.put(new ItemStack(Material.POTION), 13); + break; + + case ZOMBIE: + possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2); + possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98); + break; + + default: + return; + } + } + + /** + * Randomly chooses a drop among the list + * + * @param possibleDrops List of ItemStack that can be dropped + * @return Chosen ItemStack + */ + protected static ItemStack chooseDrop(Map possibleDrops) { + int dropProbability = Misc.getRandom().nextInt(100); + int cumulatedProbability = 0; + + for (Entry entry : possibleDrops.entrySet()) { + cumulatedProbability += entry.getValue(); + + if (dropProbability < cumulatedProbability) { + return entry.getKey(); + } + } + + return null; } } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java index 3b0731670..eb7db1053 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java @@ -42,7 +42,7 @@ public class FishingCommand extends SkillCommand { magicChanceLucky = treasureHunterStrings[1]; //SHAKE - String[] shakeStrings = calculateAbilityDisplayValues(ShakeMob.getShakeProbability((int) skillValue)); + String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability()); shakeChance = shakeStrings[0]; shakeChanceLucky = shakeStrings[1]; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index caba1abcb..01a378a7b 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -2,11 +2,19 @@ package com.gmail.nossr50.skills.fishing; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.AdvancedConfig; @@ -17,6 +25,7 @@ import com.gmail.nossr50.datatypes.treasure.FishingTreasure; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.fishing.Fishing.Tier; +import com.gmail.nossr50.skills.utilities.CombatTools; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.ItemChecks; @@ -24,11 +33,15 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; public class FishingManager extends SkillManager { - public FishingManager(McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, SkillType.FISHING); } + public boolean canShake(Entity target) { + Player player = getPlayer(); + + return target instanceof LivingEntity && SkillTools.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player); + } /** * Handle the Fisherman's Diet ability * @@ -82,6 +95,71 @@ public class FishingManager extends SkillManager { return experience * getVanillaXpMultiplier(); } + /** + * Handle the Shake ability + * + * @param mob The {@link LivingEntity} affected by the ability + */ + public void shakeCheck(LivingEntity target) { + if (SkillTools.activationSuccessful(getPlayer(), skill, getShakeProbability())) { + Map possibleDrops = new HashMap(); + + Fishing.findPossibleDrops(target, possibleDrops); + + if (possibleDrops.isEmpty()) { + return; + } + + ItemStack drop = Fishing.chooseDrop(possibleDrops); + + // It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100 + if (drop == null) { + return; + } + + // Extra processing depending on the mob and drop type + switch (target.getType()) { + case SHEEP: + Sheep sheep = (Sheep) target; + + if (drop.getType() == Material.WOOL) { + if (sheep.isSheared()) { + return; + } + + drop.setDurability(sheep.getColor().getWoolData()); + sheep.setSheared(true); + } + break; + + case SKELETON: + Skeleton skeleton = (Skeleton) target; + + if (skeleton.getSkeletonType() == SkeletonType.WITHER) { + switch (drop.getType()) { + case SKULL_ITEM: + drop.setDurability((short) 1); + break; + + case ARROW: + drop.setType(Material.COAL); + break; + + default: + break; + } + } + break; + + default: + break; + } + + Misc.dropItem(target.getLocation(), drop); + CombatTools.dealDamage(target, target.getMaxHealth() / 4); // Make it so you can shake a mob no more than 4 times. + } + } + /** * Process the Treasure Hunter ability for Fishing * @@ -190,6 +268,22 @@ public class FishingManager extends SkillManager { return 0; } + /** + * Gets the Shake Mob probability + * + * @return Shake Mob probability + */ + public int getShakeProbability() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getShakeChance(); + } + } + + return 0; + } /** * Gets the vanilla XP multiplier diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java b/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java deleted file mode 100644 index 4a746c8d5..000000000 --- a/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java +++ /dev/null @@ -1,236 +0,0 @@ -package com.gmail.nossr50.skills.fishing; - -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Sheep; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Skeleton.SkeletonType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.Wool; -import org.bukkit.potion.Potion; -import org.bukkit.potion.PotionType; - -import com.gmail.nossr50.skills.fishing.Fishing.Tier; -import com.gmail.nossr50.skills.utilities.CombatTools; -import com.gmail.nossr50.skills.utilities.PerksUtils; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; - -public final class ShakeMob { - private ShakeMob() {} - - /** - * Begins Tree Feller - * - * @param player Player using Shake Mob - * @param mob Targeted entity - * @param skillLevel Fishing level of the player - */ - public static void process(Player player, LivingEntity mob, int skillLevel) { - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.FISHING); - - if (getShakeProbability(skillLevel) <= Misc.getRandom().nextInt(activationChance)) { - return; - } - - Map possibleDrops = new HashMap(); - - findPossibleDrops(mob, possibleDrops); - - if (possibleDrops.isEmpty()) { - return; - } - - ItemStack drop = chooseDrop(possibleDrops); - - // It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100 - if (drop == null) { - return; - } - - // Extra processing depending on the mob and drop type - switch (mob.getType()) { - case SHEEP: - Sheep sheep = (Sheep) mob; - - if (drop.getType() == Material.WOOL) { - if (sheep.isSheared()) { - return; - } - - // TODO: Find a cleaner way to do this, maybe by using Sheep.getColor().getWoolData() (available since 1.4.7-R0.1) - Wool wool = (Wool) drop.getData(); - - wool.setColor(sheep.getColor()); - drop.setDurability(wool.getData()); - sheep.setSheared(true); - } - break; - - case SKELETON: - Skeleton skeleton = (Skeleton) mob; - - if (skeleton.getSkeletonType() == SkeletonType.WITHER) { - switch (drop.getType()) { - case SKULL_ITEM: - drop.setDurability((short) 1); - break; - case ARROW: - drop.setType(Material.COAL); - break; - default: - break; - } - } - break; - - default: - break; - } - - Misc.dropItem(mob.getLocation(), drop); - CombatTools.dealDamage(mob, 1); // We may want to base the damage on the entity max health - } - - /** - * Finds the possible drops of an entity - * - * @param mob Targeted entity - * @param possibleDrops List of ItemStack that can be dropped - */ - private static void findPossibleDrops(LivingEntity mob, Map possibleDrops) { - switch (mob.getType()) { - case BLAZE: - possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100); - break; - case CAVE_SPIDER: - case SPIDER: - possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50); - possibleDrops.put(new ItemStack(Material.STRING), 50); - break; - case CHICKEN: - possibleDrops.put(new ItemStack(Material.FEATHER), 34); - possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33); - possibleDrops.put(new ItemStack(Material.EGG), 33); - break; - case COW: - possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2); - possibleDrops.put(new ItemStack(Material.LEATHER), 49); - possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49); - break; - case CREEPER: - possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1); - possibleDrops.put(new ItemStack(Material.SULPHUR), 99); - break; - case ENDERMAN: - possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100); - break; - case GHAST: - possibleDrops.put(new ItemStack(Material.SULPHUR), 50); - possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50); - break; - case IRON_GOLEM: - possibleDrops.put(new ItemStack(Material.PUMPKIN), 3); - possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12); - possibleDrops.put(new ItemStack(Material.RED_ROSE), 85); - break; - case MAGMA_CUBE: - possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100); - break; - case MUSHROOM_COW: - possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5); - possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5); - possibleDrops.put(new ItemStack(Material.LEATHER), 30); - possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30); - possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30); - break; - case PIG: - possibleDrops.put(new ItemStack(Material.PORK), 100); - break; - case PIG_ZOMBIE: - possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50); - possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50); - break; - case SHEEP: - possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100); - break; - case SKELETON: - possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2); - possibleDrops.put(new ItemStack(Material.BONE), 49); - possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49); - break; - case SLIME: - possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100); - break; - case SNOWMAN: - possibleDrops.put(new ItemStack(Material.PUMPKIN), 3); - possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97); - break; - case SQUID: - possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100); - break; - case WITCH: - possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1); - possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1); - possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1); - possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9); - possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13); - possibleDrops.put(new ItemStack(Material.SULPHUR), 12); - possibleDrops.put(new ItemStack(Material.REDSTONE), 13); - possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12); - possibleDrops.put(new ItemStack(Material.STICK), 13); - possibleDrops.put(new ItemStack(Material.SUGAR), 12); - possibleDrops.put(new ItemStack(Material.POTION), 13); - break; - case ZOMBIE: - possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2); - possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98); - break; - default: - return; - } - } - - /** - * Randomly chooses a drop among the list - * - * @param possibleDrops List of ItemStack that can be dropped - * @return Chosen ItemStack - */ - private static ItemStack chooseDrop(Map possibleDrops) { - int dropProbability = Misc.getRandom().nextInt(100); - int cumulatedProbability = 0; - - for (Entry entry : possibleDrops.entrySet()) { - cumulatedProbability += entry.getValue(); - - if (dropProbability < cumulatedProbability) { - return entry.getKey(); - } - } - - return null; - } - - /** - * Gets the Shake Mob probability for a given skill level - * - * @param skillLevel Fishing skill level - * @return Shake Mob probability - */ - public static int getShakeProbability(int skillLevel) { - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getShakeChance(); - } - } - - return 0; - } -} From 356c97cd67e2c1568a21f8c03c1f9e6146a865b1 Mon Sep 17 00:00:00 2001 From: bm01 Date: Wed, 27 Feb 2013 13:49:56 +0100 Subject: [PATCH 086/137] Fixed CME in BleedTimer --- .../nossr50/skills/runnables/BleedTimer.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java b/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java index a076f6c00..464b6b013 100644 --- a/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java +++ b/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java @@ -27,7 +27,10 @@ public class BleedTimer implements Runnable { continue; } + int damage = 0; + if (entity instanceof Player) { + damage = 1; Player player = (Player) entity; if (!player.isOnline()) { @@ -35,21 +38,30 @@ public class BleedTimer implements Runnable { } // Never kill with Bleeding - if (player.getHealth() - 1 > 0) { - CombatTools.dealDamage(player, 1); + if (player.getHealth() - damage > 0) { + CombatTools.dealDamage(player, damage); ParticleEffectUtils.playBleedEffect(entity); } - entry.setValue(entry.getValue() - 1); + entry.setValue(entry.getValue() - damage); if (entry.getValue() <= 0) { player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Stopped")); } } else { - CombatTools.dealDamage(entity, 2); + damage = 2; + + // Anticipate the entity's death to prevent CME because of our EntityDeathEvent listener + if (entity.getHealth() - damage > 0) { + entry.setValue(entry.getValue() - 1); + } + else { + bleedIterator.remove(); + } + + CombatTools.dealDamage(entity, damage); ParticleEffectUtils.playBleedEffect(entity); - entry.setValue(entry.getValue() - 1); } } } From bbcc8f918e427dff5e7907762cffce774d791041 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 27 Feb 2013 08:32:32 -0500 Subject: [PATCH 087/137] Hire another manager in charge of Herbalism. --- .../nossr50/listeners/BlockListener.java | 24 +- .../nossr50/listeners/EntityListener.java | 4 +- .../nossr50/listeners/PlayerListener.java | 12 +- .../nossr50/skills/SkillManagerStore.java | 10 + .../nossr50/skills/herbalism/Herbalism.java | 271 +--------------- .../skills/herbalism/HerbalismManager.java | 306 ++++++++++++++++++ 6 files changed, 343 insertions(+), 284 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 74dc1dfd5..6627c8e64 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -31,7 +31,7 @@ import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.runnables.StickyPistonTracker; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.excavation.ExcavationManager; -import com.gmail.nossr50.skills.herbalism.Herbalism; +import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.Mining; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; @@ -154,8 +154,10 @@ public class BlockListener implements Listener { /* HERBALISM */ if (BlockChecks.affectedByGreenTerra(blockState)) { + HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName()); + /* Green Terra */ - if (profile.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(player)) { + if (herbalismManager.canActivateAbility()) { SkillTools.abilityCheck(player, SkillType.HERBALISM); } @@ -166,11 +168,11 @@ public class BlockListener implements Listener { if (Permissions.skillEnabled(player, SkillType.HERBALISM)) { //Double drops - Herbalism.herbalismBlockCheck(blockState, player); + herbalismManager.herbalismBlockCheck(blockState); //Triple drops - if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) { - Herbalism.herbalismBlockCheck(blockState, player); + if (herbalismManager.canGreenTerraPlant()) { + herbalismManager.herbalismBlockCheck(blockState); } } } @@ -234,11 +236,12 @@ public class BlockListener implements Listener { return; } + String playerName = player.getName(); BlockState blockState = event.getBlock().getState(); ItemStack heldItem = player.getItemInHand(); - if (Permissions.hylianLuck(player) && ItemChecks.isSword(heldItem)) { - if (Herbalism.processHylianLuck(blockState, player)) { + if (SkillManagerStore.getInstance().getHerbalismManager(playerName).canUseHylianLuck()) { + if (SkillManagerStore.getInstance().getHerbalismManager(playerName).processHylianLuck(blockState)) { blockState.update(true); event.setCancelled(true); } @@ -334,6 +337,7 @@ public class BlockListener implements Listener { return; } + String playerName = player.getName(); McMMOPlayer mcMMOPlayer = Users.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); ItemStack heldItem = player.getItemInHand(); @@ -345,9 +349,9 @@ public class BlockListener implements Listener { * * We don't need to check permissions here because they've already been checked for the ability to even activate. */ - if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(blockState)) { - if (Herbalism.processGreenTerra(blockState, player)) { - blockState.update(); + if (SkillManagerStore.getInstance().getHerbalismManager(playerName).canGreenTerraBlock(blockState)) { + if (SkillManagerStore.getInstance().getHerbalismManager(playerName).processGreenTerra(blockState)) { + blockState.update(true); } } else if (profile.getAbilityMode(AbilityType.BERSERK)) { diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index b176fc245..8418961e1 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -389,7 +389,7 @@ public class EntityListener implements Listener { case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ if (Permissions.farmersDiet(player)) { - event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, newFoodLevel)); + event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel)); } return; @@ -398,7 +398,7 @@ public class EntityListener implements Listener { case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ if (Permissions.farmersDiet(player)) { - event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, newFoodLevel)); + event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel)); } return; diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 110f54c5e..1bd7ed624 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -35,7 +35,7 @@ import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.fishing.FishingManager; -import com.gmail.nossr50.skills.herbalism.Herbalism; +import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.BlastMining; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; @@ -354,17 +354,19 @@ public class PlayerListener implements Listener { } /* GREEN THUMB CHECK */ - if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(blockState)) { + HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName()); + + if (herbalismManager.canGreenThumbBlock(blockState)) { player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1)); - if (Herbalism.processGreenThumbBlocks(blockState, player) && SkillTools.blockBreakSimulate(block, player, false)) { + if (herbalismManager.processGreenThumbBlocks(blockState) && SkillTools.blockBreakSimulate(block, player, false)) { blockState.update(true); } } /* SHROOM THUMB CHECK */ - else if ((heldItem.getType() == Material.RED_MUSHROOM || heldItem.getType() == Material.BROWN_MUSHROOM) && BlockChecks.canMakeShroomy(blockState)) { - if (Herbalism.processShroomThumb(blockState, player) && SkillTools.blockBreakSimulate(block, player, false)) { + else if (herbalismManager.canUseShroomThumb(blockState)) { + if (herbalismManager.processShroomThumb(blockState) && SkillTools.blockBreakSimulate(block, player, false)) { blockState.update(true); } } diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java index a0d9078ba..d4f27f6f4 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java @@ -7,6 +7,7 @@ import com.gmail.nossr50.skills.archery.ArcheryManager; import com.gmail.nossr50.skills.axes.AxeManager; import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.fishing.FishingManager; +import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.swords.SwordsManager; @@ -22,6 +23,7 @@ public class SkillManagerStore { private HashMap axeManagers = new HashMap(); private HashMap excavationManagers = new HashMap(); private HashMap fishingManagers = new HashMap(); + private HashMap herbalismManagers = new HashMap(); private HashMap miningManagers = new HashMap(); private HashMap smeltingManagers = new HashMap(); private HashMap swordsManagers = new HashMap(); @@ -76,6 +78,14 @@ public class SkillManagerStore { return fishingManagers.get(playerName); } + public HerbalismManager getHerbalismManager(String playerName) { + if (!herbalismManagers.containsKey(playerName)) { + herbalismManagers.put(playerName, new HerbalismManager(Users.getPlayer(playerName))); + } + + return herbalismManagers.get(playerName); + } + public MiningManager getMiningManager(String playerName) { if (!miningManagers.containsKey(playerName)) { miningManagers.put(playerName, new MiningManager(Users.getPlayer(playerName))); diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index b3d043903..96179e233 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -1,33 +1,12 @@ package com.gmail.nossr50.skills.herbalism; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.TreasuresConfig; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.datatypes.treasure.HylianTreasure; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.mods.datatypes.CustomBlock; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; public class Herbalism { public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange(); @@ -49,54 +28,14 @@ public class Herbalism { public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax(); public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel(); - /** - * Handle the farmers diet skill. - * - * @param player The player to activate the skill for - * @param rankChange The # of levels to change rank for the food - * @param event The actual FoodLevelChange event - */ - public static int farmersDiet(Player player, int rankChange, int eventFoodLevel) { - return SkillTools.handleFoodSkills(player, SkillType.HERBALISM, eventFoodLevel, farmersDietRankLevel1, farmersDietMaxLevel, rankChange); - } - - /** - * Process the Green Terra ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - * @return true if the ability was successful, false otherwise - */ - public static boolean processGreenTerra(BlockState blockState, Player player) { - PlayerInventory playerInventory = player.getInventory(); - ItemStack seed = new ItemStack(Material.SEEDS); - - if (!playerInventory.containsAtLeast(seed, 1)) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore")); - return false; - } - - playerInventory.removeItem(seed); - player.updateInventory(); // Needed until replacement available - - return convertGreenTerraBlocks(blockState, player); - } - /** * Convert blocks affected by the Green Thumb & Green Terra abilities. * * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability * @return true if the ability was successful, false otherwise */ - private static boolean convertGreenTerraBlocks(BlockState blockState, Player player) { - Material blockType = blockState.getType(); - - if (!Permissions.greenThumbBlock(player, blockType)) { - return false; - } - - switch (blockType) { + protected static boolean convertGreenTerraBlocks(BlockState blockState) { + switch (blockState.getType()) { case COBBLE_WALL: case SMOOTH_BRICK: blockState.setRawData((byte) 0x1); @@ -121,7 +60,7 @@ public class Herbalism { * @param blockState The {@link BlockState} of the bottom block of the plant * @return the number of bonus drops to award from the blocks in this plant */ - private static int calculateCatciAndSugarDrops(BlockState blockState) { + protected static int calculateCatciAndSugarDrops(BlockState blockState) { Block block = blockState.getBlock(); Material blockType = blockState.getType(); int dropAmount = 0; @@ -149,215 +88,13 @@ public class Herbalism { return dropAmount; } - /** - * Process double drops & XP gain for Herbalism. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - * @return true if the ability was successful, false otherwise - */ - public static void herbalismBlockCheck(BlockState blockState, Player player) { - if (Config.getInstance().getHerbalismAFKDisabled() && player.isInsideVehicle()) { - return; - } - - Material blockType = blockState.getType(); - - HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType); - CustomBlock customBlock = null; - - int xp = 0; - int dropAmount = 1; - ItemStack dropItem = null; - - if (herbalismBlock != null) { - if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) { - dropItem = herbalismBlock.getDropItem(); - dropAmount = calculateCatciAndSugarDrops(blockState); - xp = herbalismBlock.getXpGain() * dropAmount; - } - else if (herbalismBlock.hasGreenThumbPermission(player)){ - dropItem = herbalismBlock.getDropItem(); - xp = herbalismBlock.getXpGain(); - processGreenThumbPlants(blockState, player); - } - else { - if (!mcMMO.placeStore.isTrue(blockState)) { - dropItem = herbalismBlock.getDropItem(); - xp = herbalismBlock.getXpGain(); - } - } - } - else { - customBlock = ModChecks.getCustomBlock(blockState); - dropItem = customBlock.getItemDrop(); - xp = customBlock.getXpGain(); - } - - if (Permissions.doubleDrops(player, SkillType.HERBALISM) && SkillTools.activationSuccessful(player, SkillType.HERBALISM, doubleDropsMaxChance, doubleDropsMaxLevel)) { - Location location = blockState.getLocation(); - - if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) { - Misc.dropItems(location, dropItem, dropAmount); - } - else if (customBlock != null){ - int minimumDropAmount = customBlock.getMinimumDropAmount(); - int maximumDropAmount = customBlock.getMaximumDropAmount(); - - if (minimumDropAmount != maximumDropAmount) { - Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); - } - - Misc.dropItems(location, dropItem, minimumDropAmount); - } - } - - Users.getPlayer(player).beginXpGain(SkillType.HERBALISM, xp); - } - - /** - * Process the Green Thumb ability for blocks. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - * @return true if the ability was successful, false otherwise - */ - public static boolean processGreenThumbBlocks(BlockState blockState, Player player) { - if (!SkillTools.activationSuccessful(player, SkillType.HERBALISM, greenThumbMaxChance, greenThumbMaxLevel)) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail")); - return false; - } - - return convertGreenTerraBlocks(blockState, player); - } - - /** - * Process the Green Thumb ability for plants. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - */ - private static void processGreenThumbPlants(BlockState blockState, Player player) { - PlayerInventory playerInventory = player.getInventory(); - ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); - - if (!playerInventory.containsAtLeast(seed, 1)) { - return; - } - - PlayerProfile playerProfile = Users.getPlayer(player).getProfile(); - - if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) { - playerInventory.removeItem(seed); - player.updateInventory(); // Needed until replacement available - - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimer(blockState), 0); - return; - } - else if (SkillTools.activationSuccessful(player, SkillType.HERBALISM, greenThumbMaxChance, greenThumbMaxLevel)) { - playerInventory.removeItem(seed); - player.updateInventory(); // Needed until replacement available - - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimer(blockState, playerProfile.getSkillLevel(SkillType.HERBALISM)), 0); - return; - } - } - - /** - * Process the Hylian Luck ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - * @return true if the ability was successful, false otherwise - */ - public static boolean processHylianLuck(BlockState blockState, Player player) { - if (!SkillTools.activationSuccessful(player, SkillType.HERBALISM, hylianLuckMaxChance, hylianLuckMaxLevel)) { - return false; - } - - List treasures = new ArrayList(); - - switch (blockState.getType()) { - case DEAD_BUSH: - case LONG_GRASS: - case SAPLING: - treasures = TreasuresConfig.getInstance().hylianFromBushes; - break; - - case RED_ROSE: - case YELLOW_FLOWER: - if (mcMMO.placeStore.isTrue(blockState)) { - mcMMO.placeStore.setFalse(blockState); - return false; - } - - treasures = TreasuresConfig.getInstance().hylianFromFlowers; - break; - - case FLOWER_POT: - treasures = TreasuresConfig.getInstance().hylianFromPots; - break; - - default: - return false; - } - - if (treasures.isEmpty()) { - return false; - } - - blockState.setRawData((byte) 0x0); - blockState.setType(Material.AIR); - - Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop()); - player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); - return true; - } - - /** - * Process the Shroom Thumb ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - * @return true if the ability was successful, false otherwise - */ - public static boolean processShroomThumb(BlockState blockState, Player player) { - PlayerInventory playerInventory = player.getInventory(); - - if (!playerInventory.contains(Material.BROWN_MUSHROOM)) { - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM))); - return false; - } - - if (!playerInventory.contains(Material.RED_MUSHROOM)) { - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM))); - return false; - } - - playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM)); - playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM)); - player.updateInventory(); - - if (!SkillTools.activationSuccessful(player, SkillType.HERBALISM, shroomThumbMaxChance, shroomThumbMaxLevel)) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail")); - return false; - } - - return convertShroomThumb(blockState, player); - } - /** * Convert blocks affected by the Green Thumb & Green Terra abilities. * * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability * @return true if the ability was successful, false otherwise */ - private static boolean convertShroomThumb(BlockState blockState, Player player) { - if (!Permissions.shroomThumb(player)) { - return false; - } - + protected static boolean convertShroomThumb(BlockState blockState) { switch (blockState.getType()){ case DIRT: case GRASS: diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java new file mode 100644 index 000000000..74d4d41d5 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -0,0 +1,306 @@ +package com.gmail.nossr50.skills.herbalism; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.TreasuresConfig; +import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.treasure.HylianTreasure; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mods.ModChecks; +import com.gmail.nossr50.mods.datatypes.CustomBlock; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.utilities.AbilityType; +import com.gmail.nossr50.skills.utilities.SkillTools; +import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.skills.utilities.ToolType; +import com.gmail.nossr50.util.BlockChecks; +import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.Users; + +public class HerbalismManager extends SkillManager { + public HerbalismManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.HERBALISM); + } + + public boolean canBlockCheck() { + return !(Config.getInstance().getHerbalismAFKDisabled() && getPlayer().isInsideVehicle()); + } + + public boolean canGreenThumbBlock(BlockState blockState) { + Player player = getPlayer(); + + return player.getItemInHand().getType() == Material.SEEDS && BlockChecks.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); + } + + public boolean canUseShroomThumb(BlockState blockState) { + Player player = getPlayer(); + Material itemType = player.getItemInHand().getType(); + + return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockChecks.canMakeShroomy(blockState) && Permissions.shroomThumb(player); + } + + public boolean canUseHylianLuck() { + Player player = getPlayer(); + + return ItemChecks.isSword(player.getItemInHand()) && Permissions.hylianLuck(player); + } + + public boolean canGreenTerraBlock(BlockState blockState) { + return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(blockState); + } + + public boolean canActivateAbility() { + return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer()); + } + + public boolean canGreenTerraPlant() { + return getProfile().getAbilityMode(AbilityType.GREEN_TERRA); + } + + /** + * Handle the Farmer's Diet ability + * + * @param rankChange The # of levels to change rank for the food + * @param eventFoodLevel The initial change in hunger from the event + * @return the modified change in hunger for the event + */ + public int farmersDiet(int rankChange, int eventFoodLevel) { + return SkillTools.handleFoodSkills(getPlayer(), SkillType.HERBALISM, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange); + } + + /** + * Process the Green Terra ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processGreenTerra(BlockState blockState) { + Player player = getPlayer(); + + if (!Permissions.greenThumbBlock(player, blockState.getType())) { + return false; + } + + PlayerInventory playerInventory = player.getInventory(); + ItemStack seed = new ItemStack(Material.SEEDS); + + if (!playerInventory.containsAtLeast(seed, 1)) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore")); + return false; + } + + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + + return Herbalism.convertGreenTerraBlocks(blockState); + } + + /** + * Process double drops & XP gain for Herbalism. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public void herbalismBlockCheck(BlockState blockState) { + Player player = getPlayer(); + Material blockType = blockState.getType(); + + HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType); + CustomBlock customBlock = null; + + int xp = 0; + int dropAmount = 1; + ItemStack dropItem = null; + + if (herbalismBlock != null) { + if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) { + dropItem = herbalismBlock.getDropItem(); + dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState); + xp = herbalismBlock.getXpGain() * dropAmount; + } + else if (herbalismBlock.hasGreenThumbPermission(player)){ + dropItem = herbalismBlock.getDropItem(); + xp = herbalismBlock.getXpGain(); + processGreenThumbPlants(blockState); + } + else { + if (!mcMMO.placeStore.isTrue(blockState)) { + dropItem = herbalismBlock.getDropItem(); + xp = herbalismBlock.getXpGain(); + } + } + } + else { + customBlock = ModChecks.getCustomBlock(blockState); + dropItem = customBlock.getItemDrop(); + xp = customBlock.getXpGain(); + } + + if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) { + Location location = blockState.getLocation(); + + if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) { + Misc.dropItems(location, dropItem, dropAmount); + } + else if (customBlock != null){ + int minimumDropAmount = customBlock.getMinimumDropAmount(); + int maximumDropAmount = customBlock.getMaximumDropAmount(); + + if (minimumDropAmount != maximumDropAmount) { + Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); + } + + Misc.dropItems(location, dropItem, minimumDropAmount); + } + } + + applyXpGain(xp); + } + + /** + * Process the Green Thumb ability for blocks. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processGreenThumbBlocks(BlockState blockState) { + Player player = getPlayer(); + + if (!SkillTools.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail")); + return false; + } + + return Herbalism.convertGreenTerraBlocks(blockState); + } + + /** + * Process the Hylian Luck ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processHylianLuck(BlockState blockState) { + Player player = getPlayer(); + + if (!SkillTools.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) { + return false; + } + + List treasures = new ArrayList(); + + switch (blockState.getType()) { + case DEAD_BUSH: + case LONG_GRASS: + case SAPLING: + treasures = TreasuresConfig.getInstance().hylianFromBushes; + break; + + case RED_ROSE: + case YELLOW_FLOWER: + if (mcMMO.placeStore.isTrue(blockState)) { + mcMMO.placeStore.setFalse(blockState); + return false; + } + + treasures = TreasuresConfig.getInstance().hylianFromFlowers; + break; + + case FLOWER_POT: + treasures = TreasuresConfig.getInstance().hylianFromPots; + break; + + default: + return false; + } + + if (treasures.isEmpty()) { + return false; + } + + blockState.setRawData((byte) 0x0); + blockState.setType(Material.AIR); + + Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop()); + player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); + return true; + } + + /** + * Process the Shroom Thumb ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processShroomThumb(BlockState blockState) { + Player player = getPlayer(); + PlayerInventory playerInventory = player.getInventory(); + + if (!playerInventory.contains(Material.BROWN_MUSHROOM)) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM))); + return false; + } + + if (!playerInventory.contains(Material.RED_MUSHROOM)) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM))); + return false; + } + + playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM)); + playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM)); + player.updateInventory(); + + if (!SkillTools.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail")); + return false; + } + + return Herbalism.convertShroomThumb(blockState); + } + + /** + * Process the Green Thumb ability for plants. + * + * @param blockState The {@link BlockState} to check ability activation for + */ + private void processGreenThumbPlants(BlockState blockState) { + Player player = getPlayer(); + PlayerInventory playerInventory = player.getInventory(); + ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); + + if (!playerInventory.containsAtLeast(seed, 1)) { + return; + } + + PlayerProfile playerProfile = Users.getPlayer(player).getProfile(); + + if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) { + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimer(blockState), 0); + return; + } + else if (SkillTools.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimer(blockState, getSkillLevel()), 0); + return; + } + } +} From 5ba4dc7b7788169a0b067758dfed795947a24421 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 27 Feb 2013 08:32:46 -0500 Subject: [PATCH 088/137] Leave some room. --- .../java/com/gmail/nossr50/skills/fishing/FishingManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 01a378a7b..d7bb591b3 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -42,6 +42,7 @@ public class FishingManager extends SkillManager { return target instanceof LivingEntity && SkillTools.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player); } + /** * Handle the Fisherman's Diet ability * From a7f858ab035f3ea84d9fdd1bf9a4011230053345 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 27 Feb 2013 11:51:44 -0800 Subject: [PATCH 089/137] Added new Tree Feller algorithm for Huge Red Mushroom --- .../skills/woodcutting/TreeFeller.java | 56 +++++++++++++++++-- .../skills/woodcutting/Woodcutting.java | 2 +- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java index e382dc0db..962c636d1 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java @@ -36,10 +36,13 @@ public final class TreeFeller { * @param mcMMOPlayer Player using Tree Feller * @param blockState Block being broken */ - protected static void process(BlockState blockState, Player player) { + protected static void processTreeFeller(BlockState blockState, Player player) { List treeFellerBlocks = new ArrayList(); - - processRecursively(blockState, treeFellerBlocks); + + if(blockState.getTypeId() == 17 || blockState.getTypeId() == 99) + processRegularTrees(blockState, treeFellerBlocks); + else + processRedMushroomTrees(blockState, treeFellerBlocks); // If the player is trying to break too many blocks if (treeFellerReachedThreshold) { @@ -66,12 +69,12 @@ public final class TreeFeller { } /** - * Processes Tree Feller + * Processes Tree Feller for generic Trees * * @param blockState Block being checked * @param treeFellerBlocks List of blocks to be removed */ - private static void processRecursively(BlockState blockState, List treeFellerBlocks) { + private static void processRegularTrees(BlockState blockState, List treeFellerBlocks) { if (!BlockChecks.isLog(blockState)) { return; } @@ -100,7 +103,48 @@ public final class TreeFeller { return; } - processRecursively(futureCenterBlock, treeFellerBlocks); + processRegularTrees(futureCenterBlock, treeFellerBlocks); + } + } + + /** + * Processes Tree Feller for Red Mushrooms (Dome Shaped) + * + * @param blockState Block being checked + * @param treeFellerBlocks List of blocks to be removed + */ + private static void processRedMushroomTrees(BlockState blockState, List treeFellerBlocks) { + if (!BlockChecks.isLog(blockState)) { + return; + } + + List futureCenterBlocks = new ArrayList(); + World world = blockState.getWorld(); + + // Handle the blocks around 'block' + for (int y = 0; y <= 1; y++) { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState(); + BlockState otherNextBlock = world.getBlockAt(blockState.getLocation().add(x, y-(y*2), z)).getState(); + + handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks); + handleBlock(otherNextBlock, futureCenterBlocks, treeFellerBlocks); + + if (treeFellerReachedThreshold) { + return; + } + } + } + } + + // Recursive call for each log found + for (BlockState futureCenterBlock : futureCenterBlocks) { + if (treeFellerReachedThreshold) { + return; + } + + processRedMushroomTrees(futureCenterBlock, treeFellerBlocks); } } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index 1c36a8d19..c0439b532 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -38,7 +38,7 @@ public final class Woodcutting { * @param block Block being broken */ public static void beginTreeFeller(BlockState blockState, Player player) { - TreeFeller.process(blockState, player); + TreeFeller.processTreeFeller(blockState, player); } /** From c3eaec513ba46c8ce15129cfbfdb4d4a0b1d913c Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 27 Feb 2013 15:45:15 -0500 Subject: [PATCH 090/137] GIANT Blast Mining update. Lots of new config options in advanced.yml --- .../gmail/nossr50/config/AdvancedConfig.java | 45 +++ .../nossr50/listeners/BlockListener.java | 7 +- .../nossr50/listeners/EntityListener.java | 21 +- .../nossr50/listeners/PlayerListener.java | 14 +- .../mining/BiggerBombsEventHandler.java | 42 --- .../nossr50/skills/mining/BlastMining.java | 115 +++++-- .../mining/BlastMiningDropEventHandler.java | 149 --------- .../gmail/nossr50/skills/mining/Mining.java | 31 +- .../nossr50/skills/mining/MiningCommand.java | 76 ++--- .../nossr50/skills/mining/MiningManager.java | 284 +++++++++++++++--- .../mining/RemoteDetonationEventHandler.java | 89 ------ src/main/resources/advanced.yml | 50 +++ .../resources/locale/locale_en_US.properties | 9 +- 13 files changed, 474 insertions(+), 458 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/mining/BiggerBombsEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/mining/BlastMiningDropEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/mining/RemoteDetonationEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index f6d0f130b..d1c3cdec4 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -128,6 +128,51 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { public int getBlastMiningRank7() { return config.getInt("Skills.Mining.BlastMining_Rank7", 875); } public int getBlastMiningRank8() { return config.getInt("Skills.Mining.BlastMining_Rank8", 1000); } + public double getBlastDamageDecreaseRank1() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank1", 0.0D); } + public double getBlastDamageDecreaseRank2() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank2", 0.0D); } + public double getBlastDamageDecreaseRank3() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank3", 0.0D); } + public double getBlastDamageDecreaseRank4() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank4", 25.0D); } + public double getBlastDamageDecreaseRank5() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank5", 25.0D); } + public double getBlastDamageDecreaseRank6() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank6", 50.0D); } + public double getBlastDamageDecreaseRank7() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank7", 50.0D); } + public double getBlastDamageDecreaseRank8() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank8", 100.0D); } + + public double getOreBonusRank1() { return config.getDouble("Skills.Mining.OreBonus_Rank1", 35.0D); } + public double getOreBonusRank2() { return config.getDouble("Skills.Mining.OreBonus_Rank2", 40.0D); } + public double getOreBonusRank3() { return config.getDouble("Skills.Mining.OreBonus_Rank3", 45.0D); } + public double getOreBonusRank4() { return config.getDouble("Skills.Mining.OreBonus_Rank4", 50.0D); } + public double getOreBonusRank5() { return config.getDouble("Skills.Mining.OreBonus_Rank5", 55.0D); } + public double getOreBonusRank6() { return config.getDouble("Skills.Mining.OreBonus_Rank6", 60.0D); } + public double getOreBonusRank7() { return config.getDouble("Skills.Mining.OreBonus_Rank7", 65.0D); } + public double getOreBonusRank8() { return config.getDouble("Skills.Mining.OreBonus_Rank8", 70.0D); } + + public double getDebrisReductionRank1() { return config.getDouble("Skills.Mining.DebrisReduction_Rank1", 10.0D); } + public double getDebrisReductionRank2() { return config.getDouble("Skills.Mining.DebrisReduction_Rank2", 20.0D); } + public double getDebrisReductionRank3() { return config.getDouble("Skills.Mining.DebrisReduction_Rank3", 30.0D); } + public double getDebrisReductionRank4() { return config.getDouble("Skills.Mining.DebrisReduction_Rank4", 30.0D); } + public double getDebrisReductionRank5() { return config.getDouble("Skills.Mining.DebrisReduction_Rank5", 30.0D); } + public double getDebrisReductionRank6() { return config.getDouble("Skills.Mining.DebrisReduction_Rank6", 30.0D); } + public double getDebrisReductionRank7() { return config.getDouble("Skills.Mining.DebrisReduction_Rank7", 30.0D); } + public double getDebrisReductionRank8() { return config.getDouble("Skills.Mining.DebrisReduction_Rank8", 30.0D); } + + public int getDropMultiplierRank1() { return config.getInt("Skills.Mining.DropMultiplier_Rank1", 1); } + public int getDropMultiplierRank2() { return config.getInt("Skills.Mining.DropMultiplier_Rank2", 1); } + public int getDropMultiplierRank3() { return config.getInt("Skills.Mining.DropMultiplier_Rank3", 1); } + public int getDropMultiplierRank4() { return config.getInt("Skills.Mining.DropMultiplier_Rank4", 1); } + public int getDropMultiplierRank5() { return config.getInt("Skills.Mining.DropMultiplier_Rank5", 2); } + public int getDropMultiplierRank6() { return config.getInt("Skills.Mining.DropMultiplier_Rank6", 2); } + public int getDropMultiplierRank7() { return config.getInt("Skills.Mining.DropMultiplier_Rank7", 3); } + public int getDropMultiplierRank8() { return config.getInt("Skills.Mining.DropMultiplier_Rank8", 3); } + + public double getBlastRadiusModifierRank1() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank1", 1.0); } + public double getBlastRadiusModifierRank2() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank2", 1.0); } + public double getBlastRadiusModifierRank3() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank3", 2.0); } + public double getBlastRadiusModifierRank4() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank4", 2.0); } + public double getBlastRadiusModifierRank5() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank5", 3.0); } + public double getBlastRadiusModifierRank6() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank6", 3.0); } + public double getBlastRadiusModifierRank7() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank7", 4.0); } + public double getBlastRadiusModifierRank8() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank8", 4.0); } + /* REPAIR */ public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery_MaxBonusPercentage", 200.0D); } public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 6627c8e64..a95f1fcde 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -32,7 +32,7 @@ import com.gmail.nossr50.runnables.StickyPistonTracker; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; -import com.gmail.nossr50.skills.mining.Mining; +import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.smelting.Smelting; @@ -179,10 +179,11 @@ public class BlockListener implements Listener { /* MINING */ else if (BlockChecks.affectedBySuperBreaker(blockState) && ItemChecks.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) { - Mining.miningBlockCheck(blockState, player); + MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); + miningManager.miningBlockCheck(blockState); if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) { - Mining.miningBlockCheck(blockState, player); + miningManager.miningBlockCheck(blockState); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 8418961e1..02d35ea20 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -36,7 +36,7 @@ import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; -import com.gmail.nossr50.skills.mining.BlastMining; +import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.taming.Taming; import com.gmail.nossr50.skills.utilities.CombatTools; @@ -189,8 +189,10 @@ public class EntityListener implements Listener { break; case BLOCK_EXPLOSION: - if (Permissions.demolitionsExpertise(player)) { - event.setDamage(BlastMining.processDemolitionsExpertise(player, event.getDamage())); + MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); + + if (miningManager.canUseDemolitionsExpertise()) { + event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); @@ -323,10 +325,10 @@ public class EntityListener implements Listener { int id = entity.getEntityId(); if (plugin.tntIsTracked(id)) { - Player player = plugin.getTNTPlayer(id); + MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(plugin.getTNTPlayer(id).getName()); - if (Permissions.biggerBombs(player)) { - SkillManagerStore.getInstance().getMiningManager(player.getName()).biggerBombs(event); + if (miningManager.canUseBiggerBombs()) { + event.setRadius(miningManager.biggerBombs(event.getRadius())); } } } @@ -345,9 +347,12 @@ public class EntityListener implements Listener { int id = entity.getEntityId(); if (plugin.tntIsTracked(id)) { - Player player = plugin.getTNTPlayer(id); + MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(plugin.getTNTPlayer(id).getName()); - SkillManagerStore.getInstance().getMiningManager(player.getName()).blastMiningDropProcessing(event); + if (miningManager.canUseBlastMining()) { + miningManager.blastMiningDropProcessing(event.getYield(), event.blockList()); + event.setYield(0); + } plugin.removeFromTNTTracker(id); } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 1bd7ed624..757177950 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -36,7 +36,6 @@ import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; -import com.gmail.nossr50.skills.mining.BlastMining; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.runnables.BleedTimer; @@ -296,16 +295,21 @@ public class PlayerListener implements Listener { player.updateInventory(); } /* BLAST MINING CHECK */ - else if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) { - SkillManagerStore.getInstance().getMiningManager(player.getName()).detonate(event); + else if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) { + if (blockID == Material.TNT.getId()) { + event.setCancelled(true); // Don't detonate the TNT if they're too close + } + else { + SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation(); + } } break; case RIGHT_CLICK_AIR: /* BLAST MINING CHECK */ - if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) { - SkillManagerStore.getInstance().getMiningManager(player.getName()).detonate(event); + if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) { + SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation(); } break; diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BiggerBombsEventHandler.java b/src/main/java/com/gmail/nossr50/skills/mining/BiggerBombsEventHandler.java deleted file mode 100644 index d7575cb95..000000000 --- a/src/main/java/com/gmail/nossr50/skills/mining/BiggerBombsEventHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.gmail.nossr50.skills.mining; - -import org.bukkit.event.entity.ExplosionPrimeEvent; - -public class BiggerBombsEventHandler { - private int skillLevel; - - private ExplosionPrimeEvent event; - private float radius; - private float radiusModifier; - - protected BiggerBombsEventHandler(MiningManager manager, ExplosionPrimeEvent event) { - this.skillLevel = manager.getSkillLevel(); - - this.event = event; - this.radius = event.getRadius(); - } - - protected void calculateRadiusIncrease() { - if (skillLevel < BlastMining.rank2) { - return; - } - - if (skillLevel >= BlastMining.rank8) { - radiusModifier = 4.0f; - } - else if (skillLevel >= BlastMining.rank6) { - radiusModifier = 3.0f; - } - else if (skillLevel >= BlastMining.rank4) { - radiusModifier = 2.0f; - } - else if (skillLevel >= BlastMining.rank2) { - radiusModifier = 1.0f; - } - } - - protected void modifyBlastRadius() { - radius = radius + radiusModifier; - event.setRadius(radius); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java index 0d31b3acd..0152b0909 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java @@ -1,46 +1,103 @@ package com.gmail.nossr50.skills.mining; -import org.bukkit.entity.Player; +import java.util.HashSet; + +import org.bukkit.Material; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; public class BlastMining { - public static int rank1 = AdvancedConfig.getInstance().getBlastMiningRank1(); - public static int rank2 = AdvancedConfig.getInstance().getBlastMiningRank2(); - public static int rank3 = AdvancedConfig.getInstance().getBlastMiningRank3(); - public static int rank4 = AdvancedConfig.getInstance().getBlastMiningRank4(); - public static int rank5 = AdvancedConfig.getInstance().getBlastMiningRank5(); - public static int rank6 = AdvancedConfig.getInstance().getBlastMiningRank6(); - public static int rank7 = AdvancedConfig.getInstance().getBlastMiningRank7(); - public static int rank8 = AdvancedConfig.getInstance().getBlastMiningRank8(); + // The order of the values is extremely important, a few methods depend on it to work properly + protected enum Tier { + EIGHT(8) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank8();} + @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank8();} + @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank8();} + @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank8();} + @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank8();} + @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank8();}}, + SEVEN(7) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank7();} + @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank7();} + @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank7();} + @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank7();} + @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank7();} + @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank7();}}, + SIX(6) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank6();} + @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank6();} + @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank6();} + @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank6();} + @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank6();} + @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank6();}}, + FIVE(5) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank5();} + @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank5();} + @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank5();} + @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank5();} + @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank5();} + @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank5();}}, + FOUR(4) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank4();} + @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank4();} + @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank4();} + @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank4();} + @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank4();} + @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank4();}}, + THREE(3) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank3();} + @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank3();} + @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank3();} + @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank3();} + @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank3();} + @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank3();}}, + TWO(2) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank2();} + @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank2();} + @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank2();} + @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank2();} + @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank2();} + @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank2();}}, + ONE(1) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank1();} + @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank1();} + @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank1();} + @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank1();} + @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank1();} + @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank1();}}; + + int numerical; + + private Tier(int numerical) { + this.numerical = numerical; + } + + public int toNumerical() { + return numerical; + } + + abstract protected int getLevel(); + abstract protected double getBlastRadiusModifier(); + abstract protected double getOreBonus(); + abstract protected double getDebrisReduction(); + abstract protected double getBlastDamageDecrease(); + abstract protected int getDropMultiplier(); + } public static int detonatorID = Config.getInstance().getDetonatorItemID(); public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100; - public static boolean canUseDemolitionsExpertise(Player player) { - return SkillTools.unlockLevelReached(player, SkillType.MINING, rank4) && Permissions.demolitionsExpertise(player); - } + protected static HashSet generateTransparentBlockList() { + HashSet transparentBlocks = new HashSet(); - public static int processDemolitionsExpertise(Player player, int damage) { - int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.MINING); - int modifiedDamage; - - if (skillLevel >= BlastMining.rank8) { - modifiedDamage = 0; - } - else if (skillLevel >= BlastMining.rank6) { - modifiedDamage = damage / 4; - } - else { - modifiedDamage = damage / 2; + for (Material material : Material.values()) { + if (material.isTransparent()) { + transparentBlocks.add((byte) material.getId()); + } } - return modifiedDamage; + return transparentBlocks; } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMiningDropEventHandler.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMiningDropEventHandler.java deleted file mode 100644 index 77c9ade0b..000000000 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMiningDropEventHandler.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.gmail.nossr50.skills.mining; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.BlockChecks; -import com.gmail.nossr50.util.Misc; - -public class BlastMiningDropEventHandler { - private MiningManager manager; - private int skillLevel; - private EntityExplodeEvent event; - private float yield; - private List blocks; - private List ores = new ArrayList(); - private List debris = new ArrayList(); - private List droppedOres = new ArrayList(); - private float oreBonus; - private float debrisReduction; - private int dropMultiplier; - - public BlastMiningDropEventHandler(MiningManager manager, EntityExplodeEvent event) { - this.manager = manager; - this.skillLevel = manager.getSkillLevel(); - - this.event = event; - this.yield = event.getYield(); - this.blocks = event.blockList(); - } - - protected void sortExplosionBlocks() { - for (Block block : blocks) { - BlockState blockState = block.getState(); - - if (BlockChecks.isOre(blockState)) { - ores.add(blockState); - } - else { - debris.add(blockState); - } - } - } - - protected void processXPGain() { - for (BlockState blockState : droppedOres) { - if (!mcMMO.placeStore.isTrue(blockState)) { - Mining.awardMiningXp(blockState, manager.getMcMMOPlayer().getPlayer()); - } - } - } - - protected void processDroppedBlocks() { - for (BlockState blockState : ores) { - if (Misc.getRandom().nextFloat() < (yield + oreBonus)) { - droppedOres.add(blockState); - Mining.handleMiningDrops(blockState); - - if (!mcMMO.placeStore.isTrue(blockState)) { - for (int i = 1 ; i < dropMultiplier ; i++) { - droppedOres.add(blockState); - Mining.handleMiningDrops(blockState); - } - } - } - } - - float debrisYield = yield - debrisReduction; - - if (debrisYield > 0) { - for (BlockState blockState : debris) { - Location location = blockState.getLocation(); - Material type = blockState.getType(); - - if (Misc.getRandom().nextFloat() < debrisYield) { - Misc.dropItem(location, new ItemStack(type)); - } - } - } - } - - protected void modifyEventYield() { - event.setYield(0); - } - - protected void calcuateDropModifiers() { - calculateOreBonus(); - calculateDebrisReduction(); - calculateDropMultiplier(); - } - - private void calculateOreBonus() { - if (skillLevel >= BlastMining.rank8) { - oreBonus = .70f; - } - else if (skillLevel >= BlastMining.rank7) { - oreBonus = .65f; - } - else if (skillLevel >= BlastMining.rank6) { - oreBonus = .60f; - } - else if (skillLevel >= BlastMining.rank5) { - oreBonus = .55f; - } - else if (skillLevel >= BlastMining.rank4) { - oreBonus = .50f; - } - else if (skillLevel >= BlastMining.rank3) { - oreBonus = .45f; - } - else if (skillLevel >= BlastMining.rank2) { - oreBonus = .40f; - } - else { - debrisReduction = .35f; - } - } - - private void calculateDebrisReduction() { - if (skillLevel >= BlastMining.rank3) { - debrisReduction = .30f; - } - else if (skillLevel >= BlastMining.rank2) { - debrisReduction = .20f; - } - else { - debrisReduction = .10f; - } - } - - private void calculateDropMultiplier() { - if (skillLevel >= BlastMining.rank7) { - dropMultiplier = 3; - } - else if (skillLevel >= BlastMining.rank5) { - dropMultiplier = 2; - } - else { - dropMultiplier = 1; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java index 9655af76e..7dd154666 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -3,19 +3,14 @@ package com.gmail.nossr50.skills.mining; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.BlockState; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.mods.datatypes.CustomBlock; -import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; public class Mining { private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -24,31 +19,11 @@ public class Mining { public static double doubleDropsMaxChance = advancedConfig.getMiningDoubleDropChance(); /** - * Process double drops & XP gain for Mining. + * Calculate XP gain for Mining. * * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability */ - public static void miningBlockCheck(BlockState blockState, Player player) { - awardMiningXp(blockState, player); - - if (Permissions.doubleDrops(player, SkillType.MINING) && SkillTools.activationSuccessful(player, SkillType.MINING, doubleDropsMaxChance, doubleDropsMaxLevel)) { - if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { - handleSilkTouchDrops(blockState); - } - else { - handleMiningDrops(blockState); - } - } - } - - /** - * Award XP gain for Mining. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - */ - protected static void awardMiningXp(BlockState blockState, Player player) { + protected static int getBlockXp(BlockState blockState) { Material blockType = blockState.getType(); int xp = Config.getInstance().getXp(SkillType.MINING, blockType); @@ -59,7 +34,7 @@ public class Mining { xp = ModChecks.getCustomBlock(blockState).getXpGain(); } - Users.getPlayer(player).beginXpGain(SkillType.MINING, xp); + return xp; } /** diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java index 2bee93bd9..dd44ee0f7 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java @@ -1,7 +1,9 @@ package com.gmail.nossr50.skills.mining; +import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillCommand; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Permissions; @@ -10,8 +12,12 @@ public class MiningCommand extends SkillCommand { private String doubleDropChanceLucky; private String superBreakerLength; private String superBreakerLengthEndurance; - private String blastMiningRank; - private String blastRadiusIncrease; + + private int blastMiningRank; + private int bonusTNTDrops; + private double blastRadiusIncrease; + private String oreBonus; + private String debrisReduction; private String blastDamageDecrease; private boolean canSuperBreaker; @@ -38,51 +44,13 @@ public class MiningCommand extends SkillCommand { doubleDropChanceLucky = doubleDropStrings[1]; //BLAST MINING - if (skillValue >= BlastMining.rank8) { - blastMiningRank = "8"; - blastDamageDecrease = "100.00%"; - blastRadiusIncrease = "4"; - } - else if (skillValue >= BlastMining.rank7) { - blastMiningRank = "7"; - blastDamageDecrease = "50.00%"; - blastRadiusIncrease = "3"; - } - else if (skillValue >= BlastMining.rank6) { - blastMiningRank = "6"; - blastDamageDecrease = "50.00%"; - blastRadiusIncrease = "3"; - } - else if (skillValue >= BlastMining.rank5) { - blastMiningRank = "5"; - blastDamageDecrease = "25.00%"; - blastRadiusIncrease = "2"; - } - else if (skillValue >= BlastMining.rank4) { - blastMiningRank = "4"; - blastDamageDecrease = "25.00%"; - blastRadiusIncrease = "2"; - } - else if (skillValue >= BlastMining.rank3) { - blastMiningRank = "3"; - blastDamageDecrease = "0.00%"; - blastRadiusIncrease = "1"; - } - else if (skillValue >= BlastMining.rank2) { - blastMiningRank = "2"; - blastDamageDecrease = "0.00%"; - blastRadiusIncrease = "1"; - } - else if (skillValue >= BlastMining.rank1) { - blastMiningRank = "1"; - blastDamageDecrease = "0.00%"; - blastRadiusIncrease = "0"; - } - else { - blastMiningRank = "0"; - blastDamageDecrease = "0.00%"; - blastRadiusIncrease = "0"; - } + MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); + blastMiningRank = miningManager.getBlastMiningTier(); + bonusTNTDrops = miningManager.getDropMultiplier(); + oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30% + debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30% + blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D); + blastRadiusIncrease = miningManager.getBlastRadiusModifier(); } @Override @@ -151,17 +119,17 @@ public class MiningCommand extends SkillCommand { } if (canBlast) { - if (skillValue < BlastMining.rank1) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", BlastMining.rank1))); + if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank1()) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", AdvancedConfig.getInstance().getBlastMiningRank1()))); } else { - player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Integer.parseInt(blastMiningRank) - 1)))); + player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); } } if (canBiggerBombs) { - if (skillValue < BlastMining.rank2) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", BlastMining.rank2))); + if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank2()) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", AdvancedConfig.getInstance().getBlastMiningRank2()))); } else { player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease)); @@ -169,8 +137,8 @@ public class MiningCommand extends SkillCommand { } if (canDemoExpert) { - if (skillValue < BlastMining.rank4) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", BlastMining.rank4))); + if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank4()) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", AdvancedConfig.getInstance().getBlastMiningRank4()))); } else { player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease)); diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index bf6d55aa6..2f219f4e3 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -1,50 +1,104 @@ package com.gmail.nossr50.skills.mining; -import org.bukkit.Material; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.player.PlayerInteractEvent; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; + +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.mining.BlastMining.Tier; +import com.gmail.nossr50.skills.utilities.AbilityType; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.BlockChecks; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; public class MiningManager extends SkillManager{ public MiningManager (McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, SkillType.MINING); } + public boolean canUseDemolitionsExpertise() { + Player player = getPlayer(); + + return SkillTools.unlockLevelReached(player, skill, BlastMining.Tier.FOUR.getLevel()) && Permissions.demolitionsExpertise(player); + } + + public boolean canDetonate() { + Player player = getPlayer(); + + return player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player) && SkillTools.unlockLevelReached(player, skill, BlastMining.Tier.ONE.getLevel()); + } + + public boolean canUseBlastMining() { + return SkillTools.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.ONE.getLevel()); + } + + public boolean canUseBiggerBombs() { + Player player = getPlayer(); + + return Permissions.biggerBombs(player) && SkillTools.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.TWO.getLevel()); + } + + /** + * Process double drops & XP gain for Mining. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + */ + public void miningBlockCheck(BlockState blockState) { + Player player = getPlayer(); + int xp = Mining.getBlockXp(blockState); + + if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { + if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { + Mining.handleSilkTouchDrops(blockState); + } + else { + Mining.handleMiningDrops(blockState); + } + } + + applyXpGain(xp); + } + /** * Detonate TNT for Blast Mining - * - * @param event The PlayerInteractEvent */ - public void detonate(PlayerInteractEvent event) { - if (getSkillLevel() < BlastMining.rank1) { + public void remoteDetonation() { + Player player = getPlayer(); + + HashSet transparentBlocks = BlastMining.generateTransparentBlockList(); + Block targetBlock = player.getTargetBlock(transparentBlocks, BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE); + + if (targetBlock.getType() != Material.TNT || !SkillTools.blockBreakSimulate(targetBlock, player, true) || !blastMiningCooldownOver()) { return; } - RemoteDetonationEventHandler eventHandler = new RemoteDetonationEventHandler(this, event); + PlayerProfile profile = getProfile(); + TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class); - eventHandler.targetTNT(); + SkillTools.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player)); + player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom")); - if (eventHandler.getBlock().getType() != Material.TNT) { - return; - } + mcMMO.p.addToTNTTracker(tnt.getEntityId(), player.getName()); + tnt.setFuseTicks(0); + targetBlock.setData((byte) 0x0); + targetBlock.setType(Material.AIR); - if (!SkillTools.blockBreakSimulate(eventHandler.getBlock(), mcMMOPlayer.getPlayer(), true)) { - return; - } - - if (!eventHandler.cooldownOver()) { - return; - } - - eventHandler.sendMessages(); - eventHandler.handleDetonation(); - eventHandler.setProfileData(); + profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis()); + profile.setAbilityInformed(AbilityType.BLAST_MINING, false); } /** @@ -52,24 +106,54 @@ public class MiningManager extends SkillManager{ * * @param event Event whose explosion is being processed */ - public void blastMiningDropProcessing(EntityExplodeEvent event) { - if (Misc.isNPCEntity(mcMMOPlayer.getPlayer())) { - return; + public void blastMiningDropProcessing(float yield, List blockList) { + List ores = new ArrayList(); + List debris = new ArrayList(); + int xp = 0; + + float oreBonus = (float) (getOreBonus() / 100); + float debrisReduction = (float) (getDebrisReduction() / 100); + int dropMultiplier = getDropMultiplier(); + + float debrisYield = yield - debrisReduction; + + for (Block block : blockList) { + BlockState blockState = block.getState(); + + if (BlockChecks.isOre(blockState)) { + ores.add(blockState); + } + else { + debris.add(blockState); + } } - if (getSkillLevel() < BlastMining.rank1) { - return; + for (BlockState blockState : ores) { + if (Misc.getRandom().nextFloat() < (yield + oreBonus)) { + if (!mcMMO.placeStore.isTrue(blockState)) { + xp += Mining.getBlockXp(blockState); + } + + Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); // Initial block that would have been dropped + + if (!mcMMO.placeStore.isTrue(blockState)) { + for (int i = 1 ; i < dropMultiplier ; i++) { + xp += Mining.getBlockXp(blockState); + Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items + } + } + } } - BlastMiningDropEventHandler eventHandler = new BlastMiningDropEventHandler(this, event); + if (debrisYield > 0) { + for (BlockState blockState : debris) { + if (Misc.getRandom().nextFloat() < debrisYield) { + Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); + } + } + } - eventHandler.sortExplosionBlocks(); - eventHandler.modifyEventYield(); - - eventHandler.calcuateDropModifiers(); - eventHandler.processDroppedBlocks(); - - eventHandler.processXPGain(); + applyXpGain(xp); } /** @@ -77,14 +161,128 @@ public class MiningManager extends SkillManager{ * * @param event Event whose explosion radius is being changed */ - public void biggerBombs(ExplosionPrimeEvent event) { - if (Misc.isNPCEntity(mcMMOPlayer.getPlayer())) { - return; + public float biggerBombs(float radius) { + return (float) (radius + getBlastRadiusModifier()); + } + + public int processDemolitionsExpertise(int damage) { + return (int) (damage * (100.0 - getBlastDamageModifier())); + } + + private boolean blastMiningCooldownOver() { + Player player = getPlayer(); + PlayerProfile profile = getProfile(); + + long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR; + int cooldown = AbilityType.BLAST_MINING.getCooldown(); + + if (!SkillTools.cooldownOver(oldTime, cooldown, player)) { + player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillTools.calculateTimeLeft(oldTime, cooldown, player))); + return false; } - BiggerBombsEventHandler eventHandler = new BiggerBombsEventHandler(this, event); + return true; + } - eventHandler.calculateRadiusIncrease(); - eventHandler.modifyBlastRadius(); + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public int getBlastMiningTier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.toNumerical(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public double getOreBonus() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getOreBonus(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public double getDebrisReduction() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getDebrisReduction(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public int getDropMultiplier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getDropMultiplier(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public double getBlastRadiusModifier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getBlastRadiusModifier(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public double getBlastDamageModifier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getBlastDamageDecrease(); + } + } + + return 0; } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/RemoteDetonationEventHandler.java b/src/main/java/com/gmail/nossr50/skills/mining/RemoteDetonationEventHandler.java deleted file mode 100644 index d37e52f26..000000000 --- a/src/main/java/com/gmail/nossr50/skills/mining/RemoteDetonationEventHandler.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.gmail.nossr50.skills.mining; - -import java.util.HashSet; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.player.PlayerInteractEvent; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.util.Misc; - -public class RemoteDetonationEventHandler { - private MiningManager manager; - private PlayerInteractEvent event; - private Block block; - private HashSet transparentBlocks = new HashSet(); - - public RemoteDetonationEventHandler(MiningManager manager, PlayerInteractEvent event) { - this.manager = manager; - this.event = event; - this.block = event.getClickedBlock(); - } - - protected void targetTNT() { - if (block == null || block.getType() != Material.TNT) { - generateTransparentBlockList(); - block = manager.getMcMMOPlayer().getPlayer().getTargetBlock(transparentBlocks, BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE); - } - else { - event.setCancelled(true); // This is the only way I know to avoid the original TNT to be triggered (in case the player is close to it) - } - } - - protected boolean cooldownOver() { - McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer(); - Player player = mcMMOPlayer.getPlayer(); - PlayerProfile profile = mcMMOPlayer.getProfile(); - - if (!SkillTools.cooldownOver(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player)) { - player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillTools.calculateTimeLeft(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player))); - - return false; - } - - return true; - } - - protected void sendMessages() { - Player player = manager.getMcMMOPlayer().getPlayer(); - - SkillTools.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player)); - player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom")); - } - - protected void handleDetonation() { - Player player = manager.getMcMMOPlayer().getPlayer(); - TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class); - - mcMMO.p.addToTNTTracker(tnt.getEntityId(), player.getName()); - tnt.setFuseTicks(0); - block.setType(Material.AIR); - } - - protected void setProfileData() { - PlayerProfile profile = manager.getMcMMOPlayer().getProfile(); - - profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis()); - profile.setAbilityInformed(AbilityType.BLAST_MINING, false); - } - - private void generateTransparentBlockList() { - for (Material material : Material.values()) { - if (material.isTransparent()) { - transparentBlocks.add((byte) material.getId()); - } - } - } - - protected Block getBlock() { - return block; - } -} diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index e9a028b85..7dcbae73a 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -183,6 +183,56 @@ Skills: BlastMining_Rank6: 750 BlastMining_Rank7: 875 BlastMining_Rank8: 1000 + + # BlastDamageDecrease_Rank: % of damage reduced from TNT explosions + BlastDamageDecrease_Rank1: 0.0 + BlastDamageDecrease_Rank2: 0.0 + BlastDamageDecrease_Rank3: 0.0 + BlastDamageDecrease_Rank4: 25.0 + BlastDamageDecrease_Rank5: 25.0 + BlastDamageDecrease_Rank6: 50.0 + BlastDamageDecrease_Rank7: 50.0 + BlastDamageDecrease_Rank8: 100.0 + + # OreBonus_Rank: % of extra ores received when Blast Mining + OreBonus_Rank1: 35.0 + OreBonus_Rank2: 40.0 + OreBonus_Rank3: 45.0 + OreBonus_Rank4: 50.0 + OreBonus_Rank5: 55.0 + OreBonus_Rank6: 60.0 + OreBonus_Rank7: 65.0 + OreBonus_Rank8: 70.0 + + # DebrisReduction_Rank: % of fewer non-ores received when Blast Mining + DebrisReduction_Rank1: 10.0 + DebrisReduction_Rank2: 20.0 + DebrisReduction_Rank3: 30.0 + DebrisReduction_Rank4: 30.0 + DebrisReduction_Rank5: 30.0 + DebrisReduction_Rank6: 30.0 + DebrisReduction_Rank7: 30.0 + DebrisReduction_Rank8: 30.0 + + # DropMultiplier_Rank: # of times each ore will drop + DropMultiplier_Rank1: 1 + DropMultiplier_Rank2: 1 + DropMultiplier_Rank3: 1 + DropMultiplier_Rank4: 1 + DropMultiplier_Rank5: 2 + DropMultiplier_Rank6: 2 + DropMultiplier_Rank7: 3 + DropMultiplier_Rank8: 3 + + # BlastRadiusModifier_Rank: Increases the blast radius by this amount + BlastRadiusModifier_Rank1: 1.0 + BlastRadiusModifier_Rank2: 1.0 + BlastRadiusModifier_Rank3: 2.0 + BlastRadiusModifier_Rank4: 2.0 + BlastRadiusModifier_Rank5: 3.0 + BlastRadiusModifier_Rank6: 3.0 + BlastRadiusModifier_Rank7: 4.0 + BlastRadiusModifier_Rank8: 4.0 # # Settings for Repair ### diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 5177e7736..5aa71ee97 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -187,14 +187,7 @@ Mining.Skillup=[[YELLOW]]Mining skill increased by {0}. Total ({1}) #Blast Mining Mining.Blast.Boom=[[GRAY]]**BOOM** -Mining.Blast.Effect.0=+35% ore yield -Mining.Blast.Effect.1=+40% ore yield -Mining.Blast.Effect.2=+45% ore yield, no debris -Mining.Blast.Effect.3=+50% ore yield, no debris -Mining.Blast.Effect.4=+55% ore yield, no debris, double drops -Mining.Blast.Effect.5=+60% ore yield, no debris, double drops -Mining.Blast.Effect.6=+65% ore yield, no debris, triple drops -Mining.Blast.Effect.7=+70% ore yield, no debris, triple drops +Mining.Blast.Effect=+{0} ore yield, -{1} debris yield, {2}x drops Mining.Blast.Radius.Increase=[[RED]]Blast Radius Increase: [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]Blast Mining: [[YELLOW]] Rank {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] has used [[RED]]Blast Mining! From 499411f6a296060ff9533151b4129acbabf16fae Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 27 Feb 2013 18:28:20 -0500 Subject: [PATCH 091/137] SmeltingManager cleaning. --- .../gmail/nossr50/datatypes/McMMOPlayer.java | 19 ++- .../nossr50/listeners/BlockListener.java | 7 +- .../nossr50/listeners/InventoryListener.java | 85 ++++++----- src/main/java/com/gmail/nossr50/mcMMO.java | 12 +- .../smelting/FuelEfficiencyEventHandler.java | 23 --- .../smelting/SmeltResourceEventHandler.java | 57 -------- .../nossr50/skills/smelting/Smelting.java | 99 +++++-------- .../skills/smelting/SmeltingCommand.java | 24 +--- .../skills/smelting/SmeltingManager.java | 136 +++++++++++++----- .../SmeltingVanillaXPEventHandler.java | 39 ----- 10 files changed, 216 insertions(+), 285 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/smelting/FuelEfficiencyEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/smelting/SmeltResourceEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/smelting/SmeltingVanillaXPEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java index ccc45af41..4c1f56d97 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.datatypes; +import java.util.Set; + import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -12,6 +14,7 @@ import com.gmail.nossr50.mods.datatypes.CustomTool; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.ShareHandler; +import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.utilities.PerksUtils; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; @@ -67,10 +70,22 @@ public class McMMOPlayer { * @param xp Experience amount to process */ public void beginXpGain(SkillType skillType, int xp) { - if (xp == 0) { + if (xp == 0) { return; } - + + if (skillType.isChildSkill()) { + Set parentSkills = FamilyTree.getParents(skillType); + + for (SkillType parentSkill : parentSkills) { + if (Permissions.skillEnabled(player, parentSkill)) { + beginXpGain(parentSkill, xp / parentSkills.size()); + } + } + + return; + } + // Return if the experience has been shared if (party != null && ShareHandler.handleXpShare(xp, this, skillType)) { return; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index a95f1fcde..bc62854f8 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -7,7 +7,6 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -35,7 +34,6 @@ import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; -import com.gmail.nossr50.skills.smelting.Smelting; import com.gmail.nossr50.skills.unarmed.Unarmed; import com.gmail.nossr50.skills.utilities.AbilityType; import com.gmail.nossr50.skills.utilities.SkillTools; @@ -239,7 +237,6 @@ public class BlockListener implements Listener { String playerName = player.getName(); BlockState blockState = event.getBlock().getState(); - ItemStack heldItem = player.getItemInHand(); if (SkillManagerStore.getInstance().getHerbalismManager(playerName).canUseHylianLuck()) { if (SkillManagerStore.getInstance().getHerbalismManager(playerName).processHylianLuck(blockState)) { @@ -247,8 +244,8 @@ public class BlockListener implements Listener { event.setCancelled(true); } } - else if (BlockChecks.affectedByFluxMining(blockState) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState)) { - if (Smelting.processFluxMining(blockState, player)) { + else if (SkillManagerStore.getInstance().getSmeltingManager(playerName).canUseFluxMining(blockState)) { + if (SkillManagerStore.getInstance().getSmeltingManager(playerName).processFluxMining(blockState)) { blockState.update(true); event.setCancelled(true); } diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index b127aed13..b5570d016 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -1,8 +1,8 @@ package com.gmail.nossr50.listeners; -import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Furnace; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -13,15 +13,18 @@ import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.FurnaceInventory; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.utilities.SkillTools; +import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class InventoryListener implements Listener{ @@ -33,37 +36,47 @@ public class InventoryListener implements Listener{ @EventHandler(priority = EventPriority.MONITOR) public void onInventoryOpen(InventoryOpenEvent event) { - InventoryType inventoryType = event.getInventory().getType(); + HumanEntity player = event.getPlayer(); - if (inventoryType == InventoryType.FURNACE) { - FurnaceInventory inventory = (FurnaceInventory) event.getInventory(); - Furnace furnace = inventory.getHolder(); + if (Misc.isNPCEntity(player)) { + return; + } + + Inventory inventory = event.getInventory(); + + if (inventory instanceof FurnaceInventory) { + Furnace furnace = (Furnace) inventory.getHolder(); if (furnace == null) { return; } - Block furnaceBlock = furnace.getBlock(); + BlockState furnaceBlock = furnace.getBlock().getState(); if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) { - plugin.addToOpenFurnaceTracker(furnaceBlock, event.getPlayer().getName()); + plugin.addToOpenFurnaceTracker(furnaceBlock, player.getName()); } } } @EventHandler(priority = EventPriority.MONITOR) public void onInventoryClose(InventoryCloseEvent event) { - InventoryType inventoryType = event.getInventory().getType(); + HumanEntity player = event.getPlayer(); - if (inventoryType == InventoryType.FURNACE) { - FurnaceInventory inventory = (FurnaceInventory) event.getInventory(); - Furnace furnace = inventory.getHolder(); + if (Misc.isNPCEntity(player)) { + return; + } + + Inventory inventory = event.getInventory(); + + if (inventory instanceof FurnaceInventory) { + Furnace furnace = (Furnace) inventory.getHolder(); if (furnace == null) { return; } - Block furnaceBlock = furnace.getBlock(); + BlockState furnaceBlock = furnace.getBlock().getState(); if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) { plugin.removeFromFurnaceTracker(furnaceBlock); @@ -73,18 +86,20 @@ public class InventoryListener implements Listener{ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFurnaceBurnEvent(FurnaceBurnEvent event) { - Block furnaceBlock = event.getBlock(); - BlockState blockState = furnaceBlock.getState(); + BlockState furnaceBlock = event.getBlock().getState(); + + if (furnaceBlock instanceof Furnace) { + ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); - if (blockState instanceof Furnace) { - FurnaceInventory inventory = ((Furnace) blockState).getInventory(); - ItemStack smelting = inventory.getSmelting(); - if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) { Player player = plugin.getFurnacePlayer(furnaceBlock); - - if (player != null) { - SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event); + + if (!Misc.isNPCEntity(player)) { + return; + } + + if (Permissions.fuelEfficiency(player)) { + event.setBurnTime(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event.getBurnTime())); } } } @@ -92,18 +107,20 @@ public class InventoryListener implements Listener{ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) { - Block furnaceBlock = event.getBlock(); - BlockState blockState = furnaceBlock.getState(); + BlockState furnaceBlock = event.getBlock().getState(); - if (blockState instanceof Furnace) { - FurnaceInventory inventory = ((Furnace) blockState).getInventory(); - ItemStack smelting = inventory.getSmelting(); + if (furnaceBlock instanceof Furnace) { + ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) { Player player = plugin.getFurnacePlayer(furnaceBlock); - if (player != null) { - SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event); + if (!Misc.isNPCEntity(player)) { + return; + } + + if (Permissions.skillEnabled(player, SkillType.SMELTING)) { + SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event.getSource().getType(), event.getResult()); } } } @@ -111,18 +128,16 @@ public class InventoryListener implements Listener{ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFurnaceExtractEvent(FurnaceExtractEvent event) { - Block furnaceBlock = event.getBlock(); - BlockState blockState = furnaceBlock.getState(); + BlockState furnaceBlock = event.getBlock().getState(); - if (blockState instanceof Furnace) { - FurnaceInventory inventory = ((Furnace) blockState).getInventory(); - ItemStack result = inventory.getResult(); + if (furnaceBlock instanceof Furnace) { + ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult(); if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemChecks.isSmelted(result)) { McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer()); if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) { - SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event); + SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event.getExpToDrop()); } } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 74972690f..935625587 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -10,7 +10,7 @@ import net.shatteredlands.shatt.backup.ZipLibrary; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.metadata.FixedMetadataValue; @@ -66,7 +66,7 @@ public class mcMMO extends JavaPlugin { private final WorldListener worldListener = new WorldListener(); private HashMap tntTracker = new HashMap(); - private HashMap furnaceTracker = new HashMap(); + private HashMap furnaceTracker = new HashMap(); public static mcMMO p; @@ -442,19 +442,19 @@ public class mcMMO extends JavaPlugin { tntTracker.remove(tntID); } - public void addToOpenFurnaceTracker(Block furnace, String playerName) { + public void addToOpenFurnaceTracker(BlockState furnace, String playerName) { furnaceTracker.put(furnace, playerName); } - public boolean furnaceIsTracked(Block furnace) { + public boolean furnaceIsTracked(BlockState furnace) { return furnaceTracker.containsKey(furnace); } - public void removeFromFurnaceTracker(Block furnace) { + public void removeFromFurnaceTracker(BlockState furnace) { furnaceTracker.remove(furnace); } - public Player getFurnacePlayer(Block furnace) { + public Player getFurnacePlayer(BlockState furnace) { return getServer().getPlayer(furnaceTracker.get(furnace)); } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/FuelEfficiencyEventHandler.java b/src/main/java/com/gmail/nossr50/skills/smelting/FuelEfficiencyEventHandler.java deleted file mode 100644 index b875e2ecb..000000000 --- a/src/main/java/com/gmail/nossr50/skills/smelting/FuelEfficiencyEventHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gmail.nossr50.skills.smelting; - -import org.bukkit.event.inventory.FurnaceBurnEvent; - -public class FuelEfficiencyEventHandler { - private SmeltingManager manager; - private FurnaceBurnEvent event; - private double burnModifier; - - protected FuelEfficiencyEventHandler(SmeltingManager manager, FurnaceBurnEvent event) { - this.manager = manager; - this.event = event; - } - - protected void calculateBurnModifier() { - this.burnModifier = 1 + (((double) manager.getSkillLevel() / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier); - } - - protected void modifyBurnTime() { - int burnTime = event.getBurnTime(); - event.setBurnTime((int)(burnTime * burnModifier)); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltResourceEventHandler.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltResourceEventHandler.java deleted file mode 100644 index c8e6947fb..000000000 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltResourceEventHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.gmail.nossr50.skills.smelting; - -import java.util.Set; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.FurnaceSmeltEvent; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.skills.child.FamilyTree; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class SmeltResourceEventHandler { - private SmeltingManager manager; - private FurnaceSmeltEvent event; - - protected int skillModifier; - - protected SmeltResourceEventHandler(SmeltingManager manager, FurnaceSmeltEvent event) { - this.manager = manager; - this.event = event; - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Smelting.secondSmeltMaxLevel); - } - - protected void handleXPGain() { - Material sourceType = event.getSource().getType(); - int xp = Config.getInstance().getXp(SkillType.SMELTING, sourceType); - - if (sourceType == Material.GLOWING_REDSTONE_ORE) { - xp = Config.getInstance().getXp(SkillType.SMELTING, Material.REDSTONE_ORE); - } - - McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer(); - Player player = mcMMOPlayer.getPlayer(); - - Set parentSkills = FamilyTree.getParents(SkillType.SMELTING); - for (SkillType parentSkill : parentSkills) { - if (Permissions.skillEnabled(player, parentSkill)) { - mcMMOPlayer.beginXpGain(parentSkill, xp / parentSkills.size()); - } - } - } - - protected void handleBonusSmelts() { - ItemStack result = event.getResult(); - - result.setAmount(result.getAmount() + 1); - event.setResult(result); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java index 113d6c98f..457fad5af 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java @@ -1,20 +1,44 @@ package com.gmail.nossr50.skills.smelting; -import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.mining.Mining; -import com.gmail.nossr50.skills.utilities.SkillTools; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; public class Smelting { + // The order of the values is extremely important, a few methods depend on it to work properly + protected enum Tier { + FIVE(5) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Level();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Multiplier();}}, + FOUR(4) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Level();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Multiplier();}}, + THREE(3) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Level();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Multiplier();}}, + TWO(2) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Level();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Multiplier();}}, + ONE(1) { + @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level();} + @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Multiplier();}}; + + int numerical; + + private Tier(int numerical) { + this.numerical = numerical; + } + + public int toNumerical() { + return numerical; + } + + abstract protected int getLevel(); + abstract protected int getVanillaXPBoostModifier(); + } + public static int burnModifierMaxLevel = AdvancedConfig.getInstance().getBurnModifierMaxLevel(); public static double burnTimeMultiplier = AdvancedConfig.getInstance().getBurnTimeMultiplier(); @@ -24,60 +48,13 @@ public class Smelting { public static int fluxMiningUnlockLevel = AdvancedConfig.getInstance().getFluxMiningUnlockLevel(); public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance(); - public static int vanillaXPBoostRank1Level = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level(); - public static int vanillaXPBoostRank2Level = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Level(); - public static int vanillaXPBoostRank3Level = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Level(); - public static int vanillaXPBoostRank4Level = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Level(); - public static int vanillaXPBoostRank5Level = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Level(); + protected static int getResourceXp(Material resourceType) { + int xp = Config.getInstance().getXp(SkillType.SMELTING, resourceType); - public static int vanillaXPBoostRank1Multiplier = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Multiplier(); - public static int vanillaXPBoostRank2Multiplier = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Multiplier(); - public static int vanillaXPBoostRank3Multiplier = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Multiplier(); - public static int vanillaXPBoostRank4Multiplier = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Multiplier(); - public static int vanillaXPBoostRank5Multiplier = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Multiplier(); - - /** - * Process the Flux Mining ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - * @return true if the ability was successful, false otherwise - */ - public static boolean processFluxMining(BlockState blockState, Player player) { - if (SkillTools.unlockLevelReached(player, SkillType.SMELTING, fluxMiningUnlockLevel) && SkillTools.activationSuccessful(player, SkillType.SMELTING, fluxMiningChance)) { - ItemStack item = null; - - switch (blockState.getType()) { - case IRON_ORE: - item = new ItemStack(Material.IRON_INGOT); - break; - - case GOLD_ORE: - item = new ItemStack(Material.GOLD_INGOT); - break; - - default: - break; - } - - if (item == null) { - return false; - } - - Location location = blockState.getLocation(); - - Misc.dropItem(location, item); - - if (Permissions.doubleDrops(player, SkillType.SMELTING) && SkillTools.activationSuccessful(player, SkillType.SMELTING, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { - Misc.dropItem(location, item); - } - - blockState.setRawData((byte) 0x0); - blockState.setType(Material.AIR); - player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success")); - return true; + if (resourceType == Material.GLOWING_REDSTONE_ORE) { + xp = Config.getInstance().getXp(SkillType.SMELTING, Material.REDSTONE_ORE); } - return false; + return xp; } } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingCommand.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingCommand.java index 67189231f..58f8fd617 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingCommand.java @@ -1,7 +1,9 @@ package com.gmail.nossr50.skills.smelting; +import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillCommand; +import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Permissions; @@ -11,7 +13,7 @@ public class SmeltingCommand extends SkillCommand { private String secondSmeltChanceLucky; private String fluxMiningChance; private String fluxMiningChanceLucky; - private String vanillaXPModifier; + private int vanillaXPModifier; private boolean canFuelEfficiency; private boolean canSecondSmelt; @@ -38,21 +40,7 @@ public class SmeltingCommand extends SkillCommand { fluxMiningChanceLucky = fluxMiningStrings[1]; //VANILLA XP BOOST - if (skillValue >= Smelting.vanillaXPBoostRank5Level) { - vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank5Multiplier); - } - else if (skillValue >= Smelting.vanillaXPBoostRank4Level) { - vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank4Multiplier); - } - else if (skillValue >= Smelting.vanillaXPBoostRank3Level) { - vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank3Multiplier); - } - else if (skillValue >= Smelting.vanillaXPBoostRank2Level) { - vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank2Multiplier); - } - else { - vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank1Multiplier); - } + vanillaXPModifier = SkillManagerStore.getInstance().getSmeltingManager(player.getName()).getVanillaXpMultiplier(); } @Override @@ -110,8 +98,8 @@ public class SmeltingCommand extends SkillCommand { } if (canVanillaXPBoost) { - if (skillValue < Smelting.vanillaXPBoostRank1Level) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", Smelting.vanillaXPBoostRank1Level))); + if (skillValue < AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()))); } else { player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", vanillaXPModifier)); diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index 71fbc29fc..c8985a680 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -1,71 +1,129 @@ package com.gmail.nossr50.skills.smelting; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.inventory.FurnaceBurnEvent; -import org.bukkit.event.inventory.FurnaceExtractEvent; -import org.bukkit.event.inventory.FurnaceSmeltEvent; +import org.bukkit.inventory.ItemStack; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.mining.Mining; +import com.gmail.nossr50.skills.smelting.Smelting.Tier; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.BlockChecks; +import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; public class SmeltingManager extends SkillManager { - public SmeltingManager(McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, SkillType.SMELTING); } + public boolean canUseFluxMining(BlockState blockState) { + Player player = getPlayer(); + ItemStack heldItem = player.getItemInHand(); + + return BlockChecks.affectedByFluxMining(blockState) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState); + } + + public boolean canUseVanillaXpBoost() { + Player player = getPlayer(); + + return SkillTools.unlockLevelReached(player, skill, Smelting.Tier.ONE.getLevel()) && Permissions.vanillaXpBoost(player, skill); + } + + /** + * Process the Flux Mining ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processFluxMining(BlockState blockState) { + Player player = getPlayer(); + + if (SkillTools.unlockLevelReached(player, skill, Smelting.fluxMiningUnlockLevel) && SkillTools.activationSuccessful(player, skill, Smelting.fluxMiningChance)) { + ItemStack item = null; + + switch (blockState.getType()) { + case IRON_ORE: + item = new ItemStack(Material.IRON_INGOT); + break; + + case GOLD_ORE: + item = new ItemStack(Material.GOLD_INGOT); + break; + + default: + break; + } + + if (item == null) { + return false; + } + + Location location = blockState.getLocation(); + + Misc.dropItem(location, item); + + if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { + Misc.dropItem(location, item); + } + + blockState.setRawData((byte) 0x0); + blockState.setType(Material.AIR); + player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success")); + return true; + } + + return false; + } + /** * Increases burn time for furnace fuel. * - * @param event The {@link FurnaceBurnEvent} to modify. + * @param burnTime The initial burn time from the {@link FurnaceBurnEvent} */ - public void fuelEfficiency(FurnaceBurnEvent event) { - Player player = mcMMOPlayer.getPlayer(); + public int fuelEfficiency(int burnTime) { + double burnModifier = 1 + (((double) getSkillLevel() / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier); - if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) { - return; - } - - FuelEfficiencyEventHandler eventHandler = new FuelEfficiencyEventHandler(this, event); - eventHandler.calculateBurnModifier(); - eventHandler.modifyBurnTime(); + return (int) (burnTime * burnModifier); } - public void smeltProcessing(FurnaceSmeltEvent event) { - Player player = mcMMOPlayer.getPlayer(); + public void smeltProcessing(Material resourceType, ItemStack result) { + Player player = getPlayer(); - if (Misc.isNPCEntity(player)) { - return; - } + applyXpGain(Smelting.getResourceXp(resourceType)); - SmeltResourceEventHandler eventHandler = new SmeltResourceEventHandler(this, event); - - if (Permissions.skillEnabled(player, skill)) { - eventHandler.handleXPGain(); - } - - if (!Permissions.doubleDrops(player, skill)) { - return; - } - - eventHandler.calculateSkillModifier(); - - double chance = (Smelting.secondSmeltMaxChance / Smelting.secondSmeltMaxLevel) * eventHandler.skillModifier; - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.handleBonusSmelts(); + if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) { + result.setAmount(result.getAmount() + 1); } } - public void vanillaXPBoost(FurnaceExtractEvent event) { - if (getSkillLevel() < Smelting.vanillaXPBoostRank1Level || !Permissions.vanillaXpBoost(mcMMOPlayer.getPlayer(), skill)) { - return; + public int vanillaXPBoost(int experience) { + return experience * getVanillaXpMultiplier(); + } + + /** + * Gets the vanilla XP multiplier + * + * @return the vanilla XP multiplier + */ + protected int getVanillaXpMultiplier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getVanillaXPBoostModifier(); + } } - SmeltingVanillaXPEventHandler eventHandler = new SmeltingVanillaXPEventHandler(this, event); - eventHandler.calculateModifier(); - eventHandler.modifyVanillaXP(); + return 0; } } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingVanillaXPEventHandler.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingVanillaXPEventHandler.java deleted file mode 100644 index 33f18eea0..000000000 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingVanillaXPEventHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.gmail.nossr50.skills.smelting; - -import org.bukkit.event.inventory.FurnaceExtractEvent; - -public class SmeltingVanillaXPEventHandler { - private SmeltingManager manager; - private FurnaceExtractEvent event; - private int xpBoostModifier; - - protected SmeltingVanillaXPEventHandler(SmeltingManager manager, FurnaceExtractEvent event) { - this.manager = manager; - this.event = event; - } - - protected void calculateModifier() { - int skillLevel = manager.getSkillLevel(); - - if (skillLevel >= Smelting.vanillaXPBoostRank5Level) { - xpBoostModifier = Smelting.vanillaXPBoostRank5Multiplier; - } - else if (skillLevel >= Smelting.vanillaXPBoostRank4Level) { - xpBoostModifier = Smelting.vanillaXPBoostRank4Multiplier; - } - else if (skillLevel >= Smelting.vanillaXPBoostRank3Level) { - xpBoostModifier = Smelting.vanillaXPBoostRank3Multiplier; - } - else if (skillLevel >= Smelting.vanillaXPBoostRank2Level) { - xpBoostModifier = Smelting.vanillaXPBoostRank2Multiplier; - } - else { - xpBoostModifier = Smelting.vanillaXPBoostRank1Multiplier; - } - } - - protected void modifyVanillaXP() { - int xp = event.getExpToDrop(); - event.setExpToDrop(xp * xpBoostModifier); - } -} From 8fb8c67148c2820373c5ac1f5888ace05e530444 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 27 Feb 2013 23:18:17 -0500 Subject: [PATCH 092/137] SwordsManager cleaning --- .../skills/swords/BleedEventHandler.java | 56 ------------------- .../swords/CounterAttackEventHandler.java | 37 ------------ .../swords/SerratedStrikesEventHandler.java | 24 -------- .../nossr50/skills/swords/SwordsManager.java | 54 ++++++++++++------ 4 files changed, 36 insertions(+), 135 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/swords/BleedEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/swords/CounterAttackEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/swords/SerratedStrikesEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/skills/swords/BleedEventHandler.java b/src/main/java/com/gmail/nossr50/skills/swords/BleedEventHandler.java deleted file mode 100644 index 36fccd9ca..000000000 --- a/src/main/java/com/gmail/nossr50/skills/swords/BleedEventHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.gmail.nossr50.skills.swords; - -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.util.Users; - -public class BleedEventHandler { - private McMMOPlayer mcMMOPlayer; - private int skillLevel; - private LivingEntity defender; - protected int skillModifier; - - protected BleedEventHandler(SwordsManager manager, LivingEntity defender) { - this.mcMMOPlayer = manager.getMcMMOPlayer(); - this.skillLevel = manager.getSkillLevel(); - this.defender = defender; - - calculateSkillModifier(); - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(skillLevel, Swords.bleedMaxBonusLevel); - } - - protected void addBleedTicks() { - int bleedTicks; - - if (skillLevel >= Swords.bleedMaxBonusLevel) { - bleedTicks = Swords.bleedMaxTicks; - } - else { - bleedTicks = Swords.bleedBaseTicks; - } - - BleedTimer.add(defender, bleedTicks); - } - - protected void sendAbilityMessages() { - if (mcMMOPlayer.getProfile().useChatNotifications()) { - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); - } - - if (defender instanceof Player) { - Player defendingPlayer = (Player) defender; - - if (Users.getPlayer(defendingPlayer).getProfile().useChatNotifications()) { - defendingPlayer.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started")); - } - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/swords/CounterAttackEventHandler.java b/src/main/java/com/gmail/nossr50/skills/swords/CounterAttackEventHandler.java deleted file mode 100644 index 15022eadd..000000000 --- a/src/main/java/com/gmail/nossr50/skills/swords/CounterAttackEventHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.gmail.nossr50.skills.swords; - -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.CombatTools; -import com.gmail.nossr50.skills.utilities.SkillTools; - -public class CounterAttackEventHandler { - private SwordsManager manager; - private LivingEntity attacker; - private int damage; - protected int skillModifier; - - protected CounterAttackEventHandler(SwordsManager manager, LivingEntity attacker, int damage) { - this.manager = manager; - this.attacker = attacker; - this.damage = damage; - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Swords.counterAttackMaxBonusLevel); - } - - protected void dealDamage() { - CombatTools.dealDamage(attacker, damage / Swords.counterAttackModifier); - } - - protected void sendAbilityMessages() { - manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered")); - - if (attacker instanceof Player) { - ((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit")); - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SerratedStrikesEventHandler.java b/src/main/java/com/gmail/nossr50/skills/swords/SerratedStrikesEventHandler.java deleted file mode 100644 index 57e147215..000000000 --- a/src/main/java/com/gmail/nossr50/skills/swords/SerratedStrikesEventHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.gmail.nossr50.skills.swords; - -import org.bukkit.entity.LivingEntity; - -import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.utilities.CombatTools; -import com.gmail.nossr50.skills.utilities.SkillType; - -public class SerratedStrikesEventHandler { - private SwordsManager manager; - private LivingEntity target; - private int damage; - - protected SerratedStrikesEventHandler(SwordsManager manager, LivingEntity target, int damage) { - this.manager = manager; - this.target = target; - this.damage = damage; - } - - protected void applyAbilityEffects() { - CombatTools.applyAbilityAoE(manager.getMcMMOPlayer().getPlayer(), target, damage / Swords.serratedStrikesModifier, SkillType.SWORDS); - BleedTimer.add(target, Swords.serratedStrikesBleedTicks); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index d00d91188..3d72dd94b 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -1,11 +1,16 @@ package com.gmail.nossr50.skills.swords; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.runnables.BleedTimer; +import com.gmail.nossr50.skills.utilities.CombatTools; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Users; public class SwordsManager extends SkillManager { public SwordsManager(McMMOPlayer mcMMOPlayer) { @@ -15,35 +20,48 @@ public class SwordsManager extends SkillManager { /** * Check for Bleed effect. * - * @param defender The defending entity + * @param target The defending entity */ - public void bleedCheck(LivingEntity defender) { - BleedEventHandler eventHandler = new BleedEventHandler(this, defender); + public void bleedCheck(LivingEntity target) { + Player player = getPlayer(); - float chance = (float) ((Swords.bleedMaxChance / Swords.bleedMaxBonusLevel) * getSkillLevel()); - if (chance > Swords.bleedMaxChance) chance = (float) Swords.bleedMaxChance; + if (SkillTools.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) { - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.addBleedTicks(); - eventHandler.sendAbilityMessages(); + if (getSkillLevel() >= Swords.bleedMaxBonusLevel) { + BleedTimer.add(target, Swords.bleedMaxTicks); + } + else { + BleedTimer.add(target, Swords.bleedBaseTicks); + } + + if (getProfile().useChatNotifications()) { + player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); + } + + if (target instanceof Player) { + Player defender = (Player) target; + + if (Users.getPlayer(defender).getProfile().useChatNotifications()) { + defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started")); + } + } } } public void counterAttackChecks(LivingEntity attacker, int damage) { - CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage); - eventHandler.calculateSkillModifier(); + if (SkillTools.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) { + CombatTools.dealDamage(attacker, damage / Swords.counterAttackModifier); - float chance = (float) ((Swords.counterAttackMaxChance / Swords.counterAttackMaxBonusLevel) * getSkillLevel()); - if (chance > Swords.counterAttackMaxChance) chance = (float) Swords.counterAttackMaxChance; + getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered")); - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.dealDamage(); - eventHandler.sendAbilityMessages(); + if (attacker instanceof Player) { + ((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit")); + } } } public void serratedStrikes(LivingEntity target, int damage) { - SerratedStrikesEventHandler eventHandler = new SerratedStrikesEventHandler(this, target, damage); - eventHandler.applyAbilityEffects(); + CombatTools.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill); + BleedTimer.add(target, Swords.serratedStrikesBleedTicks); } } From c900edb261b67d1f2f1f493844ddcb162d152a17 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Thu, 28 Feb 2013 11:28:28 +0100 Subject: [PATCH 093/137] Fixed a bug where the near party member counter was off. Closes #745 --- src/main/java/com/gmail/nossr50/party/PartyManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 72603d5f8..fabf61c1d 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -74,7 +74,7 @@ public final class PartyManager { List nearMembers = new ArrayList(); if (party != null) { for (Player member : party.getOnlineMembers()) { - if (player != member && Misc.isNear(player.getLocation(), member.getLocation(), range)) { + if (!player.getName().equals(member.getName()) && Misc.isNear(player.getLocation(), member.getLocation(), range)) { nearMembers.add(member); } } From 886515400dc845c996075c9f6e6240dd4c8c8c31 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Thu, 28 Feb 2013 11:29:04 +0100 Subject: [PATCH 094/137] It's a modifier, not a multiplier. --- src/main/resources/advanced.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 7dcbae73a..dff2f234b 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -22,7 +22,7 @@ Skills: Acrobatics: # Dodge_ChanceMax: Maximum chance of dodging when on Dodge_MaxBonusLevel or higher # Dodge_MaxBonusLevel: On this level or higher, the dodge chance will not go higher than Dodge_ChanceMax - # Dodge_DamageModifer: Dodge damage will be divided by this multiplier + # Dodge_DamageModifer: Dodge damage will be divided by this modifier Dodge_ChanceMax: 20.0 Dodge_MaxBonusLevel: 800 Dodge_DamageModifier: 2 From 213b4763e7beaffab428e5f38bdd58f85c22d0a2 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 28 Feb 2013 08:58:59 -0500 Subject: [PATCH 095/137] Check the perms for these commands in the commands, otherwise they don't work in console because they don't default to OP. Fixes #715 --- .../gmail/nossr50/commands/CommandRegistrationHelper.java | 3 --- .../com/gmail/nossr50/database/commands/McpurgeCommand.java | 6 ++++++ .../gmail/nossr50/database/commands/McremoveCommand.java | 6 ++++++ .../gmail/nossr50/database/commands/MmoupdateCommand.java | 6 ++++++ src/main/java/com/gmail/nossr50/util/Permissions.java | 4 ++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java index 19dd617ac..7664f3667 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java @@ -253,7 +253,6 @@ public final class CommandRegistrationHelper { public static void registerMcpurgeCommand() { PluginCommand command = mcMMO.p.getCommand("mcpurge"); command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff())); - command.setPermission("mcmmo.commands.mcpurge"); command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge")); command.setExecutor(new McpurgeCommand()); @@ -262,7 +261,6 @@ public final class CommandRegistrationHelper { public static void registerMcremoveCommand() { PluginCommand command = mcMMO.p.getCommand("mcremove"); command.setDescription(LocaleLoader.getString("Commands.Description.mcremove")); - command.setPermission("mcmmo.commands.mcremove"); command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); command.setExecutor(new McremoveCommand()); @@ -271,7 +269,6 @@ public final class CommandRegistrationHelper { public static void registerMmoupdateCommand() { PluginCommand command = mcMMO.p.getCommand("mmoupdate"); command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate")); - command.setPermission("mcmmo.commands.mmoupdate"); command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate")); command.setExecutor(new MmoupdateCommand()); diff --git a/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java b/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java index ab7a88d84..a4738d10a 100644 --- a/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java +++ b/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java @@ -8,10 +8,16 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.Database; import com.gmail.nossr50.database.Leaderboard; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class McpurgeCommand implements CommandExecutor{ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.mcpurge(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + switch (args.length) { case 0: if (Config.getInstance().getUseMySQL()) { diff --git a/src/main/java/com/gmail/nossr50/database/commands/McremoveCommand.java b/src/main/java/com/gmail/nossr50/database/commands/McremoveCommand.java index 41e383208..62f7f02c4 100644 --- a/src/main/java/com/gmail/nossr50/database/commands/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/database/commands/McremoveCommand.java @@ -8,10 +8,16 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.Database; import com.gmail.nossr50.database.Leaderboard; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class McremoveCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.mcremove(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + switch (args.length) { case 1: /* MySQL */ diff --git a/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java b/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java index 5bf0be742..097c2fcaf 100644 --- a/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java +++ b/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java @@ -9,11 +9,17 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.runnables.SQLConversionTask; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class MmoupdateCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.mmoupdate(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + switch (args.length) { case 0: sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start")); diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index b9371a0d1..bf687c293 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -83,6 +83,10 @@ public final class Permissions { public static boolean vampirismModify(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.vampirism.modify"); } public static boolean vampirismToggle(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.vampirism.toggle"); } + public static boolean mcpurge(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcpurge"); } + public static boolean mcremove(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcremove"); } + public static boolean mmoupdate(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mmoupdate"); } + /* * PERKS */ From d5bcb4346e8d48a67624763f5085d5a11ed185cd Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 28 Feb 2013 09:22:53 -0500 Subject: [PATCH 096/137] This typo was causing the config value to never be read properly. Fixes #691 --- src/main/resources/advanced.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index dff2f234b..ec35aa44a 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -380,9 +380,9 @@ Skills: IronGrip_ChanceMax: 100.0 IronGrip_MaxBonusLevel: 1000 - # IronArmBonusMax: Maximum bonus damage for unarmed + # IronArm_BonusMax: Maximum bonus damage for unarmed # IronArm_IncreaseLevel: Bonus damage increases every increase level - IronArmBonusMax: 8 + IronArm_BonusMax: 8 IronArm_IncreaseLevel: 50 # # Settings for Woodcutting From 10e7fe55608202f9c89802e30db88faf26ed8011 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 28 Feb 2013 11:24:38 -0500 Subject: [PATCH 097/137] Minor Spout cleanup. --- .../gmail/nossr50/spout/SpoutListener.java | 4 +- .../com/gmail/nossr50/spout/SpoutSounds.java | 24 +------ .../com/gmail/nossr50/spout/SpoutTools.java | 64 ++++++------------- 3 files changed, 21 insertions(+), 71 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java b/src/main/java/com/gmail/nossr50/spout/SpoutListener.java index 07972fae0..f2ccaa4e9 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutListener.java @@ -12,7 +12,6 @@ import org.getspout.spoutapi.gui.ScreenType; import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.spout.buttons.McmmoButton; import com.gmail.nossr50.spout.huds.SpoutHud; @@ -30,14 +29,13 @@ public class SpoutListener implements Listener { public void onSpoutCraftEnable(SpoutCraftEnableEvent event) { SpoutPlayer spoutPlayer = event.getPlayer(); McMMOPlayer mcMMOPlayer = Users.getPlayer(spoutPlayer); - PlayerProfile profile = mcMMOPlayer.getProfile(); //TODO: Add custom titles based on skills if (SpoutTools.showPowerLevel) { spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getName(), mcMMOPlayer.getPowerLevel())); } - profile.setSpoutHud(new SpoutHud(mcMMOPlayer)); //Setup Party HUD stuff + mcMMOPlayer.getProfile().setSpoutHud(new SpoutHud(mcMMOPlayer)); //Setup Party HUD stuff } /** diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java b/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java index 23ed5f218..82ce3fe77 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java @@ -1,40 +1,18 @@ package com.gmail.nossr50.spout; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.getspout.spoutapi.SpoutManager; -import org.getspout.spoutapi.player.SpoutPlayer; -import org.getspout.spoutapi.sound.SoundEffect; -import org.getspout.spoutapi.sound.SoundManager; import com.gmail.nossr50.mcMMO; public class SpoutSounds { - /** - * Play sound effect through Spout. - * - * @param effect The sound effect to play - * @param player The player to play the sound to - * @param location The location the sound should come from - */ - public static void playSoundForPlayer(SoundEffect effect, Player player, Location location) { - SoundManager soundManager = SpoutManager.getSoundManager(); - SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); - - soundManager.playSoundEffect(spoutPlayer, effect, location); - } - /** * Play noise on level-up. * * @param player The player who leveled up */ protected static void playLevelUpNoise(Player player, mcMMO plugin) { - SoundManager soundManager = SpoutManager.getSoundManager(); - SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); - - //If this is pulling from online, why have it in the jar? - soundManager.playCustomSoundEffect(plugin, spoutPlayer, "level.wav", false); + SpoutManager.getSoundManager().playCustomSoundEffect(plugin, SpoutManager.getPlayer(player), "level.wav", false); } } diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutTools.java b/src/main/java/com/gmail/nossr50/spout/SpoutTools.java index a74e8dedb..136e61084 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutTools.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutTools.java @@ -30,7 +30,6 @@ import com.gmail.nossr50.util.Users; public class SpoutTools { private static mcMMO plugin = mcMMO.p; - static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); public final static String spoutDirectory = mcMMO.getMainDirectory() + "Resources" + File.separator; public final static String hudDirectory = spoutDirectory + "HUD" + File.separator; @@ -146,12 +145,10 @@ public class SpoutTools { continue; } - String skillTypeString = skillType.toString(); - String standardFileName = StringUtils.getCapitalized(skillTypeString)+".png"; - String retroFileName = StringUtils.getCapitalized(skillTypeString)+"_r.png"; + String skillTypeString = StringUtils.getCapitalized(skillType.toString()); - writeFile(standardFileName, hudStandardDirectory); - writeFile(retroFileName, hudRetroDirectory); + writeFile(skillTypeString + ".png", hudStandardDirectory); + writeFile(skillTypeString + "_r.png", hudRetroDirectory); } // Blank icons @@ -208,10 +205,10 @@ public class SpoutTools { continue; } - String skillTypeString = skillType.toString(); + String skillTypeString = StringUtils.getCapitalized(skillType.toString()); - files.add(new File(hudStandardDirectory + StringUtils.getCapitalized(skillTypeString) + ".png")); - files.add(new File(hudRetroDirectory + StringUtils.getCapitalized(skillTypeString) + "_r.png")); + files.add(new File(hudStandardDirectory + skillTypeString + ".png")); + files.add(new File(hudRetroDirectory + skillTypeString + "_r.png")); } // Blank icons @@ -280,11 +277,11 @@ public class SpoutTools { break; case 4: - mat = Material.LAPIS_ORE; + mat = Material.DIAMOND_ORE; break; case 5: - mat = Material.DIAMOND_ORE; + mat = Material.EMERALD_ORE; break; default: @@ -296,6 +293,9 @@ public class SpoutTools { case WOODCUTTING: switch (notificationTier) { case 1: + mat = Material.STICK; + break; + case 2: case 3: mat = Material.WOOD; @@ -313,31 +313,7 @@ public class SpoutTools { break; case REPAIR: - switch (notificationTier) { - case 1: - mat = Material.COBBLESTONE; - break; - - case 2: - mat = Material.IRON_BLOCK; - break; - - case 3: - mat = Material.GOLD_BLOCK; - break; - - case 4: - mat = Material.LAPIS_BLOCK; - break; - - case 5: - mat = Material.DIAMOND_BLOCK; - break; - - default: - break; - } - + mat = Material.ANVIL; break; case HERBALISM: @@ -564,17 +540,17 @@ public class SpoutTools { * @param level The level of the skill * @return the notification tier of the skill */ - private static Integer getNotificationTier(Integer level) { - if (level >= advancedConfig.getSpoutNotificationTier4()) { + private static int getNotificationTier(int level) { + if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier4()) { return 5; } - else if (level >= advancedConfig.getSpoutNotificationTier3()) { + else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier3()) { return 4; } - else if (level >= advancedConfig.getSpoutNotificationTier2()) { + else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier2()) { return 3; } - else if (level >= advancedConfig.getSpoutNotificationTier1()) { + else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier1()) { return 2; } else { @@ -587,8 +563,7 @@ public class SpoutTools { */ public static void reloadSpoutPlayers() { for (SpoutPlayer spoutPlayer : SpoutManager.getPlayerChunkMap().getOnlinePlayers()) { - SpoutCraftEnableEvent spoutCraftEnableEvent = new SpoutCraftEnableEvent(spoutPlayer); - mcMMO.p.getServer().getPluginManager().callEvent(spoutCraftEnableEvent); + mcMMO.p.getServer().getPluginManager().callEvent(new SpoutCraftEnableEvent(spoutPlayer)); } } @@ -596,8 +571,7 @@ public class SpoutTools { SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); if (spoutPlayer != null) { - SpoutCraftEnableEvent spoutCraftEnableEvent = new SpoutCraftEnableEvent(spoutPlayer); - mcMMO.p.getServer().getPluginManager().callEvent(spoutCraftEnableEvent); + mcMMO.p.getServer().getPluginManager().callEvent(new SpoutCraftEnableEvent(spoutPlayer)); } } From fbd016f86de81b8cbfa36896cd227bd9f7c71f6e Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 28 Feb 2013 11:52:56 -0500 Subject: [PATCH 098/137] Cleaning up our UnarmedManager --- .../skills/unarmed/DeflectEventHandler.java | 31 -------- .../skills/unarmed/DisarmEventHandler.java | 48 ------------ .../skills/unarmed/IronGripEventHandler.java | 30 -------- .../UnarmedBonusDamageEventHandler.java | 32 -------- .../skills/unarmed/UnarmedManager.java | 74 ++++++++----------- .../nossr50/skills/utilities/CombatTools.java | 16 +++- 6 files changed, 44 insertions(+), 187 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/unarmed/DeflectEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/unarmed/DisarmEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/unarmed/IronGripEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedBonusDamageEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/DeflectEventHandler.java b/src/main/java/com/gmail/nossr50/skills/unarmed/DeflectEventHandler.java deleted file mode 100644 index 2fadd16ac..000000000 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/DeflectEventHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.gmail.nossr50.skills.unarmed; - -import org.bukkit.event.entity.EntityDamageEvent; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; - -public class DeflectEventHandler { - private UnarmedManager manager; - private EntityDamageEvent event; - protected int skillModifier; - - protected DeflectEventHandler(UnarmedManager manager, EntityDamageEvent event) { - this.manager = manager; - this.event = event; - - calculateSkillModifier(); - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Unarmed.deflectMaxBonusLevel); - } - - protected void sendAbilityMessage() { - manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.ArrowDeflect")); - } - - protected void cancelEvent() { - event.setCancelled(true); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/DisarmEventHandler.java b/src/main/java/com/gmail/nossr50/skills/unarmed/DisarmEventHandler.java deleted file mode 100644 index 272a88e52..000000000 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/DisarmEventHandler.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.gmail.nossr50.skills.unarmed; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.events.skills.McMMOPlayerDisarmEvent; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.util.Misc; - -public class DisarmEventHandler { - private UnarmedManager manager; - private Player defender; - private ItemStack inHand; - protected int skillModifier; - - protected DisarmEventHandler(UnarmedManager manager, Player defender) { - this.manager = manager; - this.defender = defender; - this.inHand = defender.getItemInHand(); - } - - protected boolean isHoldingItem() { - return (inHand.getType() != Material.AIR); - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Unarmed.disarmMaxBonusLevel); - } - - private void sendAbilityMessage() { - defender.sendMessage(LocaleLoader.getString("Skills.Disarmed")); - } - - protected void handleDisarm() { - McMMOPlayerDisarmEvent event = new McMMOPlayerDisarmEvent(defender); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if(!event.isCancelled()) { - Misc.dropItem(defender.getLocation(), inHand); - defender.setItemInHand(new ItemStack(Material.AIR)); - - sendAbilityMessage(); - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/IronGripEventHandler.java b/src/main/java/com/gmail/nossr50/skills/unarmed/IronGripEventHandler.java deleted file mode 100644 index 554d189ab..000000000 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/IronGripEventHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.gmail.nossr50.skills.unarmed; - -import org.bukkit.entity.Player; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Users; - -public class IronGripEventHandler { - private UnarmedManager manager; - private Player defender; - protected int skillModifier; - - protected IronGripEventHandler(UnarmedManager manager, Player defender) { - this.manager = manager; - this.defender = defender; - - calculateSkillModifier(); - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(Users.getPlayer(defender).getProfile().getSkillLevel(SkillType.UNARMED), Unarmed.ironGripMaxBonusLevel); - } - - protected void sendAbilityMessages() { - defender.sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Defender")); - manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Attacker")); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedBonusDamageEventHandler.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedBonusDamageEventHandler.java deleted file mode 100644 index 62fbe1611..000000000 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedBonusDamageEventHandler.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.gmail.nossr50.skills.unarmed; - -import org.bukkit.event.entity.EntityDamageEvent; - -public class UnarmedBonusDamageEventHandler { - private UnarmedManager manager; - private EntityDamageEvent event; - - protected int damageBonus; - - protected UnarmedBonusDamageEventHandler(UnarmedManager manager, EntityDamageEvent event) { - this.manager = manager; - this.event = event; - } - - protected void calculateDamageBonus() { - int damageBonus = 3 + (manager.getSkillLevel() / Unarmed.ironArmIncreaseLevel); - - if (damageBonus > Unarmed.ironArmMaxBonusDamage) { - damageBonus = Unarmed.ironArmMaxBonusDamage; - } - - this.damageBonus = damageBonus; - } - - protected void modifyEventDamage() { - int damage = event.getDamage(); - int unarmedBonus = damage + damageBonus; - - event.setDamage(damage + unarmedBonus); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index 2c2b6f8ce..7da7d5c13 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -1,12 +1,15 @@ package com.gmail.nossr50.skills.unarmed; -import org.bukkit.entity.LivingEntity; +import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.inventory.ItemStack; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.events.skills.McMMOPlayerDisarmEvent; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.utilities.PerksUtils; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -21,55 +24,48 @@ public class UnarmedManager extends SkillManager { * * @param defender The defending player */ - public void disarmCheck(LivingEntity defender) { - Player defendingPlayer = (Player) defender; - DisarmEventHandler eventHandler = new DisarmEventHandler(this, defendingPlayer); + public void disarmCheck(Player defender) { + if (SkillTools.activationSuccessful(getPlayer(), skill, Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) { + McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender); + mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent); - if (eventHandler.isHoldingItem()) { - eventHandler.calculateSkillModifier(); + if (!disarmEvent.isCancelled()) { + Misc.dropItem(defender.getLocation(), defender.getItemInHand()); - float chance = (float) ((Unarmed.disarmMaxChance / Unarmed.disarmMaxBonusLevel) * getSkillLevel()); - if (chance > Unarmed.disarmMaxChance) chance = (float) Unarmed.disarmMaxChance; - - if (chance > Misc.getRandom().nextInt(activationChance)) { - if (!hasIronGrip(defendingPlayer)) { - eventHandler.handleDisarm(); - } + defender.setItemInHand(new ItemStack(Material.AIR)); + defender.sendMessage(LocaleLoader.getString("Skills.Disarmed")); } } } /** * Check for arrow deflection. - * - * @param event The event to modify */ - public void deflectCheck(EntityDamageEvent event) { - DeflectEventHandler eventHandler = new DeflectEventHandler(this, event); + public boolean deflectCheck() { + Player player = getPlayer(); - float chance = (float) ((Unarmed.deflectMaxChance / Unarmed.deflectMaxBonusLevel) * getSkillLevel()); - if (chance > Unarmed.deflectMaxChance) chance = (float) Unarmed.deflectMaxChance; - - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.cancelEvent(); - eventHandler.sendAbilityMessage(); + if (SkillTools.activationSuccessful(player, skill, Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) { + player.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect")); + return true; } + + return false; } - public void berserkDamage(EntityDamageEvent event) { - event.setDamage((int) (event.getDamage() * Unarmed.berserkDamageModifier)); + public int berserkDamage(int damage) { + return (int) (damage * Unarmed.berserkDamageModifier); } /** - * Handle Unarmed bonus damage. + * Handle the effects of the Iron Arm ability * - * @param event The event to modify. + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage */ - public void bonusDamage(EntityDamageEvent event) { - UnarmedBonusDamageEventHandler eventHandler = new UnarmedBonusDamageEventHandler(this, event); + public int ironArmCheck(int damage) { + int unarmedBonus = Math.min(3 + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage); - eventHandler.calculateDamageBonus(); - eventHandler.modifyEventDamage(); + return damage + unarmedBonus; } /** @@ -79,16 +75,10 @@ public class UnarmedManager extends SkillManager { * @return true if the defender was not disarmed, false otherwise */ private boolean hasIronGrip(Player defender) { - if (Misc.isNPCEntity(defender) || !Permissions.ironGrip(defender)) { - return false; - } + if (!Misc.isNPCEntity(defender) && Permissions.ironGrip(defender) && SkillTools.activationSuccessful(defender, skill, Unarmed.ironGripMaxChance, Unarmed.ironGripMaxBonusLevel)) { + defender.sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Defender")); + getPlayer().sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Attacker")); - IronGripEventHandler eventHandler = new IronGripEventHandler(this, defender); - - double chance = (Unarmed.ironGripMaxChance / Unarmed.ironGripMaxBonusLevel) * eventHandler.skillModifier; - - if (chance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(defender, skill))) { - eventHandler.sendAbilityMessages(); return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index de07ffdf6..e10efc94f 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -152,15 +152,19 @@ public final class CombatTools { } if (Permissions.bonusDamage(player, SkillType.UNARMED)) { - SkillManagerStore.getInstance().getUnarmedManager(playerName).bonusDamage(event); + event.setDamage(SkillManagerStore.getInstance().getUnarmedManager(playerName).ironArmCheck(event.getDamage())); } if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) { - SkillManagerStore.getInstance().getUnarmedManager(playerName).berserkDamage(event); + event.setDamage(SkillManagerStore.getInstance().getUnarmedManager(playerName).berserkDamage(event.getDamage())); } if (target instanceof Player && Permissions.disarm(player)) { - SkillManagerStore.getInstance().getUnarmedManager(playerName).disarmCheck(target); + Player defender = (Player) target; + + if (defender.getItemInHand().getType() != Material.AIR) { + SkillManagerStore.getInstance().getUnarmedManager(playerName).disarmCheck((Player) target); + } } startGainXp(mcMMOPlayer, target, SkillType.UNARMED); @@ -283,7 +287,11 @@ public final class CombatTools { } if (target instanceof Player && SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) { - SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck(event); + event.setCancelled(SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck()); + + if (event.isCancelled()) { + return; + } } if (SkillManagerStore.getInstance().getArcheryManager(playerName).canDaze(target)) { From bbbba12e95c658f42e8eec186913528c05e5db97 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 28 Feb 2013 12:13:13 -0500 Subject: [PATCH 099/137] Small TamingManager changes. Halting the rest of the major changes for now to prepare for 1.4.00 release. --- .../nossr50/listeners/EntityListener.java | 6 +++- .../nossr50/skills/taming/TamingManager.java | 33 +++++++++---------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 02d35ea20..991cb6bb0 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -439,7 +439,11 @@ public class EntityListener implements Listener { return; } - SkillManagerStore.getInstance().getTamingManager(player.getName()).awardTamingXP(event); + LivingEntity entity = event.getEntity(); + + if (entity != null && !entity.hasMetadata(mcMMO.entityMetadataKey)) { + SkillManagerStore.getInstance().getTamingManager(player.getName()).awardTamingXP(entity); + } } @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) 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 3258c2575..13c697da4 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -11,6 +11,7 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -25,25 +26,18 @@ public class TamingManager extends SkillManager { * * @param event The event to award XP for */ - public void awardTamingXP(EntityTameEvent event) { - if (event.getEntity() == null) { - return; - } - else if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) { - return; - } - - switch (event.getEntityType()) { + public void awardTamingXP(LivingEntity entity) { + switch (entity.getType()) { case WOLF: - mcMMOPlayer.beginXpGain(SkillType.TAMING, Taming.wolfXp); - break; + applyXpGain(Taming.wolfXp); + return; case OCELOT: - mcMMOPlayer.beginXpGain(SkillType.TAMING, Taming.ocelotXp); - break; + applyXpGain(Taming.ocelotXp); + return; default: - break; + return; } } @@ -54,10 +48,15 @@ public class TamingManager extends SkillManager { * @param damage The damage being absorbed by the wolf */ public void fastFoodService(Wolf wolf, int damage) { - if (Misc.getRandom().nextInt(activationChance) < Taming.fastFoodServiceActivationChance) { - FastFoodServiceEventHandler eventHandler = new FastFoodServiceEventHandler(wolf); + if (SkillTools.activationSuccessful(getPlayer(), skill, Taming.fastFoodServiceActivationChance)) { - eventHandler.modifyHealth(damage); + int health = wolf.getHealth(); + int maxHealth = wolf.getMaxHealth(); + + if (health < maxHealth) { + int newHealth = health + damage; + wolf.setHealth(Math.min(newHealth, maxHealth)); + } } } From 13111a8d1b3ecfff6216924f8ae80e584988c215 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 28 Feb 2013 17:32:36 -0500 Subject: [PATCH 100/137] Fixed a few small bugs with Smelting. --- .../com/gmail/nossr50/listeners/InventoryListener.java | 4 ++-- .../com/gmail/nossr50/skills/smelting/SmeltingManager.java | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index b5570d016..c49485bdb 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -120,7 +120,7 @@ public class InventoryListener implements Listener{ } if (Permissions.skillEnabled(player, SkillType.SMELTING)) { - SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event.getSource().getType(), event.getResult()); + event.setResult(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event.getSource().getType(), event.getResult())); } } } @@ -137,7 +137,7 @@ public class InventoryListener implements Listener{ McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer()); if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) { - SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event.getExpToDrop()); + event.setExpToDrop(SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event.getExpToDrop())); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index c8985a680..d44612021 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -96,14 +96,17 @@ public class SmeltingManager extends SkillManager { return (int) (burnTime * burnModifier); } - public void smeltProcessing(Material resourceType, ItemStack result) { + public ItemStack smeltProcessing(Material resourceType, ItemStack result) { Player player = getPlayer(); applyXpGain(Smelting.getResourceXp(resourceType)); if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) { - result.setAmount(result.getAmount() + 1); + ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1); + return newResult; } + + return result; } public int vanillaXPBoost(int experience) { From a542d6cf3ec60ae6ecfbe6b09e51c6bd0d835442 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Fri, 1 Mar 2013 00:52:01 -0500 Subject: [PATCH 101/137] Squashed commit of the following: commit cb3e057dee1f2b29838ab654a526baac1baab7d6 Author: NuclearW Date: Fri Mar 1 00:43:57 2013 -0500 1.4.00 release commit 4f9628d2e4cde31c8946e9a911ee6f10e1fb6b35 Author: NuclearW Date: Fri Mar 1 00:07:30 2013 -0500 \r -> \n commit b2ca22e0477c747143b0f08a28a096967ee6ffd7 Author: GJ Date: Thu Feb 28 23:53:56 2013 -0500 Commented-out code shouldn't be done like that. commit 92f131712cc671e3e616c14a22e22769ef6d6d0b Author: GJ Date: Thu Feb 28 23:45:36 2013 -0500 More things we missed. commit 408b03766f6261a03a862a1ab7f5835772feda4a Author: NuclearW Date: Thu Feb 28 23:20:13 2013 -0500 Format: util through spout and backup lib commit d6bd2c29bbb51bee3607247468cfe145d4f38c9e Author: GJ Date: Thu Feb 28 22:50:08 2013 -0500 The things we missed the first time through... commit 393f0b889aa1b7011ee81ee7b15413d8824b8cfb Author: GJ Date: Thu Feb 28 22:05:29 2013 -0500 Formatting: Skills commit c097a6e188a7b760dd1b4389ed81dca417146b16 Author: GJ Date: Thu Feb 28 19:30:12 2013 -0500 Organize imports. commit 34c3e74be7eb5f983f21d969e30155c5d82c01c1 Author: GJ Date: Thu Feb 28 19:09:45 2013 -0500 Fixed a missing fallthrough comment from ChatCommand commit b4a76c9f022a2fd98bdd8f083accfea03becfd71 Author: GJ Date: Thu Feb 28 19:09:36 2013 -0500 Formatting: datatypes.* through events.* commit 3e57dd41d3265a7c8106c7eb026df926770a4d15 Author: NuclearW Date: Thu Feb 28 17:56:15 2013 -0500 Fix issue with bad rebase commit e8c8e06b2971555b7334e49128257e3af6f36892 Author: GJ Date: Thu Feb 28 17:35:32 2013 -0500 Formatting: DatabaseManager, LeaderboardManager, DatabaseUpdateType, and PlayerStat commit 13ecf1cc41f377a12991e357ac10abdcda24d6de Author: NuclearW Date: Thu Feb 28 17:31:43 2013 -0500 Format: listeners.* through runnables.* commit 71686e3c0d96c2dcf25442b91703fadda1ea3bb0 Author: NuclearW Date: Thu Feb 28 17:13:57 2013 -0500 Format PartyLockCommand commit d50abed10bf94e1a88df3dc5cc07c259aea920ea Author: NuclearW Date: Thu Feb 28 16:54:08 2013 -0500 Format: base through config.* commit 7004823eeebbae5be7728bf9cafc3b04e57b64cf Author: NuclearW Date: Thu Feb 28 15:21:40 2013 -0500 Example of using spaces to align like things commit 534190cfe2481e466fe459d65628550458cc2993 Author: NuclearW Date: Thu Feb 28 15:12:19 2013 -0500 Capitalization commit 5b61d3ba4c8d81e6f358b0cf4f460abfe9798414 Author: NuclearW Date: Thu Feb 28 15:07:43 2013 -0500 Updated readme, added standards.md commit 5ec0df70fb82c527420a2f437f27f31bd758f884 Author: NuclearW Date: Thu Feb 28 14:42:16 2013 -0500 Markdown was here, Creole is a loser commit 70d557c59d086b6a5fb5e0e63c0c1d8eb4c8d19c Author: NuclearW Date: Thu Feb 28 13:46:24 2013 -0500 Move MCStats shading to .metrics.mcstats commit eb9d67e66b1659d6abd2397ecf403343cfeffdda Author: GJ Date: Thu Feb 28 13:37:37 2013 -0500 Move ALL the packages! commit 8ffa9e7b75417b6c7f158613d4b4ffb783dcf2d0 Author: NuclearW Date: Thu Feb 28 12:37:12 2013 -0500 /r/n -> /n --- .gitattributes | 4 + Changelog.txt | 3306 ++++++++--------- README.creole | 28 - README.md | 47 + pom.xml | 364 +- .../com/gmail/nossr50/api/AbilityAPI.java | 102 +- .../java/com/gmail/nossr50/api/ChatAPI.java | 10 +- .../com/gmail/nossr50/api/ExperienceAPI.java | 670 ++-- .../java/com/gmail/nossr50/api/PartyAPI.java | 348 +- .../com/gmail/nossr50/api/SpoutHudAPI.java | 57 +- .../com/gmail/nossr50/api/SpoutToolsAPI.java | 106 +- .../com/gmail/nossr50/chat/ChatManager.java | 150 +- .../java/com/gmail/nossr50/chat/ChatMode.java | 140 +- .../nossr50/commands/McabilityCommand.java | 80 + .../gmail/nossr50/commands/McgodCommand.java | 89 + .../commands/{player => }/McmmoCommand.java | 227 +- .../nossr50/commands/McnotifyCommand.java | 33 + .../nossr50/commands/McrefreshCommand.java | 80 + .../gmail/nossr50/commands/XprateCommand.java | 69 + .../commands/admin/AddlevelsCommand.java | 154 - .../nossr50/commands/admin/AddxpCommand.java | 151 - .../commands/admin/HardcoreCommand.java | 86 - .../nossr50/commands/admin/McgodCommand.java | 89 - .../commands/admin/McrefreshCommand.java | 80 - .../commands/admin/MmoeditCommand.java | 150 - .../commands/admin/SkillresetCommand.java | 169 - .../commands/admin/VampirismCommand.java | 91 - .../nossr50/commands/admin/XprateCommand.java | 69 - .../chat}/AdminChatCommand.java | 52 +- .../chat}/ChatCommand.java | 177 +- .../chat}/PartyChatCommand.java | 96 +- .../commands/database/McpurgeCommand.java | 45 + .../commands/database/McremoveCommand.java | 51 + .../database}/MmoupdateCommand.java | 102 +- .../commands/experience/AddlevelsCommand.java | 154 + .../commands/experience/AddxpCommand.java | 152 + .../commands/experience/MmoeditCommand.java | 150 + .../experience/SkillresetCommand.java | 169 + .../commands/hardcore/HardcoreCommand.java | 85 + .../commands/hardcore/VampirismCommand.java | 90 + .../commands/party/PartyAcceptCommand.java | 42 + .../party/PartyChangeOwnerCommand.java | 34 + .../party}/PartyChangePasswordCommand.java | 99 +- .../nossr50/commands/party/PartyCommand.java | 154 + .../commands/party/PartyCreateCommand.java | 56 + .../commands/party/PartyDisbandCommand.java | 37 + .../party}/PartyExpShareCommand.java | 110 +- .../commands/party/PartyHelpCommand.java | 30 + .../party}/PartyInfoCommand.java | 204 +- .../commands/party/PartyInviteCommand.java | 72 + .../commands/party/PartyItemShareCommand.java | 101 + .../party}/PartyJoinCommand.java | 191 +- .../commands/party/PartyKickCommand.java | 49 + .../party}/PartyLockCommand.java | 194 +- .../commands/party/PartyQuitCommand.java | 38 + .../commands/party/PartyRenameCommand.java | 58 + .../party}/PartySubcommandType.java | 96 +- .../party}/PtpCommand.java | 436 +-- .../commands/player/InspectCommand.java | 118 +- .../commands/player/McabilityCommand.java | 80 - .../commands/player/McnotifyCommand.java | 34 - .../commands/player/McrankCommand.java | 144 +- .../commands/player/McstatsCommand.java | 100 +- .../nossr50/commands/player/MctopCommand.java | 230 +- .../skills}/AcrobaticsCommand.java | 210 +- .../skills}/ArcheryCommand.java | 208 +- .../axes => commands/skills}/AxesCommand.java | 256 +- .../skills}/ExcavationCommand.java | 133 +- .../skills}/FishingCommand.java | 246 +- .../skills}/HerbalismCommand.java | 360 +- .../skills}/MiningCommand.java | 297 +- .../skills}/RepairCommand.java | 330 +- .../{ => commands}/skills/SkillCommand.java | 318 +- .../commands/skills/SkillGuideCommand.java | 107 + .../skills}/SmeltingCommand.java | 243 +- .../skills}/SwordsCommand.java | 234 +- .../skills}/TamingCommand.java | 330 +- .../skills}/UnarmedCommand.java | 292 +- .../skills}/WoodcuttingCommand.java | 206 +- .../spout}/MchudCommand.java | 58 +- .../spout}/SpoutCommand.java | 107 +- .../spout}/XplockCommand.java | 128 +- .../config/AutoUpdateConfigLoader.java | 6 +- .../java/com/gmail/nossr50/config/Config.java | 4 +- .../gmail/nossr50/config/ConfigLoader.java | 159 +- .../mods}/CustomArmorConfig.java | 195 +- .../mods/CustomBlockConfig.java} | 237 +- .../mods}/CustomEntityConfig.java | 166 +- .../mods/CustomToolConfig.java} | 206 +- .../ItemWeightConfig.java} | 19 +- .../nossr50/config/spout/SpoutConfig.java | 65 + .../TreasureConfig.java} | 572 +-- .../{Database.java => DatabaseManager.java} | 417 ++- .../nossr50/database/DatabaseUpdate.java | 8 - ...aderboard.java => LeaderboardManager.java} | 88 +- .../database/commands/McpurgeCommand.java | 45 - .../database/commands/McremoveCommand.java | 51 - .../database/runnables/SQLReconnect.java | 21 - .../database/DatabaseUpdateType.java | 8 + .../{ => datatypes}/database/PlayerStat.java | 22 +- .../mods}/CustomBlock.java | 158 +- .../mods}/CustomEntity.java | 184 +- .../mods}/CustomItem.java | 54 +- .../mods}/CustomTool.java | 76 +- .../nossr50/{ => datatypes}/party/Party.java | 278 +- .../datatypes/{ => player}/McMMOPlayer.java | 606 +-- .../datatypes/{ => player}/PlayerProfile.java | 2048 +++++----- .../skills}/AbilityType.java | 422 +-- .../skills}/SkillType.java | 196 +- .../skills}/ToolType.java | 126 +- .../spout/buttons/McMMOButton.java} | 6 +- .../{ => datatypes}/spout/huds/HudType.java | 2 +- .../spout/huds/McMMOHud.java} | 212 +- .../spout/popups/McMMOMenu.java} | 35 +- .../spout/popups/McMMOXpBar.java} | 189 +- .../treasure/ExcavationTreasure.java | 2 +- .../datatypes/treasure/HylianTreasure.java | 151 +- .../nossr50/datatypes/treasure/Treasure.java | 2 +- .../nossr50/events/chat/McMMOChatEvent.java | 188 +- .../McMMOPlayerExperienceEvent.java | 122 +- .../experience/McMMOPlayerLevelUpEvent.java | 2 +- .../experience/McMMOPlayerXpGainEvent.java | 2 +- .../events/fake/FakeBlockBreakEvent.java | 2 +- .../events/fake/FakeBlockDamageEvent.java | 2 +- .../events/fake/FakePlayerAnimationEvent.java | 26 +- .../events/party/McMMOPartyChangeEvent.java | 206 +- .../events/party/McMMOPartyTeleportEvent.java | 90 +- .../events/skills/McMMOPlayerSkillEvent.java | 96 +- .../McMMOPlayerRepairCheckEvent.java | 115 +- .../{ => unarmed}/McMMOPlayerDisarmEvent.java | 5 +- .../nossr50/listeners/BlockListener.java | 94 +- .../nossr50/listeners/EntityListener.java | 229 +- .../nossr50/listeners/InventoryListener.java | 300 +- .../nossr50/listeners/PlayerListener.java | 269 +- .../gmail/nossr50/listeners/SelfListener.java | 33 - .../{spout => listeners}/SpoutListener.java | 33 +- .../nossr50/listeners/WorldListener.java | 2 +- .../gmail/nossr50/locale/LocaleLoader.java | 4 +- src/main/java/com/gmail/nossr50/mcMMO.java | 984 ++--- .../{util => }/metrics/MetricsManager.java | 28 +- .../com/gmail/nossr50/party/PartyManager.java | 89 +- .../com/gmail/nossr50/party/ShareHandler.java | 201 +- .../party/commands/PartyAcceptCommand.java | 43 - .../commands/PartyChangeOwnerCommand.java | 34 - .../nossr50/party/commands/PartyCommand.java | 153 - .../party/commands/PartyCreateCommand.java | 55 - .../party/commands/PartyDisbandCommand.java | 37 - .../party/commands/PartyHelpCommand.java | 30 - .../party/commands/PartyInviteCommand.java | 71 - .../party/commands/PartyItemShareCommand.java | 100 - .../party/commands/PartyKickCommand.java | 49 - .../party/commands/PartyQuitCommand.java | 38 - .../party/commands/PartyRenameCommand.java | 59 - .../nossr50/runnables/ProfileSaveTask.java | 24 - .../{SaveTimer.java => SaveTimerTask.java} | 13 +- ...cker.java => StickyPistonTrackerTask.java} | 4 +- .../McrankCommandAsyncTask.java} | 18 +- .../MctopCommandAsyncTask.java} | 15 +- .../database}/SQLConversionTask.java | 562 ++- .../runnables/database/SQLReconnectTask.java | 21 + .../database}/UserPurgeTask.java | 50 +- .../party/PartyAutoKickTask.java} | 6 +- .../party/PartyLoaderTask.java} | 4 +- .../player/PlayerProfileSaveTask.java | 24 + .../skills/AwardCombatXpTask.java} | 80 +- .../skills/BleedTimerTask.java} | 14 +- .../skills/SkillMonitorTask.java} | 20 +- .../skills/herbalism/GreenTerraTimerTask.java | 46 + .../skills/herbalism/GreenThumbTimerTask.java | 66 + .../com/gmail/nossr50/skills/SkillGuide.java | 107 - .../gmail/nossr50/skills/SkillManager.java | 88 +- .../nossr50/skills/SkillManagerStore.java | 256 +- .../nossr50/skills/acrobatics/Acrobatics.java | 72 +- .../skills/acrobatics/AcrobaticsManager.java | 258 +- .../gmail/nossr50/skills/archery/Archery.java | 136 +- .../skills/archery/ArcheryManager.java | 230 +- .../nossr50/skills/archery/TrackedEntity.java | 16 +- .../gmail/nossr50/skills/axes/AxeManager.java | 296 +- .../com/gmail/nossr50/skills/axes/Axes.java | 74 +- .../nossr50/skills/child/ChildConfig.java | 8 +- .../nossr50/skills/child/FamilyTree.java | 2 +- .../nossr50/skills/excavation/Excavation.java | 117 +- .../skills/excavation/ExcavationManager.java | 114 +- .../gmail/nossr50/skills/fishing/Fishing.java | 402 +- .../skills/fishing/FishingManager.java | 610 +-- .../skills/herbalism/GreenTerraTimer.java | 46 - .../skills/herbalism/GreenThumbTimer.java | 64 - .../nossr50/skills/herbalism/Herbalism.java | 216 +- .../skills/herbalism/HerbalismBlock.java | 150 +- .../skills/herbalism/HerbalismManager.java | 614 +-- .../nossr50/skills/mining/BlastMining.java | 206 +- .../gmail/nossr50/skills/mining/Mining.java | 294 +- .../nossr50/skills/mining/MiningManager.java | 576 +-- .../gmail/nossr50/skills/repair/Repair.java | 192 +- .../nossr50/skills/repair/RepairItemType.java | 16 +- .../nossr50/skills/repair/RepairManager.java | 2 +- .../skills/repair/RepairMaterialType.java | 36 +- .../gmail/nossr50/skills/repair/Salvage.java | 82 +- .../skills/repair/SimpleRepairManager.java | 11 +- .../nossr50/skills/smelting/Smelting.java | 120 +- .../skills/smelting/SmeltingManager.java | 264 +- .../gmail/nossr50/skills/swords/Swords.java | 35 +- .../nossr50/skills/swords/SwordsManager.java | 134 +- .../skills/taming/BeastLoreEventHandler.java | 107 +- .../taming/CallOfTheWildEventHandler.java | 210 +- .../taming/FastFoodServiceEventHandler.java | 54 +- .../skills/taming/GoreEventHandler.java | 88 +- .../taming/SharpenedClawsEventHandler.java | 30 +- .../gmail/nossr50/skills/taming/Taming.java | 28 +- .../nossr50/skills/taming/TamingManager.java | 290 +- .../gmail/nossr50/skills/unarmed/Unarmed.java | 92 +- .../skills/unarmed/UnarmedManager.java | 174 +- .../skills/woodcutting/TreeFeller.java | 551 +-- .../skills/woodcutting/Woodcutting.java | 364 +- .../com/gmail/nossr50/spout/SpoutConfig.java | 97 - .../com/gmail/nossr50/util/BlockChecks.java | 365 -- .../com/gmail/nossr50/util/BlockUtils.java | 364 ++ .../com/gmail/nossr50/util/ChimaeraWing.java | 15 +- .../{Hardcore.java => HardcoreManager.java} | 19 +- .../{Anniversary.java => HolidayManager.java} | 44 +- .../com/gmail/nossr50/util/ItemChecks.java | 650 ---- .../com/gmail/nossr50/util/ItemUtils.java | 647 ++++ .../java/com/gmail/nossr50/util/Misc.java | 31 +- .../ModChecks.java => util/ModUtils.java} | 587 +-- .../java/com/gmail/nossr50/util/Motd.java | 237 +- .../com/gmail/nossr50/util/Permissions.java | 4 +- .../com/gmail/nossr50/util/StringUtils.java | 271 +- .../{UpdateCheck.java => UpdateChecker.java} | 12 +- .../util/blockmeta/ChunkletManager.java | 2 +- .../util/blockmeta/HashChunkletManager.java | 72 +- .../blockmeta/PrimitiveChunkletStore.java | 4 +- .../blockmeta/PrimitiveExChunkletStore.java | 4 +- .../blockmeta/chunkmeta/ChunkManager.java | 5 +- .../chunkmeta/ChunkManagerFactory.java | 2 +- .../util/blockmeta/chunkmeta/ChunkStore.java | 6 +- .../chunkmeta/ChunkStoreFactory.java | 2 +- .../blockmeta/chunkmeta/HashChunkManager.java | 107 +- .../chunkmeta/McMMOSimpleChunkBuffer.java} | 10 +- .../chunkmeta/McMMOSimpleRegionFile.java} | 39 +- .../blockmeta/chunkmeta/NullChunkManager.java | 2 +- .../chunkmeta/PrimitiveChunkStore.java | 10 +- .../conversion/BlockStoreConversionMain.java | 3 +- .../BlockStoreConversionXDirectory.java | 2 +- .../BlockStoreConversionZDirectory.java | 13 +- .../commands/CommandRegistrationManager.java} | 737 ++-- .../commands/CommandUtils.java} | 244 +- .../{Users.java => player/UserManager.java} | 12 +- .../skills/CombatUtils.java} | 277 +- .../{ => skills}/ParticleEffectUtils.java | 178 +- .../utilities => util/skills}/PerksUtils.java | 157 +- .../skills/SkillUtils.java} | 1251 +++---- .../spout/SpoutSoundUtils.java} | 35 +- .../spout/SpoutUtils.java} | 1170 +++--- .../shatt/backup/ZipLibrary.java | 6 +- src/main/resources/armor.yml | 148 +- src/main/resources/blocks.yml | 216 +- src/main/resources/entities.yml | 130 +- src/main/resources/plugin.yml | 3012 +++++++-------- src/main/resources/spout.yml | 144 +- src/main/resources/tools.yml | 298 +- src/main/resources/treasures.yml | 1940 +++++----- .../PrimitiveExChunkletStoreTest.java | 2 - standards.md | 95 + 263 files changed, 24364 insertions(+), 23982 deletions(-) create mode 100644 .gitattributes delete mode 100644 README.creole create mode 100644 README.md create mode 100644 src/main/java/com/gmail/nossr50/commands/McabilityCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/McgodCommand.java rename src/main/java/com/gmail/nossr50/commands/{player => }/McmmoCommand.java (67%) create mode 100644 src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/XprateCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/admin/HardcoreCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/admin/McgodCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/admin/McrefreshCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/admin/VampirismCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java rename src/main/java/com/gmail/nossr50/{chat/commands => commands/chat}/AdminChatCommand.java (92%) rename src/main/java/com/gmail/nossr50/{chat/commands => commands/chat}/ChatCommand.java (70%) rename src/main/java/com/gmail/nossr50/{chat/commands => commands/chat}/PartyChatCommand.java (86%) create mode 100644 src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java rename src/main/java/com/gmail/nossr50/{database/commands => commands/database}/MmoupdateCommand.java (59%) create mode 100644 src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/hardcore/VampirismCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java rename src/main/java/com/gmail/nossr50/{party/commands => commands/party}/PartyChangePasswordCommand.java (53%) create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java rename src/main/java/com/gmail/nossr50/{party/commands => commands/party}/PartyExpShareCommand.java (56%) create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java rename src/main/java/com/gmail/nossr50/{party/commands => commands/party}/PartyInfoCommand.java (91%) create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java rename src/main/java/com/gmail/nossr50/{party/commands => commands/party}/PartyJoinCommand.java (58%) create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java rename src/main/java/com/gmail/nossr50/{party/commands => commands/party}/PartyLockCommand.java (63%) create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java rename src/main/java/com/gmail/nossr50/{party/commands => commands/party}/PartySubcommandType.java (92%) rename src/main/java/com/gmail/nossr50/{party/commands => commands/party}/PtpCommand.java (73%) delete mode 100644 src/main/java/com/gmail/nossr50/commands/player/McabilityCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/player/McnotifyCommand.java rename src/main/java/com/gmail/nossr50/{skills/acrobatics => commands/skills}/AcrobaticsCommand.java (92%) rename src/main/java/com/gmail/nossr50/{skills/archery => commands/skills}/ArcheryCommand.java (92%) rename src/main/java/com/gmail/nossr50/{skills/axes => commands/skills}/AxesCommand.java (93%) rename src/main/java/com/gmail/nossr50/{skills/excavation => commands/skills}/ExcavationCommand.java (89%) rename src/main/java/com/gmail/nossr50/{skills/fishing => commands/skills}/FishingCommand.java (90%) rename src/main/java/com/gmail/nossr50/{skills/herbalism => commands/skills}/HerbalismCommand.java (93%) rename src/main/java/com/gmail/nossr50/{skills/mining => commands/skills}/MiningCommand.java (94%) rename src/main/java/com/gmail/nossr50/{skills/repair => commands/skills}/RepairCommand.java (88%) rename src/main/java/com/gmail/nossr50/{ => commands}/skills/SkillCommand.java (87%) create mode 100644 src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java rename src/main/java/com/gmail/nossr50/{skills/smelting => commands/skills}/SmeltingCommand.java (92%) rename src/main/java/com/gmail/nossr50/{skills/swords => commands/skills}/SwordsCommand.java (93%) rename src/main/java/com/gmail/nossr50/{skills/taming => commands/skills}/TamingCommand.java (96%) rename src/main/java/com/gmail/nossr50/{skills/unarmed => commands/skills}/UnarmedCommand.java (93%) rename src/main/java/com/gmail/nossr50/{skills/woodcutting => commands/skills}/WoodcuttingCommand.java (90%) rename src/main/java/com/gmail/nossr50/{spout/commands => commands/spout}/MchudCommand.java (87%) rename src/main/java/com/gmail/nossr50/{spout/commands => commands/spout}/SpoutCommand.java (62%) rename src/main/java/com/gmail/nossr50/{spout/commands => commands/spout}/XplockCommand.java (84%) rename src/main/java/com/gmail/nossr50/{mods/config => config/mods}/CustomArmorConfig.java (83%) rename src/main/java/com/gmail/nossr50/{mods/config/CustomBlocksConfig.java => config/mods/CustomBlockConfig.java} (76%) rename src/main/java/com/gmail/nossr50/{mods/config => config/mods}/CustomEntityConfig.java (93%) rename src/main/java/com/gmail/nossr50/{mods/config/CustomToolsConfig.java => config/mods/CustomToolConfig.java} (87%) rename src/main/java/com/gmail/nossr50/config/{ItemWeightsConfig.java => party/ItemWeightConfig.java} (66%) create mode 100644 src/main/java/com/gmail/nossr50/config/spout/SpoutConfig.java rename src/main/java/com/gmail/nossr50/config/{TreasuresConfig.java => treasure/TreasureConfig.java} (87%) rename src/main/java/com/gmail/nossr50/database/{Database.java => DatabaseManager.java} (67%) delete mode 100644 src/main/java/com/gmail/nossr50/database/DatabaseUpdate.java rename src/main/java/com/gmail/nossr50/database/{Leaderboard.java => LeaderboardManager.java} (82%) delete mode 100644 src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/database/commands/McremoveCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/database/runnables/SQLReconnect.java create mode 100644 src/main/java/com/gmail/nossr50/datatypes/database/DatabaseUpdateType.java rename src/main/java/com/gmail/nossr50/{ => datatypes}/database/PlayerStat.java (79%) rename src/main/java/com/gmail/nossr50/{mods/datatypes => datatypes/mods}/CustomBlock.java (93%) rename src/main/java/com/gmail/nossr50/{mods/datatypes => datatypes/mods}/CustomEntity.java (94%) rename src/main/java/com/gmail/nossr50/{mods/datatypes => datatypes/mods}/CustomItem.java (88%) rename src/main/java/com/gmail/nossr50/{mods/datatypes => datatypes/mods}/CustomTool.java (91%) rename src/main/java/com/gmail/nossr50/{ => datatypes}/party/Party.java (82%) rename src/main/java/com/gmail/nossr50/datatypes/{ => player}/McMMOPlayer.java (86%) rename src/main/java/com/gmail/nossr50/datatypes/{ => player}/PlayerProfile.java (71%) rename src/main/java/com/gmail/nossr50/{skills/utilities => datatypes/skills}/AbilityType.java (73%) rename src/main/java/com/gmail/nossr50/{skills/utilities => datatypes/skills}/SkillType.java (94%) rename src/main/java/com/gmail/nossr50/{skills/utilities => datatypes/skills}/ToolType.java (65%) rename src/main/java/com/gmail/nossr50/{spout/buttons/McmmoButton.java => datatypes/spout/buttons/McMMOButton.java} (68%) rename src/main/java/com/gmail/nossr50/{ => datatypes}/spout/huds/HudType.java (78%) rename src/main/java/com/gmail/nossr50/{spout/huds/SpoutHud.java => datatypes/spout/huds/McMMOHud.java} (67%) rename src/main/java/com/gmail/nossr50/{spout/popups/Menu.java => datatypes/spout/popups/McMMOMenu.java} (71%) rename src/main/java/com/gmail/nossr50/{spout/popups/XpBar.java => datatypes/spout/popups/McMMOXpBar.java} (58%) rename src/main/java/com/gmail/nossr50/events/skills/{ => repair}/McMMOPlayerRepairCheckEvent.java (87%) rename src/main/java/com/gmail/nossr50/events/skills/{ => unarmed}/McMMOPlayerDisarmEvent.java (80%) delete mode 100644 src/main/java/com/gmail/nossr50/listeners/SelfListener.java rename src/main/java/com/gmail/nossr50/{spout => listeners}/SpoutListener.java (68%) rename src/main/java/com/gmail/nossr50/{util => }/metrics/MetricsManager.java (95%) delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyAcceptCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyCreateCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyQuitCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyRenameCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/runnables/ProfileSaveTask.java rename src/main/java/com/gmail/nossr50/runnables/{SaveTimer.java => SaveTimerTask.java} (52%) rename src/main/java/com/gmail/nossr50/runnables/{StickyPistonTracker.java => StickyPistonTrackerTask.java} (85%) rename src/main/java/com/gmail/nossr50/runnables/{McRankAsync.java => commands/McrankCommandAsyncTask.java} (74%) rename src/main/java/com/gmail/nossr50/runnables/{McTopAsync.java => commands/MctopCommandAsyncTask.java} (79%) rename src/main/java/com/gmail/nossr50/{database/runnables => runnables/database}/SQLConversionTask.java (87%) create mode 100644 src/main/java/com/gmail/nossr50/runnables/database/SQLReconnectTask.java rename src/main/java/com/gmail/nossr50/{database/runnables => runnables/database}/UserPurgeTask.java (51%) rename src/main/java/com/gmail/nossr50/{party/runnables/PartyAutoKick.java => runnables/party/PartyAutoKickTask.java} (86%) rename src/main/java/com/gmail/nossr50/{party/runnables/PartiesLoader.java => runnables/party/PartyLoaderTask.java} (57%) create mode 100644 src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java rename src/main/java/com/gmail/nossr50/{skills/runnables/CombatXpGiver.java => runnables/skills/AwardCombatXpTask.java} (59%) rename src/main/java/com/gmail/nossr50/{skills/runnables/BleedTimer.java => runnables/skills/BleedTimerTask.java} (88%) rename src/main/java/com/gmail/nossr50/{skills/runnables/SkillMonitor.java => runnables/skills/SkillMonitorTask.java} (59%) create mode 100644 src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenTerraTimerTask.java create mode 100644 src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenThumbTimerTask.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/SkillGuide.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java delete mode 100644 src/main/java/com/gmail/nossr50/spout/SpoutConfig.java delete mode 100644 src/main/java/com/gmail/nossr50/util/BlockChecks.java create mode 100644 src/main/java/com/gmail/nossr50/util/BlockUtils.java rename src/main/java/com/gmail/nossr50/util/{Hardcore.java => HardcoreManager.java} (83%) rename src/main/java/com/gmail/nossr50/util/{Anniversary.java => HolidayManager.java} (88%) delete mode 100644 src/main/java/com/gmail/nossr50/util/ItemChecks.java create mode 100644 src/main/java/com/gmail/nossr50/util/ItemUtils.java rename src/main/java/com/gmail/nossr50/{mods/ModChecks.java => util/ModUtils.java} (74%) rename src/main/java/com/gmail/nossr50/util/{UpdateCheck.java => UpdateChecker.java} (90%) rename src/main/java/{org/getspout/spoutapi/chunkstore/mcMMOSimpleChunkBuffer.java => com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleChunkBuffer.java} (83%) mode change 100755 => 100644 rename src/main/java/{org/getspout/spoutapi/chunkstore/mcMMOSimpleRegionFile.java => com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java} (93%) mode change 100755 => 100644 rename src/main/java/com/gmail/nossr50/{commands/CommandRegistrationHelper.java => util/commands/CommandRegistrationManager.java} (80%) rename src/main/java/com/gmail/nossr50/{commands/CommandHelper.java => util/commands/CommandUtils.java} (92%) rename src/main/java/com/gmail/nossr50/util/{Users.java => player/UserManager.java} (89%) rename src/main/java/com/gmail/nossr50/{skills/utilities/CombatTools.java => util/skills/CombatUtils.java} (73%) rename src/main/java/com/gmail/nossr50/util/{ => skills}/ParticleEffectUtils.java (96%) rename src/main/java/com/gmail/nossr50/{skills/utilities => util/skills}/PerksUtils.java (94%) rename src/main/java/com/gmail/nossr50/{skills/utilities/SkillTools.java => util/skills/SkillUtils.java} (88%) rename src/main/java/com/gmail/nossr50/{spout/SpoutSounds.java => util/spout/SpoutSoundUtils.java} (84%) rename src/main/java/com/gmail/nossr50/{spout/SpoutTools.java => util/spout/SpoutUtils.java} (53%) create mode 100644 standards.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..a981216a2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +* text + +*.png binary +*.wav binary diff --git a/Changelog.txt b/Changelog.txt index 8a41a5296..77b5226e9 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,1661 +1,1661 @@ -Changelog: -Versions without changelogs probably had very small misc fixes, like tweaks to the source code - -Key: - + Addition - = Fix - ! Change - - Removal - -Version 1.4.00-dev - + Added new Child Skill - Smelting! - + Added a version check, admins will get notified when a new version is available! - + Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed. - + Added config options for Hylian Luck skill - + Added display values to Unarmed command for Iron Grip - + Added '/party create ' command, use this to create a party - + Added '/party disband' command, kicks out all members and deletes the party - + Added '/ptp toggle' command, to disable party teleportation. - + Added '/ptp accept' and '/ptp acceptall' commands - + Added an automatic party kick when a party member has been offline for 7 days (default) - + Added a permission to allow friendly fire in parties, both attacker and defender must have it for friendly fire to occur - + Added timeout on party teleport requests - + Added XP bonus for Archery based on distance from shooter to target - + Added ability to config Hylian Luck drops through treasures.yml - + Added party XP sharing, when more party members are near the share bonus increases. - + Added vanilla XP boost for Fishing - includes permissions, config options, etc - + Added particle effect for bleeding - + Added methods to check if a player is in party or admin chat to the ChatAPI - + Added /mcpurge functionality for Flatfile users - + Added basic support for Mo' Creatures (and other entity mods) - specify mob info in entities.yml - + Added Shears, Buckets, Fishing Rods, Flint & Steel, Carrot Sticks, and Bows to the list of items that can be Salvaged - + Added the "wait" music disc to the default fishing treasures - + Added "Chinese (Taiwan)" localization files (zh_TW) - + Added '/hardcore' and '/vampirism' commands for toggling these modes on or off. - + Added Block Cracker to Unarmed's Berserk, turn smooth brick into cracked smooth brick - + Added config option to disable automatic zip backups. - + Added particle effects for many abilities. - + Added '/mcnotify' command to toggle ability notifications on/off - + Added ability for config files to automatically update with new keys, and prune out old ones - + Added config option to make .new config files instead over writing over old ones when updating - + Added "Holy Hound" ability to Taming - + Added "Shroom Thumb" ability to Herbalism - + Added child.yml config file to choose parents for child skills - + Added '/party itemshare ' command to choose party item share mode - + Added '/party itemshare ' command to control items that are shared - + Added itemweights.yml file to determine which items are more valuable for party itemshare - = Fixed Green Thumb on wheat not working properly at rank 4 - = Fixed Green Thumb and Green Terra consuming twice the amount of seed needed - = Fixed Green Terra not also checking Green Thumb permissions - = Fixed bug where splash potions could raise a player's unarmed level - = Fixed bug where fired arrows could raise skill levels other than Archery - = Fixed /ptp telporting the target to the player, rather than the other way around. - = Fixed Impact reducing the durability of non-armor equipped blocks - = Fixed Impact reducing improperly the durability of armors (as a consequence it is now more effective) - = Fixed multiple commands not working properly on offline players - = Fixed /mmoedit not giving feedback when modifying another players stats - = Fixed the guide usage string showing up every time /skillname was called - = Fixed Spout not being able to precache our resources properly, and therefore making our XP bars fail - = Fixed Spout config files loading / generating when they shouldn't have - = Fixed mod config files loading / generating when they shouldn't have +Changelog: +Versions without changelogs probably had very small misc fixes, like tweaks to the source code + +Key: + + Addition + = Fix + ! Change + - Removal + +Version 1.4.00 + + Added new Child Skill - Smelting! + + Added a version check, admins will get notified when a new version is available! + + Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed. + + Added config options for Hylian Luck skill + + Added display values to Unarmed command for Iron Grip + + Added '/party create ' command, use this to create a party + + Added '/party disband' command, kicks out all members and deletes the party + + Added '/ptp toggle' command, to disable party teleportation. + + Added '/ptp accept' and '/ptp acceptall' commands + + Added an automatic party kick when a party member has been offline for 7 days (default) + + Added a permission to allow friendly fire in parties, both attacker and defender must have it for friendly fire to occur + + Added timeout on party teleport requests + + Added XP bonus for Archery based on distance from shooter to target + + Added ability to config Hylian Luck drops through treasures.yml + + Added party XP sharing, when more party members are near the share bonus increases. + + Added vanilla XP boost for Fishing - includes permissions, config options, etc + + Added particle effect for bleeding + + Added methods to check if a player is in party or admin chat to the ChatAPI + + Added /mcpurge functionality for Flatfile users + + Added basic support for Mo' Creatures (and other entity mods) - specify mob info in entities.yml + + Added Shears, Buckets, Fishing Rods, Flint & Steel, Carrot Sticks, and Bows to the list of items that can be Salvaged + + Added the "wait" music disc to the default fishing treasures + + Added "Chinese (Taiwan)" localization files (zh_TW) + + Added '/hardcore' and '/vampirism' commands for toggling these modes on or off. + + Added Block Cracker to Unarmed's Berserk, turn smooth brick into cracked smooth brick + + Added config option to disable automatic zip backups. + + Added particle effects for many abilities. + + Added '/mcnotify' command to toggle ability notifications on/off + + Added ability for config files to automatically update with new keys, and prune out old ones + + Added config option to make .new config files instead over writing over old ones when updating + + Added "Holy Hound" ability to Taming + + Added "Shroom Thumb" ability to Herbalism + + Added child.yml config file to choose parents for child skills + + Added '/party itemshare ' command to choose party item share mode + + Added '/party itemshare ' command to control items that are shared + + Added itemweights.yml file to determine which items are more valuable for party itemshare + = Fixed Green Thumb on wheat not working properly at rank 4 + = Fixed Green Thumb and Green Terra consuming twice the amount of seed needed + = Fixed Green Terra not also checking Green Thumb permissions + = Fixed bug where splash potions could raise a player's unarmed level + = Fixed bug where fired arrows could raise skill levels other than Archery + = Fixed /ptp telporting the target to the player, rather than the other way around. + = Fixed Impact reducing the durability of non-armor equipped blocks + = Fixed Impact reducing improperly the durability of armors (as a consequence it is now more effective) + = Fixed multiple commands not working properly on offline players + = Fixed /mmoedit not giving feedback when modifying another players stats + = Fixed the guide usage string showing up every time /skillname was called + = Fixed Spout not being able to precache our resources properly, and therefore making our XP bars fail + = Fixed Spout config files loading / generating when they shouldn't have + = Fixed mod config files loading / generating when they shouldn't have = Fixed bug where Green Terra could activate on crops that weren't fully grown. - = Fixed several typos relating to locale string display + = Fixed several typos relating to locale string display = Fixed bug where all skill guide headers appeared as "Skillname Guide Guide" - = Fixed bug where Impact was applied incorrectly due to an inverted method call - = Fixed bug where Impact improperly determined the defender's armor - = Fixed a bug which made it impossible to join other players' parties - = Fixed ArrayIndexOutOfBoundsException resulting from being unranked in a skill when using FlatFile + = Fixed bug where Impact was applied incorrectly due to an inverted method call + = Fixed bug where Impact improperly determined the defender's armor + = Fixed a bug which made it impossible to join other players' parties + = Fixed ArrayIndexOutOfBoundsException resulting from being unranked in a skill when using FlatFile = Fixed Woodcutting accidentally using Mining double drop values. - = Fixed Hylian Luck not removing the block-placed flag from flowers. - = Fixed Hylian Luck not checking the block-placed flag on flowers. - = Fixed Leaf Blower not respecting the unlock level set in advanced.yml - = Fixed abilities activating with the wrong tool in hand - = Fixed Experience.Gains.Mobspawners.Enabled not being used correctly (the check was inverted) - = Fixed bug where Iron Grip was using the attacker's skill values rather than the defender's. - = Fixed a bug where /party kick would trigger the PartyChangeEvent for the wrong player - = Fixed /party kick not working on offline players - = Fixed a bug where party join messages weren't displayed - = Fixed a bug where a new party leader wasn't appointed, after the previous party leader left - = Fixed a bug where Disarm and Deflect had wrong values - = Fixed Magic Hunter (Fishing ability) favoring certain enchants - ! Changed our custom chat events to be async - ! Changed some config value key names regarding double drops and XP - make sure you copy any custom values to your new config after updating. - ! Changed Green Terra blocks to be determined via permissions instead of the config file - ! Config files are now backed up even when running in SQL mode - ! Changed /p and /a to use /partychat and /adminchat as the default command name. The use of /p, /pc, /a, and /ac is still supported. - ! We're now using Bukkit sounds instead of Spout sounds. + = Fixed Hylian Luck not removing the block-placed flag from flowers. + = Fixed Hylian Luck not checking the block-placed flag on flowers. + = Fixed Leaf Blower not respecting the unlock level set in advanced.yml + = Fixed abilities activating with the wrong tool in hand + = Fixed Experience.Gains.Mobspawners.Enabled not being used correctly (the check was inverted) + = Fixed bug where Iron Grip was using the attacker's skill values rather than the defender's. + = Fixed a bug where /party kick would trigger the PartyChangeEvent for the wrong player + = Fixed /party kick not working on offline players + = Fixed a bug where party join messages weren't displayed + = Fixed a bug where a new party leader wasn't appointed, after the previous party leader left + = Fixed a bug where Disarm and Deflect had wrong values + = Fixed Magic Hunter (Fishing ability) favoring certain enchants + ! Changed our custom chat events to be async + ! Changed some config value key names regarding double drops and XP - make sure you copy any custom values to your new config after updating. + ! Changed Green Terra blocks to be determined via permissions instead of the config file + ! Config files are now backed up even when running in SQL mode + ! Changed /p and /a to use /partychat and /adminchat as the default command name. The use of /p, /pc, /a, and /ac is still supported. + ! We're now using Bukkit sounds instead of Spout sounds. ! It is now possible to use a negative number for Max_Level in treasures.yml to not use a maximum level, changed default file accordingly ! A Fishing catch will now always contains a fish even if a treasure is found - ! Changed how Berserk handles not picking up items to avoid listening to PlayerPickupItemEvent + ! Changed how Berserk handles not picking up items to avoid listening to PlayerPickupItemEvent ! Moved Hylian Luck into a separate listener since it actually cancels the event and shouldn't just be on MONITOR. - ! Changed how Tree Feller is handled, it should now put less stress on the CPU - ! Changed Tree Feller to work on huge mushrooms - ! Changed Fisherman's Diet and Farmer's Diet to use two seperate config values - ! Major refactoring - please take note, this WILL break any mcMMO-related plugin not properly hooking into the API. - ! Changed the way party commands work, use /party ? to check how to use the new commands - ! Changed McMMOChatEvent to contain the plugin that the event originated from. - ! Changed Excavation to have individual XP values for each block type, rather than a base XP value. - ! Changed the way party teleportation works. When using /ptp, the target player needs to confirm the teleport before it takes place. (Configurable) - ! Changed BeastLore: Now also displays offline player names - ! Changed backup task to include ALL config files - ! Deprecated most functions in ExperienceAPI, replaced them with identical versions that use a String for the SkillName rather than the SkillType enum values - ! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak. Option exists in hidden.yml to change this to an potion-based buff. - ! Changed locales to fall back on English when translated strings cannot be found. - - Removed Party "master/apprentice" system. Replaced with the new party XP share feature. - - Removed unused "healthbar" files from the resources - - Removed config options for disabling commands from the config.yml. This should instead be done through permissions. - - Removed /mcc command. Replaced with /mcmmo [?|help|commands] + ! Changed how Tree Feller is handled, it should now put less stress on the CPU + ! Changed Tree Feller to work on huge mushrooms + ! Changed Fisherman's Diet and Farmer's Diet to use two seperate config values + ! Major refactoring - please take note, this WILL break any mcMMO-related plugin not properly hooking into the API. + ! Changed the way party commands work, use /party ? to check how to use the new commands + ! Changed McMMOChatEvent to contain the plugin that the event originated from. + ! Changed Excavation to have individual XP values for each block type, rather than a base XP value. + ! Changed the way party teleportation works. When using /ptp, the target player needs to confirm the teleport before it takes place. (Configurable) + ! Changed BeastLore: Now also displays offline player names + ! Changed backup task to include ALL config files + ! Deprecated most functions in ExperienceAPI, replaced them with identical versions that use a String for the SkillName rather than the SkillType enum values + ! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak. Option exists in hidden.yml to change this to an potion-based buff. + ! Changed locales to fall back on English when translated strings cannot be found. + - Removed Party "master/apprentice" system. Replaced with the new party XP share feature. + - Removed unused "healthbar" files from the resources + - Removed config options for disabling commands from the config.yml. This should instead be done through permissions. + - Removed /mcc command. Replaced with /mcmmo [?|help|commands] - Removed options to allow Mining & Excavation without a tool due to the changes to their abilities - -Version 1.3.14 - + Added new Hylian Luck skill to Herbalism. + +Version 1.3.14 + + Added new Hylian Luck skill to Herbalism. = Fixed a memory leak involving mob tracking - - Removed extra durability loss from Leaf Blower - -Version 1.3.13 - + Added task & command to prune old and powerless users from the SQL database. - + Added Craftbukkit 1.4.6 / 1.4.7 compatibility - + Added new /mcrank command for showing a players leader board ranking for all skills in one place - + Added a configurable durability cap for ArmorImpact to advanced.yml - + Added the version number to /mcmmo - + Added bats, giants, witches, withers, and wither skeletons to the mcMMO combat experience list, and makes their experience drops configurable - + Added the ability to track mobs spawned by mob spawners or the Taming ability when the chunks they are in unload and reload - + Added wooden button to the list of items that shouldn't trigger abilities - + Added a new feature to fishing. Players will have +10% chance of finding enchanted items when fishing while it's raining - + Added displaying bonus perks on skill commands - + Added config option to disable gaining Acrobatics XP from dodging lightning - + Added missing skill guides. They're finally here! - + Added more localization - + Added a very secret easter egg - = Fix issue with Sand/Gravel tracking - = Fix possible NPE when using the PartyAPI to add a player to a party that doesn't exist. - = Fix mcremove command for mySQL - = Fix a java.io.FileNotFoundException when using SQL - = Impact now works with mobs wearing armor - = Fixed issue with Tree Feller dropping player-placed blocks - = Fixed issue with missing default cases from several switch/case statements - = Fixed issue with Mining using actual skill level rather than max skill level - = Fixed some issues with static access - = Fixed ItemStack deprecation issues - = Fixed Async deprecation issues - = Fixed a bug with MySQL databases (non-alphanumeric characters preventing MySQL access) - = Fixed a bug where the /skillreset command was broken - = Fixed a bug where skill commands displaying .x% instead of 0.x% - = Fixed a bug Unbreaking enchantments being ignored when using Treefelling and when hit by Armor Impact - = Fixed a bug where only 1 diamond was needed to fully repair a broken item: Repaired the Repair skill! - = Fixed a bug where a infinite loop of errors caused by mySQL database could cause the server to crash - = Fixed a bug where PartyChangeEvent was fired even when a player isn't able to change parties - = Fixed a bug which caused advanced.yml not to work for Swords - = Fixed a bug which caused advanced.yml not to respect every MaxChance node - = Fixed a bug where GreenThumb_StageChange wasn't read from advanced.yml - = Fixed a bug where Repair would remove enchantments but the glow effect remained - = Fixed a bug where dropped items did not retain custom NBT data - = Fixed a bug which caused a potentially infinite recursion in a btree structure - = Fixed a NPE with custom blocks - = Fixed a bug with Blast Mining never dropping debris blocks - = Fixed a bug with Blast Mining incorrectly handling reduced TNT damage - = Fixed a bug with conflicting fishing enchantments - = Fixed a bug where triple drops wouldn't happen - = Fixed a bug which caused fishing to ignore max/min levels in treasures.yml - = Fixed a bug where treefeller affected player-placed blocks - = Fixed bug where Skull Splitter would be applied twice. - ! GJ stopped being a lazy slacker and got stuff done - ! Nossr50 actually committed something - ! Changed code that uses SpoutPlugin to make it compatible with the latest version - ! Reimplemented skill level and power level caps. - ! Moved Arcane Forging and Fishing setting from config.yml to advanced.yml - ! Overall SQL query improvements - ! Reduced number of SQL queries for mcTop command from 11 to 1, speeding it up immensely - ! Changed FFS Leaderboards to hold information in memory rather than doing IO work (optimizations) - ! Improved chunk conversion (less errors) - ! Changed Fishing Treasure Hunter, chance has increased and now actually is level dependent - ! Indexed most used mySQL columns for faster queries - - Removed dead code relating to null profiles - - Removed unused imports - - Removed ChunkletUnloader and dependents, since they are no longer necessary. - -Version 1.3.12 - + Added Craftbukkit 1.4.5 compatibility - + Added the new 1.3.2 items, xp and double drops for Cocoa beans & Emeralds, EnderChest to the list of blocks that shouldn't trigger abilities - + Added new items from Minecraft 1.4 to Herbalism (potatoes & carrots) - + Added new configuration file for advanced users. - + Added new permission nodes to greenthumb for the 1.4 items - + Added new mobs from Minecraft 1.4 checks for every ability - + Added new active ability for Repair: Salvage - + Added options to 'config.yml' configure shake chance - + Added the option to negate experience earned for Herbalism while in a minecart to prevent afk leveling - + Added Green thumb now converts cobble walls to mossy cobble walls - + Added beacons and anvils to list of blocks that don't trigger abilities - + Added a configuration option to disable experience gains when in a minecraft for Acrobatics and Herbalism, to prevent AFK leveling - + Added a new passive ability for Fishing, Fishermans diet. Increases hunger restored from fish - + Added a feature to display all active perks on login - ! Changed Fishing, Shake drops changed from guaranteed to based upon fishing level and perks - ! Changed Woodcutting, the amount of experience earned when using Tree Feller on jungle trees has increased - ! Changed Herbalism double drop rates for melons and netherwart - ! Changed filesystem usage, it's reduced a lot. Should help reduce lag on larger servers - ! Changed database connection handling. Support for aggressive connection timeouts, with exponential backoff for multiple failures - ! Changed Cobblestone walls are now mossy-able with Greenthumb - ! Changed the skull drop rates of the shake ability to 3% - = Fixed a NPE when Citizens perform certain tasks - = Fixed a NPE with Woodcutting, excessive null chunk before earning Woodcutting experience - = Fixed a NPE related to skill cooldowns - = Fixed a NPE when a players profile was null - = Fixed a NPE involving certain explosions - = Fixed a dupe bug when for players who were using a 'nuker' client - = Fixed a dupe bug where pistons were used to dupe ores - = Fixed a dupe bug with Salvage when players were in Creative mode - = Fixed a bug where the player was displayed an incorrect cooldown time - = Fixed a bug where players could earn experience when they were dealing 0 damage - = Fixed a bug where players could get double drops from mossified Cobblestone - = Fixed a bug where Herablism magically converted potatoes to carrots - = Fixed a bug where you couldn't modify the stats of offline players - = Fixed a bug where treefeller didn't work properly on tree's with side-way logs - = Fixed a bug where the Arcane forging downgrade chance should've been 0, but actually wasn't - = Fixed a bug where Fishing would sometimes give items with empty enchantments - = Fixed a bug where the lucky perk for Fishing was actually an unlucky perk - - Removed nothing - -Version 1.3.11 - ! Changed axes to start with 1 durability damage instead of 5, gain 1 durability damage every 50 levels instead of 30, and only have a 25% chance on hit to damage armor (per armor piece) - + Added compatibility with bow-wielding NPCs from Citizens/NPC mods - + Added compatibility for pvp-prevention plugins for Serrated Strikes - = Fixed bug where mcMMO could throw NPE errors if trees cut down were from a custom mod and had an id of 17 - = Fixed dupe bug where mcMMO would ignore other block-protection plugins for various abilities - = Fixed NPE with hardcore mode's vampirism - -Version 1.3.10 - + Added 1.3.1 compatibility - + Added permission node for Iron Grip ability (mcmmo.ability.unarmed.irongrip) - + Added ability for custom blocks to drop a range of items. - + Added Ability API functions - + Added 50% & 150% XP boost perks - + Added "lucky" perk for donors - = Fixed /inspect not working on offline players - = Fixed custom blocks, tools and armors not loading properly - = Fixed duplication bug with sticky pistons - = Fixed "GenericLabel belonging to mcMMO..." message - = Fixed menu exit button not working - = Fixed Repair enchant downgrade not working - = Fixed NPE caused by Spout players after a /reload - = Fixed ConcurrentModificationException on world unload - = Fixed players never being removed from memory (memory leak) - = Fixed admin chat being seen by everyone - = Fixed issue with UTFDataFormatException occurring on occasion when trying to load Chunklets - = Fixed ArrayIndexOutOfBounds error caused when trying to use /xplock after logging in but before gaining XP - = Fixed custom tools not properly respecting the Ability_Enabled flag. - = Fixed "lower tool" messages still being displayed even when ability messages are disabled. - = Fixed custom blocks not dropping the proper item with Super Breaker when Silk Touch is used - = Fixed custom woodcutting blocks throwing errors. - = Fixed possible ClassCastException from catching something other than a mob when using the Shake Mob skill - ! Changed the format by which Chunklets are stored to be much smaller, and much faster to load - ! Optimized how player placed blocks are tracked - -Version 1.3.09 - + Added compatibility with AntiCheat (Which I highly recommend to prevent cheating) - + Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP) - + Added reduced cooldown permission nodes as special perks (1/4, 1/3, 1/2 cooldown) - + Added increased activation time permissions nodes as special perks (+4, +8, and +12 seconds) - + Added API for plugins to add custom tools directly via Spout - repair / abilities do not work ATM - + Added offline party members to the list displayed by /party - + Added possibility to kick offline members from parties - = Fixed bug that would cause a NPE for players that had no parties - = Fixed Vampirism not notifying the correct amount of stolen levels - = Fixed bug with Acrobatics not saving you from deadly falls - = Fixed /mcremove being applied only after a reload - = Fixed Archery PVE disablement not working properly - = Fixed possible NPE when a projectile is shot by a dispenser or doesn't have any shooter - = Fixed issue with NoCheatPlus and Serrated Strikes / Skull Splitter (fight.noswing) - = Fixed tiny memory leak concerning Archery - = Fixed bug where you could receive Archery XP from Potions - = Fixed bug where Chunklets for the < 64 y coordinates would not be properly loaded - = Fixed exploit with block duplication via piston pushing - = Fixed bug with falling sand/gravel not being tracked - = Fixed bug with Tree Feller not working with custom axes - = Fixed bug with locale strings when trying to teleport to a non-existent player - = Fixed bug with Tree Feller changing durability before checking for axe splintering - = Fixed bug with Repair Mastery permission due to typo - = Fixed bug with repairing items that use metadata - = Fixed bug with Chunklets not being reloaded on /reload - = Fixed possible NPE when falling with no item in hand - ! API methods can now only be used in a static way - ! Arrows shot from a bow having the Infinity enchantment can no longer be retrieved - ! Arrows that aren't shot by an entity are now able to be dodged (currently only from dispensers) - ! Changed Spout settings to be in their own config file (spout.yml) - ! Changed file format for parties (parties.yml), previous files are no longer used - ! Changed mcMMO to inform on corrupt Chunklets and make new ones - -Version 1.3.08 - + Added more notifications about Vampirism and Hardcore mode on player death - + Added information about Hardcore mode when joining a server running Hardcore mode - + Added new hidden.yml inside the jar for very sensitive config options for advanced users - + Added option to disable Chunklets for servers which do not have doubledrops and do not care about xp farming - + Added new "Max_Seconds" setting in config.yml to limit the max time of abilities - + Added new repair configs to allow customization of the repair skill - + Added message to inform users about hardcore mode on login - = Fixed exploit where you could gain tons of Acrobatics XP from spamming Ender Pearls - = Fixed normal pistons marking a block as user-placed on retract if it wasn't a sticky piston (thanks turt2live!) - = Fixed handling of the Unbreaking enchantment so that tools are actually damaged as they should now - = Fixed hurting pet cats with serrated strikes - ! Changed Hardcore Vampirism to require the victim to have at least half the skill level of the killer in order for vampirism to proc (this is to avoid exploitation) - ! Changed Hardcore Vampirism to steal a minimum of 1 skill level from a player no matter the percentage - ! Changed Hardcore & Vampirism to not be executed if percentages were set to zero or below - ! Changed Vampirism to actually remove stats from the victim - ! Changed Vampirism to inform the victim of their stat loss - ! Changed Mining to allow Silk Touch to work again since the dupe exploit has been fixed. - ! Changed Metrics to also report if the server uses plugin profiling - - Removed level and item settings from Repair skill in config.yml - -Version 1.3.07 - + Added ability to gain XP from custom blocks. Enable custom blocks in the config file, then enter the data in the blocks.yml file. - + Added ability to gain XP with custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file. - + Added ability to repair custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file. - + Added ability to repair custom armor. Enable custom armor in the config file, then enter the data in the armor.yml file. - + Added functionality which makes a new folder in all world files "mcmmo_data" to store player placed block information in - + Added new configurable Hardcore mode functionality to mcMMO - + Added new configurable Vampirism PVP stat leech for Hardcore mode - + Added new bypass permission node for the negative penalties of Hardcore mode 'mcmmo.bypass.hardcoremode' - + Added configurable level curve multiplier which allows for tweaking the steepness of the XP needed to level formula - + Added a permission node for Archery bonus damage - + Added a permission node for Greater Impact ability - + Added permission nodes for Treasure & Magic Hunter for Fishing - + Added a permission node for Farmer's Diet - + Added config options for enabling/disabling specific double drops - + Added automatic zip backup of flatfile database & config files - + Added config options to enable/disable specific skills for PVP & PVE - = Fixed bug where Tree Feller was looking at the wrong blocks for determining how much to take down. - = Fixed bug where Green Terra consumed seeds even on Mossy Stone Brick - = Fixed bug where the client didn't reflect the Stone Brick to Mossy Stone Brick change - = Fixed bug where an arrow could bounce off entities on daze proc - = Fixed bug where a player could gain Acrobatics experience while riding a cart - = Fixed /party not working properly with 2 arguments - = Fixed /party not showing properly the member list - = Fixed /ability not checking the right permission - = Fixed rare NPE on /party command - = Fixed Arrow Retrieval dropping only one arrow - = Fixed /p and /a incompatibilities with bChatManager - = Fixed Iron Grip working reversely - = Fixed NPE when user clicked the HUD button with Spout - = Fixed bug where the permission node for Impact didn't work - = Fixed some bypass nodes defaulting true for Ops - = Fixed bug with trying to use Chimera Wing while standing on a half-block - = Fixed duplication bug when a placed block was mined after a server restart - = Fixed exploit where shooting yourself with an arrow gave Archery XP - ! Changed the mcMMO motd to link to the new website rather than the wiki - ! Changed bleeding ticks damage to 1 from 2 - ! Changed Mining to ignore blocks when the pick is enchanted with Silk Touch - ! Changed Super Breaker to be non-functional when used with a Silk Touch enchanted pick - ! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server - ! Changed the permission node for Blast Mining detonation to mcmmo.ability.blastmining.detonate (was mcmmo.skills.blastmining) for the sake of consistency - ! Changed skill commands to only display what you have permissions for - ! Changed mcMMO to use a new storage system for player placed blocks - - Removed some unused permission nodes - - Removed a few config options in favor of permissions nodes (Hunger Bonus, Armor/Tool Repair, Instant Wheat Regrowth) - - Removed level requirement for repairing string tools from the config file - -Version 1.3.06 - + Added Iron Golem XP for aggressive golems - + Added permissions check to skill functions - + Added API functions for obtaining offline profiles & profiles via player names - + Added API functions for admin & party chat - + Added Iron Grip skill to Unarmed which gives players an chance to keep from being disarmed. - + Added some new languages to the locale files. - = Fixed Green Thumb consuming 2 seeds instead of 1 - = Fixed exploit where you could teleport to yourself with PTP to prevent things like fall damage - = Fixed NPE error with Metrics on startup - = Fixed bug where Herbalism required double drops permission to give XP - = Fixed bug where {0} would be displayed in front of your power level in mcstats - = Fixed mmoupdate not being useable from console - = Fixed bug with repairing wooden tools - = Fixed bug with Nether Wart not awarding XP - = Fixed bug with fishing treasures when treasures list is empty - = Fixed bug with only getting one level when there was enough XP for multiple levels. - = Fixed bugs with the way /mctop displayed - = Fixed issues with custom characters & locale files. - = Fixed double explosion for Blast Mining - = Fixed Blast Mining not giving triple drops when it should - ! Changed Bleeding to now stack to a finite number on Monsters and will wear off eventually - ! Changed how we handled the config file to prevent any bugs when returning values - ! Changed locale files to use a new naming scheme. This breaks ALL old locale files. If you want to assist with re-translating anything, go to getlocalization.com/mcMMO - ! Changed /mcremove to check for users in the MySQL DB before sending queries to remove them - ! Changed how the tree feller threshold worked for the better - ! Changed /mcremove to no longer kick players when they are removed from database - ! Changed /mcremove to work on offline users for FlatFile - ! Changed PlayerProfile constructor to always take a boolean - ! Changed getPlayerProfile function to work for online & offline users - ! Changed Archery's Daze to deal 4 DMG on proc (2 Hearts) - ! Changed /addlevel command to work for offline users - ! Changed party & admin chat handling to be nicer to developers - ! Changed /mcrefresh to work from console - ! Changed /mcrefresh to work for offline players - ! Changed UpdateXPBar function to hopefully avoid errors - ! Changed /party to show offline party members - ! Changed Blast Mining requirements, now asks for the player to be crouching - -Version 1.3.05 - + Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%) - + Added ExperienceAPI and PartyAPI classes for developer use - + Added ability to cap overall power level - + Added showing powerlevel below a persons name if you run Spout (optional) - = Fixed errors when Spout would disable itself after start-up - = Fixed XP bar not updating when XP was gained - = Fixed bug with repairing wooden tools - = Fixed bug where spawned wolves only had 8 health. - = Fixed bug where rare Treasures from Excavation were dropping too often - = Fixed bug where Skull Splitter & Serrated Strikes could be used without permissions. - = Fixed bug where API functions were set to static - = Fixed bug where mmoedit threw errors when modifying an offline user - = Fixed dupe exploit with Blast Mining - ! Changed Tree Feller to account for ability durability loss but not leaves. - ! Changed bypass node for Arcane Forging to not default to true for OPs - - Removed Ignition from Archery - - Removed McMMOPlayerRepairEvent - was basically a duplicate of McMMOPlayerRepairCheck but couldn't be cancelled. - -Version 1.3.04 - + Added McMMOPlayerRepairEvent for API usage - fires after completion of a repair. - + Added McMMOPlayerRepairCheckEvent for API usage - fires before repair process begins, can be cancelled. - + Added ability to get skill level from McMMOPlayerExperience events - + Added McMMOPartyTeleportEvent for API usage - fires before a successful teleportation would occur. - + Added McMMOPartyChangeEvent for API usage - fires whenever a player joins or leaves a party - = Fixed Shake ability dropping bonemeal instead of ink for squids. - = Fixed Green Terra & Super Breaker awarding 4x drops at high levels. - = Fixed summoned ocelots never changing skins. - = Fixed bug with Disarm not working - = Fixed some API functions not being visible - = Fixed bug where /ptp worked on dead party members - ! Changed MySQL to reload all player information on reconnection - ! Changed event package structure - be sure to update these if you're using the API in your plugin - -Version 1.3.03 - + Added Ocelots to Taming XP tables - + Added ability to summon Ocelots with Call of the Wild - + Added offline user functionality to mmoedit - + Added bookshelves to list of blocks that don't trigger abilities. - + Added 'mcmmo.repair.arcanebypass' permission node to bypass Arcane Repair and keep your enchantments - + Added config option to disable Herbalism's instant wheat replanting - + Added LOTS of new permissions nodes. *CHECK PLUGIN.YML FOR UPDATES* - + Added Italian locale file - thanks Luxius96! - + Added ability to inspect Ocelots with Beast Lore - + Added console functionality to mctop - = Fixed Green Terra not awarding Triple Drops - = Fixed ClassCastException from Taming preventDamage checks - = Fixed issue with Blast Mining not seeing TNT for detonation due to snow - = Fixed issue with block interaction returning NPEs - = Fixed issue where every block broken had a mining check applied - = Fixed issue where every block broken had a herbalism check applied - = Fixed issue where blocks weren't being removed from the watchlist - = Fixed exploit where you could use /ptp to teleport to anyone - = Fixed bug where Green Terra didn't work on Stone Brick - = Fixed bug where Tree Feller could be used without permissions - = Fixed exploit where falling sand & gravel weren't tracked - = Fixed exploit where Acrobatics could be leveled via Dodge on party members. - = Fixed exploit where you could gain combat XP on animals summoned by Call of the Wild - ! Changed mcMMO to save profiles only when the profile is about to be discarded rather than on player quit - ! Changed MySQL to try to reconnect every 60 seconds rather than infinitely which caused server hangs - ! Changed mcMMO to be better about saving player information on server shutdown - ! Changed PTP to prevent teleporting if you've been hurt in the last 30 seconds (configurable) - ! Changed Chimera Wing failure check to use the maxWorldHeight. - ! Changed inspect failed message to say inspect rather than whois - ! Changed Call of the Wild to activate on left-click rather than right-click - ! Changed Blast Mining to track based on Entity ID vs. Location - ! Changed mmoedit to save a profile when used (this will make mctop update) - ! Changed a few Runnable tasks to have their own classes - ! Changed parties so that a player will leave their existing party if they enter a world where they don't have party permissions. - ! Changed Call of the Wild to summon animals already tamed. - ! Changed mob spawner tracking to use new Metadata API - ! Changed block watch list to use new Metadata API - ! Changed around a few config options, including the ones for mySQL. *YOU NEED TO REDO YOUR CONFIG FILE* - - Removed 'true/false' debug message from Inspect command - -Version 1.3.02 - + Added in game guides for Mining, Excavation, and Acrobatics. Simply type /skillname ? to access them - ! Changed Tree Feller to hand out 1/4 of normal XP for each JUNGLE LOG block it fells - ! Changed Tree Feller to only fell trees if you have enough durability - ! Changed Tree Feller to cause injury if your axe splinters from a failed Tree Feller attempt - ! Changed invincibility checks in EntityDamage listeners to accommodate for vanilla MC behaviour - ! Changed Ignition to add fire ticks rather than replacing them. - ! Changed Axes critical to have a max critical rate of 37.5% down from 75% - = Fixed bug where Taming defensive checks got called twice - = Fixed Shake not working correctly - = Fixed bug with Axes command displaying wrong Greater Impact bonus damage - = Fixed bug where Impact didn't apply bonus damage - = Fixed Impact proccing multiple times in a row - = Fixed bug where PVE skills didn't level - -Version 1.3.01 - = Fixed bug where Tree Feller had no cooldown - = Fixed bug with activating Skull Splitter after using Tree Feller - -Version 1.3.00 - + Added ability to customize drops for Excavation skill (treasures.yml) - + Added ability to customize drops for Fishing skill (treasures.yml) - + Added messages to nearby players when your abilities wear off - + Added jungle trees to Woodcutting XP tables - + Added player notification for when they stop Bleeding - + Added configuration option to control mcMMO reporting damage events - + Added hunger regain bonuses to Herbalism skill - + Added Blast Mining subskills to Mining - + Added Fast Food Service subskill to Taming - + Added size limit to Tree Feller in config as Tree Feller Threshold - + Added /inspect (works on offline players) - + Added /addlevels commands - + Added /mcremove command which lets you remove users from MySQL or FlatFile - + Added config values for XP multipliers for different hostile mobs - + Added 'mcmmo.commands.inspect' permission node for the new /inspect command - + Added Impact & Greater Impact subskills to Axes - + Re-added mcMMO reporting damage events - = Fixed bug with updating MySQL tables to include fishing on servers using custom table prefixes - = Fixed bug where Disarm didn't work at all ever - = Fixed bug where Swords command showed Bleed Length twice instead of Bleed Chance - = Fixed bug where Tree Feller wasn't checking for Tree Feller permission - = Fixed bug where Leaf Blower required Tree Feller permissions rather than Woodcutting permissions - = Fixed Leaf Blower preventing the use of shears to collect leaves - = Fixed Green Thumb & Green Terra not consuming or requiring seeds to replant Wheat - = Fixed Super Breaker & Giga Drill Breaker failing to damage tools - = Fixed Tree Feller not giving proper XP for different kinds of trees - = Fixed Skill Abilities conflicting with NoCheat - = Fixed memory leak with mob spawner tracking - = Fixed /mcability not respecting permissions - = Prettied up new config files - = Various skill function optimizations - ! Changed how mcMMO calculates distance between two points (optimizations) - ! Changed how mcMMO handles MySQL connections (optimizations) - ! Changed the description /mcmmo provides to be more up to date and relevant - ! Changed mcMMO user information to be stored for 2 minutes after log out to reduce lag on rejoins - ! Changed Food+ to be named Farmer's Diet in Herbalism - ! Changed default values of Woodcutting XP tables - ! Changed 'Pine' to be renamed 'Oak' in Woodcutting XP tables - ! Changed the name of Unarmed Apprentice/Mastery to Iron Arm Style - ! Changed Axes to gain bonus damage every 50 skill levels - ! Changed Unarmed to start with a +3 DMG (1 Heart = 2 DMG) bonus from Iron Arm Style to make leveling it more viable - ! Changed Unarmed to gain bonus damage every 50 skill levels - ! Changed Unarmed to gain more bonus damage total than before - ! Changed Unarmed to have a max disarm chance of 33.3% rather than 25% - ! Changed Tree Feller to take down entire trees - ! Changed mob spawn tracking to use Unique Entity ID instead of Entity Object - ! Changed stats command name to mcstats for better plugin compatibility - ! Changed god mode to turn off if player enters world where he does not have mcgod permission - ! Changed Taming to also gain XP from animal taming - ! Changed Swords Bleeding effect to never kill - ! Changed Bleeding to never go beyond 10 ticks - ! Changed to use Bukkit's built-in ignoreCancelledEvents system - ! Changed chat logging for /p & /a - ! Changed Tree Feller to use per-use ArrayList - - Removed /mcstats console functionality - - Removed /whois command (replaced with /inspect which has similar functionality) - - Removed Master/Apprentice chat notifications to reduce spam - - Removed MySpawn system (You can still use Chimaera Wings) due to being outdated and unwanted - - Removed duplicate settings in config.yml - - Removed unused settings from config.yml (HP Regen) - - Removed Nether Brick from Mining XP Tables - - Removed Stone Brick from Mining XP Tables - -Version 1.2.12 - - Fixed issue that caused terrible MySQL performance and negative XP on levelup (Issue #134) - - Fixed addxp command taking xprate and skill modifiers into account - - Added anonymous usage statistics (you can opt out in plugins/PluginMetrics/config.yml) - - Modified onEntityDamage priority to have better compatibility with other plugins (Factions, WorldGuard, etc...) - - Fixed /mcgod & /mmoedit permissions defaulting to true - - Fixed Fishing not working or handing out XP - - Fixed error with Skull Splitter / Serrated Strikes that caused server instability and log spam - - Fixed config.yml not having values for End Stone & other new mining blocks - - Fixed Green Thumb/Green Terra not correctly planting wheat (Issue #133) - -Version 1.2.11 - - Removed legacy Permission & PEX dependency. (PEX still works fine with mcMMO) - - Made Smooth Brick to Mossy Brick and Dirt to Grass for green thumb configurable (Issue #120) - - Added MagmaCube to XP tables - - Made optimizations to Skull Splitter/Serrated Strikes - - Made it so players take damage if they try to log out with Serrated Strikes stacked onto them (Issue #131) - - Changed mcMMO to save data periodically to optimize performance with FlatFile & MySQL (Issue #138) - - Added a configurable save interval for the new save system - - Fixed a bug with the odds calculations for Serrated Strikes - - Fixed several commands not working from console (mmoedit, etc..) (Issue #150) - - Added a success message when executing xprate from console - -Version 1.2.10 - - Fixed issue with receiving Woodcutting XP for all blocks broken (Issue #103) - - Fixed issue with Spout images & sounds not working (Issue #93) - - Fixed typo with repairing Leather Armor & Bows - - Fixed issue with Silk Touch & Double/Triple drops not working properly - - Fixed conflict with NoCheat plugin & Super Breaker/Giga Drill Breaker/Berserk/Leaf Blower (Issue #104) - - Fixed counter-attacking non-LivingEntity (Issue #100 & Issue #107) - - Fixed various bugs with Leaf Blower - - Added Monitor & ignoreCancelledEvents to onBlockPlace - - Made Anvil ID configurable - -Version 1.2.09 - - Fixed issue with Repair Mastery (Issue #47) - - Made Arcane Forging fully configurable (Pull Request #52) - - Made Fishing configurable (Pull Request #60) - - Changed timer to be a bit more efficient (Issue #19) - - Changed to fire EntityDamageEvents for all damage done by mcMMO - - New custom event for developers McMMOPlayerLevelUpEvent - - New custom event for developers McMMOItemSpawnEvent - - Changed LoadProperties from the old Configuration to FileConfiguration - - Removed aliasing from config.yml - - Fixed mining procs from Super Break & Silk Touch - - Unused smelt property removed - - Minor optimizations - - Fix for setting properly block damage values - - Initial skill level capping added - - Initial command alias framework added - - Fixed abilities not handling Unbreaking items - - Fix for treefeller glitch - - Super secret anniversary easter egg! - -Version 1.2.08 - - Changed Bukkit events to new event system - - Changed aliasing to send both the mcmmo command and the command used. - - Changes in combat exp (Pull Request #49) - - Repair for bows & leather armor (Pull Request #46) - - Fixed missing images (Pull Request #45) - - POM Changes for dependencies (Pull Request #36) - - Fishing & Repair fixes (Pull Request #31) - - Fixed CraftOfflinePlayer issue (Issue #212) errors for offline wolf owners - - Pull in commit from @NuclearW for issue from previous commit - -Version 1.2.07 -Fixed mctop not working at all (whoops!) -Fixed problem with multithreading in mcMMO causing errors -Fixed bug with Repair where it would remove the enchantments if you could not even repair the item -The command mmoupdate now runs in its own thread to ease the burden on the server - -Version 1.2.06 -German translation has been updated -Fixed fishing not being applied to MySQL DB when converting from Flat File -> MySQL -Fixed mctop not taking Fishing into account some of the time -Fixed bug where Taming would try to grab the name of offline players -Fixed bug where Fishing would try to add an enchantment level not normally possible -Fixed another bug with mmoedit and Fishing -Added option to only allow tools to ready when you are sneaking, this is off by default -Added Brewing Stand & Enchanters table to the list of blocks that won't cause you to ready your tool on right click - -Version 1.2.05 -Fixed my fix of not being able to place blocks near/on Anvils -Fixed resources in inventory not correctly updating after Repair - -Version 1.2.04 -Fixed bug where you could not place blocks near/on the Anvil - -Version 1.2.03 -skills2 and experience2 will be removed from MySQL DB automagically when this version first runs -Fishing is now stored in skills and experience tables on the MySQL DB as it should have been -Fishing will now save properly for MySQL -Fishing will now work properly with mctop for those using MySQL -Fixed problems with mmoedit and fishing - -Version 1.2.02 -Added measures to prevent easy xp from hacks that cause a ridiculous amount of clicks per second -Fixed bug where Call Of The Wild used only 1 bone to summon -Reduced Endermen XP from 3x to 2x -The number of bonus fish caught from fishing has been reduced -Fishing XP reduced from 1500 to 800 -Fishing XP is now configurable in the config file - -Version 1.2.01 -Added a setting to turn off abilities completely from config -Added a setting to just turn off ability messages from config -Fixed the bug with sword repair -Fixed mcMMO not working properly with Spout -Added Fishing XP icon to Normal/Retro HUDs for Spout -Added icons to Spout notifications for leveling Fishing -Added Fishing Retro XP bar color customization to config file -The number of bones required to use Call of The Wild is now configurable -Reduced the XP animals would give from 1.5x to 1x -Removed current durability value message from Repairing -Fixed bug where Arcane Forging failed to display messages -Fixed bug where Arcane Forging tries to downgrade level 1 enchants -Fixed bug where Arcane Forging always kept enchantments if you had under 100 Repair skill - -Version 1.2.00 -Added Fishing Skill -Added Call Of The Wild to Taming -Added Arcane Forging to Repair -Added new mobs to XP tables -Added Master/Apprentice system to the Party system -Animals now give xp to combat skills (those poor sheep ;_;) -Removed unnecessary sorcery permissions from plugin.yml - -Version 1.1.17 -XP gained in combat is now softcapped by the remaining health of the entity you are damaging, preventing many exploits. -Players in Creative mode no longer gain XP -Compiled against latest Spout & CraftBukkit -Added World PVP check to Ignition, should no longer ignore PVP settings -Enemies should no longer grant XP when hit during their death -Fixed an exploit that led to unlimited ability use -Possibly fixed a bug where the same player would be listed multiple times in mctop -Added author and description to plugin.yml - -/mmoedit and /addxp are useable from the console now -Swearword's statistics tracking removed (He stopped the service, so its gone now.. On a positive note, I did find out 1000-1500 servers installed mcMMO a day) - -Version 1.1.16 -Added Melons to Herbalism xp tables -Endermen added to Combat skill xp tables -Silverfish added to Combat skill xp tables -CaveSpider added to Combat skill xp tables - -Version 1.1.15 -Smooth Brick added to Green Terra -Green thumb can be used to spread moss to Smooth Brick now -Implemented a ghetto fix for the sword durability bug (real fix sometime soon) -Added Spain Spanish localization (es_es) - -Version 1.1.14 -[1.8] Removed the Archery fire rate limiter as its no longer necesarry due to changes in game mechanics -[1.8] Removed the bonus damage from Archery (I'll rework this skill soon) -[1.8] Removed the food bonuses to healing Herbalism provided due to the change of eating in game mechanics -[1.8] Swords no longer parry, no need to compete with in game mechanics -[1.8] mcMMO no longer has an HP Regen system, no need to compete with in game mechanics -[SPOUT] mcMMO now transfers files between [MC Server] -> [Client] rather than [Webserver] -> [Client] -[SPOUT] Temporarily disabled the PartyHUD due to some performance issues -[SPOUT/CONFIG] mcMMO now allows for disabling of the party HUD with the node Spout.Party.HUD.Enabled -[BUG] Fixed a few problems with readying abilities for Woodcutting/Axes -[MYSQL] Improvements have been made to the performance of MySQL thanks to krinsdeath -[CONFIG] Spout.Party.HP tree removed, replaced with Spout.Party.HUD -[CONFIG] Added an option for Excavation to require use of a shovel, on by default -[COMPATIBILITY] Changed the listener priority for OnEntityDamage from High to Monitor (Should make mcMMO compatible with Worldguards pvp regions among other things) -[COMPATIBILITY] Made party/admin chat modes more compatible with chat plugins (vChat) -[API] Added addXpOverride for modders, this will ignore skill modifiers -[SPOUT] The option to change the weburl of mcMMO Images/Sounds has been removed, if you want to customize mcMMO images/sounds you can open mcMMO.jar and replace them there -[LOCALE] Portuguese Brazil locale added (Code: pt_br) -[MISC] Added some experimental usage tracking, you can opt out of this in /plugins/stats/config.yml (Once its generated, may require 2 restarts) - -Version 1.1.13 -Pets are removed from party bars - -Version 1.1.12 -mcMMO now downloads files when you join the server to provide the best experience -mcMMO now uses a brand new Party HUD by Rycochet (from his mmoParty plugin) -Fixed the xpbar and xpicon settings in config to work properly -Fixed infinite HP exploit with Herbalism -Fixed bug where herbalism would heal out of the players normal health range -Fixed bug where entering ':' into your party name caused stat loss among other things -Fixed issue with block break listener priority - -Version 1.1.11 -mcMMO now properly cancels its Async taks when disabled -Fixed newly generated configs using 2 instead of 1 for skill multipliers - -Version 1.1.10 -Added default hud setting to config -Fixed bug where newly generated configs used old xp gain numbers - -Version 1.1.09 -Fixed mcMMO to run fine without Spout :) - -Version 1.1.08 -Fixed repair being 10x slower to level than normal - -Version 1.1.07 -Fixed the default HUD being set to RETRO instead of STANDARD - -Version 1.1.06 -mcMMO menu implemented! Default is 'M', change this in config -Retro HUD implemented! -Retro XP fill color is completely customizable on a per skill basis -New levelup sound thanks to @Rustydaggers ! -With the help of Randomage the XP Formulas have been vastly changed for flexibility -Global modifiers and skill modifiers now support decimals -Global formula modifier dropped from config -GigaDrillBreaker/Berserk doesn't drop clay blocks anymore -Fixed bug where Herbalism didn't heal more for bread/stew when right clicking a block -Fixed bug where Wheat did not use the values form the config file -Fixed bug where Archery gave xp for inflicting self injury -Watch added to clay loot tables and maps remove from clay loot tables - -Version 1.1.05 -Maps dropped from excavation are created correctly, and represent the area they are found in -Fixed an exploit with clay and excavation -Fixed a NPE with locking xp bars -Fixed the !AdeptDiamond! localization error when repairing diamond with a skill below 50 - -Version 1.1.04 -Removed URL settings for XPBAR/XPICON/HPBAR -Added single URL setting for mcMMO -Changed default host from Dropbox to Rycochet's webserver (with apparently unlimited bandwidth!, thanks Rycochet) -Fixed Repair noise not getting played -Fixed a small memory leak with party health bars - -Version 1.1.03 -Fixed a few images being hard-coded still rather than configurable - -Version 1.1.02 -Fixed bug where toggle for xpicon didn't work -Fixed bug where Excavation gave gravel drops to grass -Excavation now uses more enums - -Version 1.1.01 -Fixed toggles for hpbar/xpbar not working - -Version 1.1.0 -Brand new XP Bars, Health bars, and Skill Icons designed by BrandonXP -Added /xplock to lock the xp bar to a skill -Repairing metal now has a sound effect -Shears added to Repair -MySpawn now works correctly when you are in the nether -MySpawn message when you right click a bed is now squelched -Intervals at which players renegerate hp have doubled in length (making it take 100% longer to regenerate than before) -Rewrote many variables stored per player to be integer instead of long, reducing overall memory usage of mcMMO -Rewrote the Timer mcMMO relies on to instead use the BukkitScheduler for performance -Fixed the party member list of /party -Fixed bug where Swords would counter-attack Projectiles -Removed a debug message when repairing diamond armor -Changed chat to use getDisplayName() instead of getName() -Changed chat priority from lowest to highest -Added Clay to excavation -Added new items to Clay's loot tables -Archery now works with the latest CB - -Version 1.0.50 -New /xprate command for those with mcmmo.admin permissions! -mcMMO now uses Spout instead of BukkitContrib -BukkitContrib support dropped -XP Formula is now 100+(skill level value * skill modifier * global modifier) thanks to suggestion -Fixed bug where /mmoupdate used the old directory instead of the new one to find the flat file -Fixed bug where Unarmed Mastery damage bonus only did as much as Unarmed Apprentice -Fixed bug where Pumpkins did not give out XP -Coordinates removed from /whois as they didn't really fit -/mcgod and /mmoedit now require permissions to be setup in some shape or form to be used -Lapus renamed to Lapis in config - -Version 1.0.49 -Updated German locale -Fixed bug where using the party system on a MySQL setup caused errors when writing to non-existent files -Fixed bug where using /accept caused a NPE (hopefully) -Fixed a few missing descriptions for commands - -Version 1.0.48 -Updated French Translation -Updated German Translation -Updated Polish Translation -Placed Coal Ore and Redstone Ore won't give XP anymore -Fixed unusually high memory usage at startup -Added many features to the party system written by NuclearW - -Version 1.0.47 -Fixed another BukkitContrib error for servers not running BukkitContrib - -Version 1.0.46 -Fixed bug preventing Excavation from gaining skill - -Version 1.0.45 -Corrected /stats showing Repair XP as Level for Repair -Corrected /repair showing Repair XP as Level for Repair -Corrected /whois showing Repair XP as Level for Repair - -Version 1.0.44 -Fixed my 'fix' of BukkitContrib errors with Tree Feller - -Version 1.0.43 -Stopped things from being auto-smelt'd - -Version 1.0.42 -Corrected 2 more errors involving not running BukkitContrib - -Version 1.0.41 -Fixed errors using Tree Feller if your server wasn't running BukkitContrib (sorry!) -Fixed some more leftover stuff involving the new half-finished mining skill -Fixed excavation's Giga Drill Breaker not working on placed blocks - -Version 1.0.40 -Fixed errors if your server wasn't running BukkitContrib - -Version 1.0.39 -mcMMO won't auto-download and auto-run BukkitContrib anymore - -Version 1.0.38 -Commented code for the half-finished Infernal Pick subskill (Whoops) - -Version 1.0.37 -The donation message in /mcmmo is now toggle-able -The anvil message now only gets shown the first time you place an anvil (after login) -Reworked /mcmmo (an improvement I would say) -Added /mcmmo text to localization file -Archery fire rate now configurable -Berserk mode stops items from being collected -Taming no longer receives xp from wolves being harmed -Fixed bug where /stats required Tree Feller permission to show Woodcutting skill -Fixed bug where players with mcgod could be harmed by AoE -Fixed bug where modifying a skill also modified the xp to the same amount (when it should be zero) - -BukkitContrib Stuff -Added a pop-up when placing an Anvil -Added pop-ups on levelup -Added basic sound effects to various abilities (Berserk, Tree Feller, Super Breaker, Leaf Blower, etc...) - -Code Stuff -Added checkXp(SkillType, Player) for plugin devs (use this after modifying XP to check for levels) -Added getPlayerProfile() which returns a PlayerProfile object for plugin devs (You can do almost everything with this object) -100% more enums -Changed how checking skill xp worked to be more efficient - -Version 1.0.36 -mcMMO now properly supports Bukkit/PEX/Permissions for Permissions -Config.yml will no longer generate Performance Debugging nodes -Registered permission nodes to plugin.yml -Some more changes to Permissions code -Fixed bug where Super Breaker activated where it shouldn't -Fixed bug with enabling/disabling mcgod in config.yml -Fixed bug with Excavation not kicking in until 1 level higher - -Version 1.0.35 -Added a Toggle for Chimaera Wing in config.yml -Added customization of what item is used for Chimaera Wing in config.yml -Fixed bug with randomly receiving Taming XP -mcmmo.users file moved into /plugins/mcMMO/FlatFileStuff/ -Leaderboard files now moved into /plugins/mcMMO/FlatFileStuff/Leaderboards -Locale files now have the prefix locale_ instead of messages_ -Locale files are now located inside com/gmail/nossr50/locale/ instead of com/gmail/nossr50/ -Updated the code that handles permissions (this may mean 3.1.6 will finally play well!) -Some more source code organization -Fixed warnings for compiler -Removed dependencies on CraftBukkit -Registered commands to OnCommand -Removed performance debugging -Removed some useless settings from the config file - -Version 1.0.34 -Fixed the PVP setting determining whether or not you would hurt yourself from AoE Abilities -Added Dutch (nl) language support -Super Breaker now gives the correct XP as determined by config.yml -Sand Stone XP is now configurable and no longer shares the 'stone' node -/mining now shows mining values instead of taming values - -Version 1.0.33 -Fixed the toggle for the Excavation drop 'Cocoa Beans' -Fixed bug where Unarmed users could disarm without being bare handed -Cocoa Beans now have an XP modifier in config.yml -You can now toggle whether or not Mobspawners will give XP (in config.yml) -MySQL version now makes requests to the MySQL server less frequently (should help performance) -Fixed bug with Skull Splitter hitting the user - -Version 1.0.32 -Added "General.Performance.Print_Reports" node to config.yml to help identify causes of performance issues -Fixed bug of swords users hurting themselves with serrated strikes - -Version 1.0.31 -Fixed bug of trying to cast Animals to non-animals - -Version 1.0.30 -Mobs that spawn from spawners no longer give XP (for reals this time) - -Version 1.0.29 -Mobs that spawn from spawners no longer give XP (again) -Fixed bug where Serrated Strikes did not Bleed additional targets -Identified and solved a potential memory leak in Bleed Simulation -Renamed the Object Config to Misc and rewrote parts of it -Rewrote Party/Admin/God toggles -Added Polish language support (pl) - -Version 1.0.28 -Actually fixed /stats showing excavation values for swords -Made some improvements to how Bleed Simulation was handled for different entity types -Obsidian now does normal durability damage during Super Breaker - -Version 1.0.27 -Fixed /stats showing excavation values for swords -Hopefully fixed a wide range of NPE errors -Updated German (de) localization - -Version 1.0.26 -Fixed accidentally making power levels go above 9,000 - -Version 1.0.25 -Compatible with the latest CB -Beast Lore now functions correctly -Wolves are no longer invincible to players -Changed the look of Beast Lore -Skill info pages now show your stat in that skill (if you have permission) -/stats and /whois has been alphabetized and divided into three categories (Gathering/Combat/Misc) -Abilities will not trigger on Trap Doors - -Version 1.0.24 -Now compatible with latest RB (928) -Taming now receives XP from your wolves harming foes -Taming is now easier to level -Green Thumb now drops seeds when harvesting Wheat - -Version 1.0.23 -Modified Bleed Simulation to fix performance problems -Rewrote MySpawn to be more efficient when calculating time left -Rewrote Skills to be more efficient when calculating time left - -Version 1.0.22 -Added 'Name' nodes to commands for renaming them - -Version 1.0.21 -Fixed Skull Splitter length in /axes displaying incorrectly -Fire rate limiter now correctly uses the value in the config file -Stone XP now correctly uses the value in the config file -Cobble -> Mossy now correctly uses the value in the config file -Removed setmyspawn from config file as it serves no purpose -All commands now have an 'Enabled' node in the config file that when set to false disables the command completely -Fixed color scheme inconsistency for Mining in /whois results - -Version 1.0.20 -Fixed Array Index Out of Bounds error - -Version 1.0.19 -Removed a failsafe for the Timer that is no longer necessary (should improve performance) -Fixed /myspawn not working by rewriting it :3 -Fixed exploit where players could break a freshly placed mushroom for XP -MySQL User Passwords can now be blank (Although you really should have a password...) -Fixed a few NPE errors - -Version 1.0.18 -Fixed MySQL default TablePrefix -Fixed Wheat not being configurable - -Version 1.0.17 -Brand new YAML Configuration file -Ability to configure XP for all gathering skills in config file -German Language added to mcMMO -French Language added to mcMMO -MySpawn will no longer heal players -/ commands now also check for their localized names for displaying help -Added many more Strings to localization files -Added more safeguards to MySpawn for NPE -Fixed bug where Tree Feller Radius depended on WoodCutting XP rather than Skill Level -Fixed bug where Readying a Hoe returned a missing localization string -Added some safeguards into Bleed Simulation to prevent possible memory leaks -Performance improvements to storing/calling Skill/XP Values -Plugged a potential memory leak with PlayerProfiles not being removed correctly -Disabled the mob spawner camping anti-exploit in favor of performance - -Version 1.0.16 -Fixed bug where localization file failed to load -Changed en_US to lowercase -mcMMO now requires locale files to be in lowercase -Fixed a few strings missing from the localization file - -Version 1.0.15 -Removed leftover code that spammed SQL errors - -Version 1.0.14 -Added many missed strings into localization -Finnish Localization updated for the new strings -Green Thumb should respect Block Protection plugins now -Fixed Number Format Exception when loading a PlayerProfile - -Version 1.0.13 -Fixed bug/NPE where stats would not load and therefore 'reset' for players -Fixed NPE involving /ptp -Added "enableMOTD" setting to properties file - -Version 1.0.12 -Fixed another NPE error -Non-Gathering skills should correctly gain XP if PVP is set to false now -Localization will now support language codes that do not have two parts like "fi" -Fixed bug where Wiki MOTD message would not be loaded from localization file - -Version 1.0.11 -Fixed bug where players could not gain experience in several skills -Removed PVP flag from mcmmo.properties as its not needed anymore -Fixed a few NPE errors -Mushroom XP reduced from 25 to 15 -Fixed an exploit where players who just logged in could be farmed for experience because they were invulnerable - -Version 1.0.10 -Added Localization/String Customization -Mushroom XP reduced from 40 to 25 -Removed "clears inventory" warning in /mcc for /myspawn since this no longer happens - -Version 1.0.09 -Fixed the NPE that occurs when players gain experience (Sorry!) -Fixed bug where /myspawn & /clearmyspawn would work if MySpawn was disabled in the properties file -Changed strings containing "MMO" to read "mcMMO" -Removed a lot of unused or unnecessary variables from the PlayerProfiles in mcMMO, this should lower the memory footprint -Added getXpToLevel() for modders - -Version 1.0.08 -Added removeXP() for modders -Fixed bug where stone swords only repaired by 33% instead of 50% -Fixed bug where stone/wooden hoes wouldn't repair -Big overhaul to how skill values and xp values were handled in the code -Modifying the players skill levels now sets the corresponding skill xp to zero -Using Serrated Strikes/Skull Splitter on mobs should no longer harm nearby players when PVP is disabled -Switching to another weapon after firing your bow should no longer trigger procs for that weapon when the arrow hits -Slimes/Ghasts now give XP for combat skills -Added "EnableHpRegeneration" property setting -Added "EnableMySpawn" property setting - -Version 1.0.07 -Added more repair customization by solarcloud7 -Leaderboards ignore players with the respective stat at 0 -Reconnecting to MySQL will reload player data -Fixed a NPE with MySQL's Leaderboards -Removed "Loop iteration" debug message from mcMMO - -Version 1.0.06 -MySQL will attempt to reconnect if the connection is closed -Breaking the bottom block of Cactus/Reeds will award the correct experience and double drops -Added support for Minecraft Statistics -Fixed NPE with /myspawn command - -Version 1.0.05 -PVP interactions now check for permissions before handing out any experience -Many skill abilities now check for permissions correctly -All interactions with Taming now check for permissions -mcMMO now checks for its pvp flag being true before handling pvp interactions - -Version 1.0.04 -Fixed bug where players would be informed incorrectly when their cooldowns refreshed -Fixed exploit where players could reconnect to reset their cooldowns -Added new "cooldowns" table to MySQL -Berserk now breaks through snow -Lightning no longer gives Taming XP -Shortened /mcc to fit the screen - -Version 1.0.03 -Bleed will no longer trigger on friendly wolves -Axes criticals will no longer trigger on friendly wolves - -Version 1.0.02 -Fixed bug where the Timer would start before everything else was ready -Fixed bug where mcrefresh also required mcability permission node -Fixed bug where Unarmed was not checking for disarm procs -Green Thumb now checks for herbalism permissions -Added "enableGreenThumbCobbleToMossy" to config file, this also changes Green Terra -AoE abilities now harm wolves - -Version 1.0.01 -Removed debug message when wolves are struck -Fixed issue with reloading mcMMO when MySQL was enabled -Fixed a NPE with MySpawn -Fixed a NPE with removing users from PlayerProfile -Unarmed no longer starts with a damage bonus -Unarmed apprentice DMG bonus changed from 3 to 2 - -Version 1.0 -Players can now repair Stone/Wood tools -Fixed duping bug with WG/Block Protection Plugins -Added Leaf Blower to WoodCutting -Different Trees give different WoodCutting XP -Water changing Gravel to Clay removed -Code Organized/Optimized further -MySQL Support -Taming Skill -Leaderboards -Players won't hand out XP if they died within the last 5 seconds - -Version 0.9.29 -Fixes critical bug involving water turning anything into clay - -Version 0.9.28 -Green thumb can now spread grass to dirt using seeds -Adding XP will check for level ups again -Acrobatics won't hand out XP on death anymore -Acrobatics will check plugins for the event being cancelled before handing out XP - -Version 0.9.27 -Fixed Herbalism not properly receiving Triple Drops from Green Terra -Fixed Herbalism not handing out any XP outside of Green Terra -Fixed Herbalism asking for seeds on things that did not require it - -Version 0.9.26 -Fixed Green Terra going off without readiness -Fixed Hoe trying to ready when tilling Grass - -Version 0.9.25 -Fixed issue with anti-exploits and Herbalism -MySpawn works like a hearthstone now, no inv pentality, 1hr cooldown -Added Green Terra Ability to Herbalism -Added Green Thumb ability to Herbalism -Fixed Repair not working for Iron Tools -Fixed bug where Axes Ability checked for Unarmed Ability Permission -Added Cocoa Beans to Excavation XP/Loot Tables, Found in Grass/Dirt -Using Super Breaker on Obsidian significantly damages it compared to other materials -Added Obsidian to Mining XP Table/Super Breaker -Added Pumpkins/Reeds/Cactus to Herbalism XP Tables/Double Drops -Corrected "mcMMMO" to "mcMMO" in MOTD - -Version 0.9.24 -PLAYER_BED_ENTER removed due to its unusual issues -Added info about the Wiki to the motd -/mcrefresh will reset if you were recently hurt (Chimaera Wing/HP Regen) -Fixed Armor Repair not adding XP -Boosted Repair XP of Armor to match Tools -Repairing Armor won't trigger Super Repair twice anymore -Setting your MySpawn now just requires right clicking a bed (still requires the setmyspawn permission node) - -Version 0.9.23 -Players will now announce ability usage within a short distance to nearby players -Chimaera Wing now takes the world into account -Acrobatics won't give XP on death, and will fail if you would've died after the damage reduction -Added yet another check to see if a Player is not in the Users system for NPC mod compatibility - - -Version 0.9.22 -Fixed bug where chimaera wing was unusable after being hurt even after the cooldown - -Version 0.9.21 -/mcrefresh fixed to work properly with the new ability monitoring system -Ability lengths are now based on your skill level directly rather than a tiered system -Chimaera Wings won't trigger on things they shouldn't (Doors, Chests, ETC) -Chimaera Wings will properly tell you how long you have to wait to use it if you've been recently hurt - -Version 0.9.20 -Fixed Tree Feller not checking if their cooldown was refreshed and always activating -/stats and /whois will now show the powerlevel based on permissions -Shovels will no longer say you've lowered your axe -/myspawn will no longer say your inventory has been cleared if the server settings disable this feature - - -Version 0.9.19 -Fixed Anti-Exploit XP stuff not working - -Version 0.9.18 -Added failsafe to prevent abilities from going on forever, abilities will check if they should've expired when being used in case the Timer fails -Archery Spam has been nerf'd, you can only fire once per second now (Toggle-able in config file) -Fixed bug when just having the Admin Chat permission wouldn't allow you to see Admin Chat -Fixed bug where Axes ability could be used without permission -Abilities are monitored with Timestamps rather than a Timer monitored tick rate -When players were last hurt is now monitored with Timestamps rather than a Timer monitored tick rate -Made Anti XP-Exploits more Robust -Repair XP is now based on durability restored -Acrobatics rolling will now reduce damage if you go over the damage threshold -Acrobatics rolling damage threshold lowered to 10 from 20 -Added Graceful Roll to Acrobatics, hold Shift when falling to do a Graceful Roll -mcMMO now checks for the blockBreak and EntityDamage events being canceled before proceeding -Dodge notification shortened -Dodge won't negate damage completely anymore -Added 3 more functions for plugin authors to call, getPartyName(Player player), inParty(Player player), and getParties() - -Version 0.9.17 -Players now set their MySpawn by entering a bed, it requires the setmyspawn permission node -/setmyspawn has been removed -Compatible with CB 670 -Fixed errors related to Repair -Abilities will no longer trigger from Bed interactions -/unarmed will now tell the player when they will receive unarmed master (if they have apprentice) - -Version 0.9.16 -Logs placed by the player won't grant XP/Double Drops anymore -Added more functions plugin authors can call -Acrobatics roll has a damage threshold of 20, going above this means a failed Roll - - -Version 0.9.15 -Acrobatics will now behave properly -AoE Abilities ignore wolves (temp fix) -Added "all" parameter to /mmoedit & /addxp -After giving XP to a player it will now check for level ups in skills - -Version 0.9.14 -mcMMO checks for abilities being active before sending the fake block break event - -Version 0.9.13 -Fixed excavation ignoring the xpGainMultiplier -Now compatible with CB 600+ -Fixed bug where Dodge acted maxed out no matter your skill level - -Version 0.9.12 -mcMMO now fakes a block break event for abilities to maximize plugin compatibility -/herbalism will return the correct values now -New /addxp command - -Version 0.9.11 -PVE Combat Skills experience is now based on damage dealt -The Timer will no longer break from Bleed Simulation -Tree feller no longer "damages" saplings -Bleed+ (Serrated Strikes) lasts 5 ticks down from 12 -Bleed/Bleed+ now do 2 damage instead of 1 -Power Level is now based on permissions -Counter Attack added to swords -Parry is now based directly on Swords skill level -Parry maximum proc chance raised to 30% from 20% -Serrated Strikes now properly applies Bleed+ to targets -Players who parry can no longer be disarmed -Acrobatics now has a Dodge passive skill reducing damage -Repair skill now effects how much durability is restored -Super repair now doubles the repair amount on proc -Unarmed now starts with a bonus to damage to encourage use -Unarmed now has two steps to damage scaling, Appentice, and Mastery -Unarmed disarm now caps at 25% for 1000 skill -Fixed problem where Archery skill procs would ignore other plugins -Ignition changed to 25% chance -Ignition length will be based on archery skill level -/myspawn now has a warning about the inventory loss penalty in /mcc -mcMMO Timer now runs in 1 second intervals rather than 2 - -Version 0.9.10 -Party invites now show who they are from -Mushrooms added to Dirt/Grass excavation loot tables, drops with 500+ skill -mcMMO configuration files property setting names have been changed for readability -Fixed bug where Gold and Iron wouldn't drop anything during Super Breaker -Added /mcability info to /mcc -Potentially fixed NPE error when checking players for being in same party for PVP XP -Removed sand specific diamond drop from sand excavation loot table, Diamonds can still drop globally for sand -Added a global XP gain multiplier, increase it to increase XP gained -Reduced PVE XP for Unarmed, now identical to Axes/Swords -Changed Chat priority in mcMMO to be higher, this should help plugin conflicts -Mushroom XP raised to 40 from 10 -Flower XP raised to 10 from 3 - -Version 0.9.9 -Fixed problem where entities never got removed from the arrow retrieval list of entities - -Version 0.9.8 -EntityLiving shouldn't be cast to entities that are not an instance of EntityLiving -Added a null check in the timer for players being null before proceeding - -Version 0.9.7 -Procs/XP Gain will no longer happen when the Entity is immune to damage (Thanks EdwardHand!) -Axes critical damage versus players reduced to 150% damage from 200% damage -Fixed bug where Daze might not proc -Changed archery Daze to follow smooth transition -Added archery Daze chance info to /archery -Cooldown lengths are now customizable, they are in seconds and multiplied by 2 by mcMMO - -Version 0.9.6 -Timer checks for player being null before adding them to the mcUsers system -Cooldowns will now show how much time is remaining when trying to use their respective abilities -SkullSpliiter will now correctly inform the player when they are too tired to use it -Acrobatics will no longer give XP if the event was cancelled by another plugin -Version 0.9.5 -Super Breaker now gives a chance for Triple Drops based on mining skill -Ability durability loss down from 15 to 2 -Ability durability loss is now toggle-able -Ability durability loss can be adjusted in the configuration file -Mining Picks are no longer lowered after activating Super Breaker - -Version 0.9.4 -Flowers won't drop wheat anymore -Signs won't trigger ability readiness anymore -Version 0.9.3 -Bug stopping abilities from never wearing of may have been fixed -Changed color of "X Ability has worn off" to RED from GRAY -Super Breaker, Giga Drill Breaker, and Tree Feller now damage the tool significantly during use -Netherrack and Glowstone now give Mining XP -Netherrack and Glowstone are now effected by Super Breaker -Abilities will no longer be readied when you right click signs or beds -Chimaera Wings won't activate on blocks you can interact with and signs -Abilities now adjust their effects depending on tool quality -Superbreaker won't break things that tool couldn't normally break -Giga Drill Breaker will only give triple xp and triple drops for diamond tools, with a reduced effect for lesser tools -Skull Splitter now has a limit of opponents nearby it will strike based on your tool quality -Serrated Strikes now has a limit of opponents nearby it will strike based on your tool quality -Modified /mcmmo description to be a little bit more relevant. - -Version 0.9.2 -Changed priority of some of the mcMMO listeners -Now when certain abilities are activated it shouldn't say "You lower your x" - -Version 0.9.1 -Fixed "Unknown console command" errors with CB 556 -Added /mcability command to toggle being able to trigger abilities with right click -Added some more nullchecks for people reporting NPE errors -Compatibility with NPC mods improved (Mainly for archery!) -Other plugins can now call inSameParty() from mcMMO to increase compatibility - -Version 0.9 ---NEW CONTENT-- -Woodcutting now has the "Tree Feller" Ability -Unarmed now has the "Berserk" Ability -Swords now has the "Serrated Strikes" Ability -Mining now has the "Super Breaker" Ability -Axes now has the "Skull Splitter" Ability -Excavation now has the "Giga Drill Breaker" Ability -Added /mcrefresh - tool for refreshing cooldowns -Unarmed now has the "Deflect Arrows" passive skill -Chimaera Wing Item Added - ---CHANGES-- -HP Regen & Bleed are back -Woodcutting will drop the appropriate log on double drop procs -Herbalism now applies double drops to herbs -/ now shows much more information to the player regarding their stats -Axes skill Critical Strikes are now based directly on your skill level -Swords skill Bleed chance is now based directly on your skill level -Unarmed disarm chance is now based directly on your skill level -Acrobatics now gives XP when you roll - ---BUGFIXES-- -Memory Leak Fixed -Axes not doing critical strikes -Gold Armor repair -Capped skills now have the correct proc chance -/mmoedit is no longer case sensitive -More NPE errors fixed -Many bugs I forgot to write down - ---PLUGIN COMPATABILITY FIXES-- -If combat interactions are cancelled by other plugins mcMMO should ignore the event -If block damage interactions are cancelled by other plugins mcMMO should ignore the event - -Version 0.8.22 - Fixed bug where Axes did less damage than normal - Acrobatic rolls now give XP - Acrobatics XP increased for non-rolls -Version 0.8.21 - Fixed bug where axe criticals would dupe items -Version 0.8.20 - 99.99% sure I fixed anvils that suddenly stop working -Version 0.8.19 - Fixed being able to excavate placed blocks - Added toggle option to mining requiring a pickaxe - Added toggle option to woodcutting requiring an axe - PVP interactions now reward XP based on the damage caused (this is effected by skills) - PVP XP gain can be disabled in the configuration file - PVP XP has a modifier, increase the modifier for higher XP rewards from PVP combat -Version 0.8.18 - Fixed sandstone not being watched for exploitation -Version 0.8.17 - mcmmo.users moved to plugins/mcMMO/ - Snowballs and Eggs will no longer trigger Ignition - Loot tables for excavation adjusted - Mining benefits now require the player to be holding a mining pick - Woodcutting benefits now require the player to be holding an axe -Version 0.8.16 - Moved configuration file to /plugins/mcMMO - Arrows now have a chance to Ignite enemiesw - Fixed arrows not being retrievable from corpses - Added info about ignition to /archery -Version 0.8.14 - Mining, Woodcutting, Herbalism, and Acrobatics proc rates now are based on your skill level directly rather than tiers you unlock via skill levels - Archery's ability to retrieve arrows from corpses now is based on your skill level directly rather than tiers you unlock via skill levels - Mining, Woodcutting, Herbalism, Archery, and Acrobatics now show their proc % relative to your skill if you type / - You can now adjust what level is required to repair diamond in the configuration file - Changed mining XP rates to be a tad higher for some things - You can now get XP from sandstone - XP rates increased for gathering glowstone with excavation - XP rates increased a bit for excavation - Skill info is now a bit more detailed for certain skills - Added info about arrow retrieval to /archery -Version 0.8.13 - Enemies no longer look like they have frozen when they die - Item duping fix -Version 0.8.11 - Performance improvements - Memory leak fixed - NPE error with MySpawn really fixed -Version 0.8.9 - Fixed NPE for My Spawn - Fixed NPE for onBlockDamage - Bleed proc now correctly checks for Swords permissions -Version 0.8.8 - Gold can now be repaired - Tweaked Mining XP gains - Reorganized code - Added /mcgod godmode command - Fixed the pvp toggle in the settings file -Version 0.8.7 - Removed packet-sending stuff wasn't working anyways - Fixed another NPE with the TimerTask - Skills now only show up in /stats if you have permissions for them -Version 0.8.6 - Added a null check in bleed simulation to prevent a NPE -Version 0.8.5 - Players are now added to files when they connect (to fix a NPE) - onPlayerCommand stuff moved into onPlayerCommandPreprocess -Version 0.8.4 - Fixed another nullpointer error for TimerTask - Fixed bug making regeneration take twice as long to kick in after combat -Version 0.8.3 - Modified the timer intervals (from 1 second to 2) - All skills now have an individual modifier (Set by default to 2) - There is now a global XP modifier (Set by default to 1) - Herbalism now correctly follows its skill curve - Unarmed no longer gives experience for harming other players - Players can no longer exploit mob spawners for experience -Version 0.8.2 - Fixed Concurrent Modification Exception - Fixed some incorrect skill descriptions - First tier of HP Regeneration is now available from the start - Fixed bleed proc rate for very high skill levels - Changed regeneration permissions to 'mcmmo.regeneration' -Version 0.8 - Archery skill now lets players recover arrows from downed foes - Health regenerates based on power level - Added toggle to myspawn clearing player inventory in settings file - Swords now have a bleed effect - Rewrote Skill descriptions to be more informative/better -Version 0.7.9 - XP Curve now follows a new formula - Acrobatics XP gains changed - Compiled against permissions 2.1 -Version 0.7.8 - Massive tweaks to XP gain for Archery, Swords, Axes, Unarmed -Version 0.7.7 - Minor tweak to how players are added to the flat file - Fixed some nullpointer exceptions when players die -Version 0.7.6 - Fixed being able to repair diamond armor with below 50 skill - Myspawn now supports multiple worlds, clearing myspawn will set it to the first world created by the server -Version 0.7.5 - Removed random checks for herbalism XP - Herbalism is now called properly (This should fix gaining no xp or double drops) -Version 0.7.4 - Work around for a bukkit bug that broke my onBlockDamage event - Added /clearmyspawn -Version 0.7.3 - Fixed to work with build 424 of CB - Lowered the XP of gold due to it not being that rare anymore -Version 0.7.2 - Fixed security flaw where players could access /mmoedit if the server was not running permissions - Reduced XP gain of woodcutting a bit -Version 0.7 - Completely rewrote the XP system - Added an XP skillrate modifier to the settings file - -Version 0.6.2 - Axes now do critical strikes against farm animals - Removed the "Stupidly Long Constructor" - Now compatible with the latest CB builds -Version 0.6.1 - Customizable command names - Axes can now be modified with /mmoedit - Party members are now correctly informed when you leave the party - Fixed incorrect commands in /mcc -Version 0.5.17 - - Changed namespaces to fit bukkits new standard - Adjusted excavation proc rates - Modified excavation loot tables - Added Party Invite System - -Version 0.5.16 - - Fixed unarmed not checking for permissions when hitting players - -Version 0.5.15 - Fixed stone swords not being recognized as swords - Fixed /a not working if you were an op but did not have permissions - -Version 0.5.14 - Added permissions for skills - -Version 0.5.13 - - Removed skillgain from succesful parries - Repair now refreshed the inventory - -Version 0.5.12 - - Fixed being able to hurt party members with the bow and arrow - -Version 0.5.11 - - Added /mmoedit command - Fixed bug preventing player versus player damage - Fixed bug preventing damage from scaling with unarmed & bows - Fixed disarm proc making the opponent dupe his/her items - Added mcmmo.tools.mmoedit permission - Added mcmmo.commands.setmyspawn permission - Added totalskill to /stats - Changed the look of /stats - -Version 0.5.10 - - Fixed trying to set health to an invalid value - -Version 0.5.9 - - Fixed duping inventories on death - -Version 0.5.8 - - Fixed bug where players inventories would dupe during combat - -Version 0.5.7 - - Fixed monsters instant killing players - Misc fixes -Version 0.5.4 - - Changed herbalism skill gain from wheat to be WAAAAY slower - -Version 0.5.3 - - Players will now correctly drop their inventories when killed by a monster - -Version 0.5.2 - - Fixed MAJOR bug preventing swords skill from gaining through combat - -Version 0.5 - - Archery Added - Swords Added - Acrobatics Added - Logging for Party/Admin chat added - Fixed whois to show correct values for Excavation - Made death messages much much more specific - -Version 0.4.4 - - Fixed being able to repair full durability iron tools - Fixed herbalism benefits not behaving properly - Fixed removing 1 diamond from every stack of diamond when repairing diamond - -Version 0.4.2 - - Removed myspawn from the motd - -Version 0.4.1 - - Fixed /mcc showing incorrect command for herbalism - Changed unarmed skillrate to be much slower than before - Modified a few skill descriptions - Added permission for /whois - Players can now use admin chat without being op as long as they have the correct permission (requires Permissions) - -Version 0.4 - - Permissions support - Removed OPs having different names than normal players - Removed /setspawn & /spawn - Slowed down excavation skill rate - Fixed excavation coal drop being too rare - -Version 0.3.4 - - Creepers now give double xp for unarmed - Iron armor can now be repaired! - Fixed bug stopping items from being repaired - -Version 0.3.3 - - Yet another herbalism skill gain tweak - -Version 0.3.2 - - Changed excavation loot tables to be more rewarding - Changed sand to give normal excavation xp instead of double xp - Fixed herbalism skill exploit - Mobs killed with unarmed now drop loot properly - Unarmed xp rate depends on mob (zombies lowest fyi) - Huge player crashing bug fix on disarm! - -Version 0.3.1 - - Fixed excavation not saving properly - Fixed repair using excavation values - -Version 0.3 - - Unarmed skill - Herbalism skill - Excavation skill - Many bugfixes (thanks for reporting them!) - / - Detailed information about skills in game - -Version 0.2.1 - - Misc bugfixes - -Version 0.2 - - Repair ability added - Repair skill added - Iron Armor repair temporarily disabled - Anvils (Iron Block) added - /mcmmo & /mcc added - Misc changes to existing commands - Misc bug fixes - -Version 0.1 - - Releasing my awesome plugin - + - Removed extra durability loss from Leaf Blower + +Version 1.3.13 + + Added task & command to prune old and powerless users from the SQL database. + + Added Craftbukkit 1.4.6 / 1.4.7 compatibility + + Added new /mcrank command for showing a players leader board ranking for all skills in one place + + Added a configurable durability cap for ArmorImpact to advanced.yml + + Added the version number to /mcmmo + + Added bats, giants, witches, withers, and wither skeletons to the mcMMO combat experience list, and makes their experience drops configurable + + Added the ability to track mobs spawned by mob spawners or the Taming ability when the chunks they are in unload and reload + + Added wooden button to the list of items that shouldn't trigger abilities + + Added a new feature to fishing. Players will have +10% chance of finding enchanted items when fishing while it's raining + + Added displaying bonus perks on skill commands + + Added config option to disable gaining Acrobatics XP from dodging lightning + + Added missing skill guides. They're finally here! + + Added more localization + + Added a very secret easter egg + = Fix issue with Sand/Gravel tracking + = Fix possible NPE when using the PartyAPI to add a player to a party that doesn't exist. + = Fix mcremove command for mySQL + = Fix a java.io.FileNotFoundException when using SQL + = Impact now works with mobs wearing armor + = Fixed issue with Tree Feller dropping player-placed blocks + = Fixed issue with missing default cases from several switch/case statements + = Fixed issue with Mining using actual skill level rather than max skill level + = Fixed some issues with static access + = Fixed ItemStack deprecation issues + = Fixed Async deprecation issues + = Fixed a bug with MySQL databases (non-alphanumeric characters preventing MySQL access) + = Fixed a bug where the /skillreset command was broken + = Fixed a bug where skill commands displaying .x% instead of 0.x% + = Fixed a bug Unbreaking enchantments being ignored when using Treefelling and when hit by Armor Impact + = Fixed a bug where only 1 diamond was needed to fully repair a broken item: Repaired the Repair skill! + = Fixed a bug where a infinite loop of errors caused by mySQL database could cause the server to crash + = Fixed a bug where PartyChangeEvent was fired even when a player isn't able to change parties + = Fixed a bug which caused advanced.yml not to work for Swords + = Fixed a bug which caused advanced.yml not to respect every MaxChance node + = Fixed a bug where GreenThumb_StageChange wasn't read from advanced.yml + = Fixed a bug where Repair would remove enchantments but the glow effect remained + = Fixed a bug where dropped items did not retain custom NBT data + = Fixed a bug which caused a potentially infinite recursion in a btree structure + = Fixed a NPE with custom blocks + = Fixed a bug with Blast Mining never dropping debris blocks + = Fixed a bug with Blast Mining incorrectly handling reduced TNT damage + = Fixed a bug with conflicting fishing enchantments + = Fixed a bug where triple drops wouldn't happen + = Fixed a bug which caused fishing to ignore max/min levels in treasures.yml + = Fixed a bug where treefeller affected player-placed blocks + = Fixed bug where Skull Splitter would be applied twice. + ! GJ stopped being a lazy slacker and got stuff done + ! Nossr50 actually committed something + ! Changed code that uses SpoutPlugin to make it compatible with the latest version + ! Reimplemented skill level and power level caps. + ! Moved Arcane Forging and Fishing setting from config.yml to advanced.yml + ! Overall SQL query improvements + ! Reduced number of SQL queries for mcTop command from 11 to 1, speeding it up immensely + ! Changed FFS Leaderboards to hold information in memory rather than doing IO work (optimizations) + ! Improved chunk conversion (less errors) + ! Changed Fishing Treasure Hunter, chance has increased and now actually is level dependent + ! Indexed most used mySQL columns for faster queries + - Removed dead code relating to null profiles + - Removed unused imports + - Removed ChunkletUnloader and dependents, since they are no longer necessary. + +Version 1.3.12 + + Added Craftbukkit 1.4.5 compatibility + + Added the new 1.3.2 items, xp and double drops for Cocoa beans & Emeralds, EnderChest to the list of blocks that shouldn't trigger abilities + + Added new items from Minecraft 1.4 to Herbalism (potatoes & carrots) + + Added new configuration file for advanced users. + + Added new permission nodes to greenthumb for the 1.4 items + + Added new mobs from Minecraft 1.4 checks for every ability + + Added new active ability for Repair: Salvage + + Added options to 'config.yml' configure shake chance + + Added the option to negate experience earned for Herbalism while in a minecart to prevent afk leveling + + Added Green thumb now converts cobble walls to mossy cobble walls + + Added beacons and anvils to list of blocks that don't trigger abilities + + Added a configuration option to disable experience gains when in a minecraft for Acrobatics and Herbalism, to prevent AFK leveling + + Added a new passive ability for Fishing, Fishermans diet. Increases hunger restored from fish + + Added a feature to display all active perks on login + ! Changed Fishing, Shake drops changed from guaranteed to based upon fishing level and perks + ! Changed Woodcutting, the amount of experience earned when using Tree Feller on jungle trees has increased + ! Changed Herbalism double drop rates for melons and netherwart + ! Changed filesystem usage, it's reduced a lot. Should help reduce lag on larger servers + ! Changed database connection handling. Support for aggressive connection timeouts, with exponential backoff for multiple failures + ! Changed Cobblestone walls are now mossy-able with Greenthumb + ! Changed the skull drop rates of the shake ability to 3% + = Fixed a NPE when Citizens perform certain tasks + = Fixed a NPE with Woodcutting, excessive null chunk before earning Woodcutting experience + = Fixed a NPE related to skill cooldowns + = Fixed a NPE when a players profile was null + = Fixed a NPE involving certain explosions + = Fixed a dupe bug when for players who were using a 'nuker' client + = Fixed a dupe bug where pistons were used to dupe ores + = Fixed a dupe bug with Salvage when players were in Creative mode + = Fixed a bug where the player was displayed an incorrect cooldown time + = Fixed a bug where players could earn experience when they were dealing 0 damage + = Fixed a bug where players could get double drops from mossified Cobblestone + = Fixed a bug where Herablism magically converted potatoes to carrots + = Fixed a bug where you couldn't modify the stats of offline players + = Fixed a bug where treefeller didn't work properly on tree's with side-way logs + = Fixed a bug where the Arcane forging downgrade chance should've been 0, but actually wasn't + = Fixed a bug where Fishing would sometimes give items with empty enchantments + = Fixed a bug where the lucky perk for Fishing was actually an unlucky perk + - Removed nothing + +Version 1.3.11 + ! Changed axes to start with 1 durability damage instead of 5, gain 1 durability damage every 50 levels instead of 30, and only have a 25% chance on hit to damage armor (per armor piece) + + Added compatibility with bow-wielding NPCs from Citizens/NPC mods + + Added compatibility for pvp-prevention plugins for Serrated Strikes + = Fixed bug where mcMMO could throw NPE errors if trees cut down were from a custom mod and had an id of 17 + = Fixed dupe bug where mcMMO would ignore other block-protection plugins for various abilities + = Fixed NPE with hardcore mode's vampirism + +Version 1.3.10 + + Added 1.3.1 compatibility + + Added permission node for Iron Grip ability (mcmmo.ability.unarmed.irongrip) + + Added ability for custom blocks to drop a range of items. + + Added Ability API functions + + Added 50% & 150% XP boost perks + + Added "lucky" perk for donors + = Fixed /inspect not working on offline players + = Fixed custom blocks, tools and armors not loading properly + = Fixed duplication bug with sticky pistons + = Fixed "GenericLabel belonging to mcMMO..." message + = Fixed menu exit button not working + = Fixed Repair enchant downgrade not working + = Fixed NPE caused by Spout players after a /reload + = Fixed ConcurrentModificationException on world unload + = Fixed players never being removed from memory (memory leak) + = Fixed admin chat being seen by everyone + = Fixed issue with UTFDataFormatException occurring on occasion when trying to load Chunklets + = Fixed ArrayIndexOutOfBounds error caused when trying to use /xplock after logging in but before gaining XP + = Fixed custom tools not properly respecting the Ability_Enabled flag. + = Fixed "lower tool" messages still being displayed even when ability messages are disabled. + = Fixed custom blocks not dropping the proper item with Super Breaker when Silk Touch is used + = Fixed custom woodcutting blocks throwing errors. + = Fixed possible ClassCastException from catching something other than a mob when using the Shake Mob skill + ! Changed the format by which Chunklets are stored to be much smaller, and much faster to load + ! Optimized how player placed blocks are tracked + +Version 1.3.09 + + Added compatibility with AntiCheat (Which I highly recommend to prevent cheating) + + Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP) + + Added reduced cooldown permission nodes as special perks (1/4, 1/3, 1/2 cooldown) + + Added increased activation time permissions nodes as special perks (+4, +8, and +12 seconds) + + Added API for plugins to add custom tools directly via Spout - repair / abilities do not work ATM + + Added offline party members to the list displayed by /party + + Added possibility to kick offline members from parties + = Fixed bug that would cause a NPE for players that had no parties + = Fixed Vampirism not notifying the correct amount of stolen levels + = Fixed bug with Acrobatics not saving you from deadly falls + = Fixed /mcremove being applied only after a reload + = Fixed Archery PVE disablement not working properly + = Fixed possible NPE when a projectile is shot by a dispenser or doesn't have any shooter + = Fixed issue with NoCheatPlus and Serrated Strikes / Skull Splitter (fight.noswing) + = Fixed tiny memory leak concerning Archery + = Fixed bug where you could receive Archery XP from Potions + = Fixed bug where Chunklets for the < 64 y coordinates would not be properly loaded + = Fixed exploit with block duplication via piston pushing + = Fixed bug with falling sand/gravel not being tracked + = Fixed bug with Tree Feller not working with custom axes + = Fixed bug with locale strings when trying to teleport to a non-existent player + = Fixed bug with Tree Feller changing durability before checking for axe splintering + = Fixed bug with Repair Mastery permission due to typo + = Fixed bug with repairing items that use metadata + = Fixed bug with Chunklets not being reloaded on /reload + = Fixed possible NPE when falling with no item in hand + ! API methods can now only be used in a static way + ! Arrows shot from a bow having the Infinity enchantment can no longer be retrieved + ! Arrows that aren't shot by an entity are now able to be dodged (currently only from dispensers) + ! Changed Spout settings to be in their own config file (spout.yml) + ! Changed file format for parties (parties.yml), previous files are no longer used + ! Changed mcMMO to inform on corrupt Chunklets and make new ones + +Version 1.3.08 + + Added more notifications about Vampirism and Hardcore mode on player death + + Added information about Hardcore mode when joining a server running Hardcore mode + + Added new hidden.yml inside the jar for very sensitive config options for advanced users + + Added option to disable Chunklets for servers which do not have doubledrops and do not care about xp farming + + Added new "Max_Seconds" setting in config.yml to limit the max time of abilities + + Added new repair configs to allow customization of the repair skill + + Added message to inform users about hardcore mode on login + = Fixed exploit where you could gain tons of Acrobatics XP from spamming Ender Pearls + = Fixed normal pistons marking a block as user-placed on retract if it wasn't a sticky piston (thanks turt2live!) + = Fixed handling of the Unbreaking enchantment so that tools are actually damaged as they should now + = Fixed hurting pet cats with serrated strikes + ! Changed Hardcore Vampirism to require the victim to have at least half the skill level of the killer in order for vampirism to proc (this is to avoid exploitation) + ! Changed Hardcore Vampirism to steal a minimum of 1 skill level from a player no matter the percentage + ! Changed Hardcore & Vampirism to not be executed if percentages were set to zero or below + ! Changed Vampirism to actually remove stats from the victim + ! Changed Vampirism to inform the victim of their stat loss + ! Changed Mining to allow Silk Touch to work again since the dupe exploit has been fixed. + ! Changed Metrics to also report if the server uses plugin profiling + - Removed level and item settings from Repair skill in config.yml + +Version 1.3.07 + + Added ability to gain XP from custom blocks. Enable custom blocks in the config file, then enter the data in the blocks.yml file. + + Added ability to gain XP with custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file. + + Added ability to repair custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file. + + Added ability to repair custom armor. Enable custom armor in the config file, then enter the data in the armor.yml file. + + Added functionality which makes a new folder in all world files "mcmmo_data" to store player placed block information in + + Added new configurable Hardcore mode functionality to mcMMO + + Added new configurable Vampirism PVP stat leech for Hardcore mode + + Added new bypass permission node for the negative penalties of Hardcore mode 'mcmmo.bypass.hardcoremode' + + Added configurable level curve multiplier which allows for tweaking the steepness of the XP needed to level formula + + Added a permission node for Archery bonus damage + + Added a permission node for Greater Impact ability + + Added permission nodes for Treasure & Magic Hunter for Fishing + + Added a permission node for Farmer's Diet + + Added config options for enabling/disabling specific double drops + + Added automatic zip backup of flatfile database & config files + + Added config options to enable/disable specific skills for PVP & PVE + = Fixed bug where Tree Feller was looking at the wrong blocks for determining how much to take down. + = Fixed bug where Green Terra consumed seeds even on Mossy Stone Brick + = Fixed bug where the client didn't reflect the Stone Brick to Mossy Stone Brick change + = Fixed bug where an arrow could bounce off entities on daze proc + = Fixed bug where a player could gain Acrobatics experience while riding a cart + = Fixed /party not working properly with 2 arguments + = Fixed /party not showing properly the member list + = Fixed /ability not checking the right permission + = Fixed rare NPE on /party command + = Fixed Arrow Retrieval dropping only one arrow + = Fixed /p and /a incompatibilities with bChatManager + = Fixed Iron Grip working reversely + = Fixed NPE when user clicked the HUD button with Spout + = Fixed bug where the permission node for Impact didn't work + = Fixed some bypass nodes defaulting true for Ops + = Fixed bug with trying to use Chimera Wing while standing on a half-block + = Fixed duplication bug when a placed block was mined after a server restart + = Fixed exploit where shooting yourself with an arrow gave Archery XP + ! Changed the mcMMO motd to link to the new website rather than the wiki + ! Changed bleeding ticks damage to 1 from 2 + ! Changed Mining to ignore blocks when the pick is enchanted with Silk Touch + ! Changed Super Breaker to be non-functional when used with a Silk Touch enchanted pick + ! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server + ! Changed the permission node for Blast Mining detonation to mcmmo.ability.blastmining.detonate (was mcmmo.skills.blastmining) for the sake of consistency + ! Changed skill commands to only display what you have permissions for + ! Changed mcMMO to use a new storage system for player placed blocks + - Removed some unused permission nodes + - Removed a few config options in favor of permissions nodes (Hunger Bonus, Armor/Tool Repair, Instant Wheat Regrowth) + - Removed level requirement for repairing string tools from the config file + +Version 1.3.06 + + Added Iron Golem XP for aggressive golems + + Added permissions check to skill functions + + Added API functions for obtaining offline profiles & profiles via player names + + Added API functions for admin & party chat + + Added Iron Grip skill to Unarmed which gives players an chance to keep from being disarmed. + + Added some new languages to the locale files. + = Fixed Green Thumb consuming 2 seeds instead of 1 + = Fixed exploit where you could teleport to yourself with PTP to prevent things like fall damage + = Fixed NPE error with Metrics on startup + = Fixed bug where Herbalism required double drops permission to give XP + = Fixed bug where {0} would be displayed in front of your power level in mcstats + = Fixed mmoupdate not being useable from console + = Fixed bug with repairing wooden tools + = Fixed bug with Nether Wart not awarding XP + = Fixed bug with fishing treasures when treasures list is empty + = Fixed bug with only getting one level when there was enough XP for multiple levels. + = Fixed bugs with the way /mctop displayed + = Fixed issues with custom characters & locale files. + = Fixed double explosion for Blast Mining + = Fixed Blast Mining not giving triple drops when it should + ! Changed Bleeding to now stack to a finite number on Monsters and will wear off eventually + ! Changed how we handled the config file to prevent any bugs when returning values + ! Changed locale files to use a new naming scheme. This breaks ALL old locale files. If you want to assist with re-translating anything, go to getlocalization.com/mcMMO + ! Changed /mcremove to check for users in the MySQL DB before sending queries to remove them + ! Changed how the tree feller threshold worked for the better + ! Changed /mcremove to no longer kick players when they are removed from database + ! Changed /mcremove to work on offline users for FlatFile + ! Changed PlayerProfile constructor to always take a boolean + ! Changed getPlayerProfile function to work for online & offline users + ! Changed Archery's Daze to deal 4 DMG on proc (2 Hearts) + ! Changed /addlevel command to work for offline users + ! Changed party & admin chat handling to be nicer to developers + ! Changed /mcrefresh to work from console + ! Changed /mcrefresh to work for offline players + ! Changed UpdateXPBar function to hopefully avoid errors + ! Changed /party to show offline party members + ! Changed Blast Mining requirements, now asks for the player to be crouching + +Version 1.3.05 + + Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%) + + Added ExperienceAPI and PartyAPI classes for developer use + + Added ability to cap overall power level + + Added showing powerlevel below a persons name if you run Spout (optional) + = Fixed errors when Spout would disable itself after start-up + = Fixed XP bar not updating when XP was gained + = Fixed bug with repairing wooden tools + = Fixed bug where spawned wolves only had 8 health. + = Fixed bug where rare Treasures from Excavation were dropping too often + = Fixed bug where Skull Splitter & Serrated Strikes could be used without permissions. + = Fixed bug where API functions were set to static + = Fixed bug where mmoedit threw errors when modifying an offline user + = Fixed dupe exploit with Blast Mining + ! Changed Tree Feller to account for ability durability loss but not leaves. + ! Changed bypass node for Arcane Forging to not default to true for OPs + - Removed Ignition from Archery + - Removed McMMOPlayerRepairEvent - was basically a duplicate of McMMOPlayerRepairCheck but couldn't be cancelled. + +Version 1.3.04 + + Added McMMOPlayerRepairEvent for API usage - fires after completion of a repair. + + Added McMMOPlayerRepairCheckEvent for API usage - fires before repair process begins, can be cancelled. + + Added ability to get skill level from McMMOPlayerExperience events + + Added McMMOPartyTeleportEvent for API usage - fires before a successful teleportation would occur. + + Added McMMOPartyChangeEvent for API usage - fires whenever a player joins or leaves a party + = Fixed Shake ability dropping bonemeal instead of ink for squids. + = Fixed Green Terra & Super Breaker awarding 4x drops at high levels. + = Fixed summoned ocelots never changing skins. + = Fixed bug with Disarm not working + = Fixed some API functions not being visible + = Fixed bug where /ptp worked on dead party members + ! Changed MySQL to reload all player information on reconnection + ! Changed event package structure - be sure to update these if you're using the API in your plugin + +Version 1.3.03 + + Added Ocelots to Taming XP tables + + Added ability to summon Ocelots with Call of the Wild + + Added offline user functionality to mmoedit + + Added bookshelves to list of blocks that don't trigger abilities. + + Added 'mcmmo.repair.arcanebypass' permission node to bypass Arcane Repair and keep your enchantments + + Added config option to disable Herbalism's instant wheat replanting + + Added LOTS of new permissions nodes. *CHECK PLUGIN.YML FOR UPDATES* + + Added Italian locale file - thanks Luxius96! + + Added ability to inspect Ocelots with Beast Lore + + Added console functionality to mctop + = Fixed Green Terra not awarding Triple Drops + = Fixed ClassCastException from Taming preventDamage checks + = Fixed issue with Blast Mining not seeing TNT for detonation due to snow + = Fixed issue with block interaction returning NPEs + = Fixed issue where every block broken had a mining check applied + = Fixed issue where every block broken had a herbalism check applied + = Fixed issue where blocks weren't being removed from the watchlist + = Fixed exploit where you could use /ptp to teleport to anyone + = Fixed bug where Green Terra didn't work on Stone Brick + = Fixed bug where Tree Feller could be used without permissions + = Fixed exploit where falling sand & gravel weren't tracked + = Fixed exploit where Acrobatics could be leveled via Dodge on party members. + = Fixed exploit where you could gain combat XP on animals summoned by Call of the Wild + ! Changed mcMMO to save profiles only when the profile is about to be discarded rather than on player quit + ! Changed MySQL to try to reconnect every 60 seconds rather than infinitely which caused server hangs + ! Changed mcMMO to be better about saving player information on server shutdown + ! Changed PTP to prevent teleporting if you've been hurt in the last 30 seconds (configurable) + ! Changed Chimera Wing failure check to use the maxWorldHeight. + ! Changed inspect failed message to say inspect rather than whois + ! Changed Call of the Wild to activate on left-click rather than right-click + ! Changed Blast Mining to track based on Entity ID vs. Location + ! Changed mmoedit to save a profile when used (this will make mctop update) + ! Changed a few Runnable tasks to have their own classes + ! Changed parties so that a player will leave their existing party if they enter a world where they don't have party permissions. + ! Changed Call of the Wild to summon animals already tamed. + ! Changed mob spawner tracking to use new Metadata API + ! Changed block watch list to use new Metadata API + ! Changed around a few config options, including the ones for mySQL. *YOU NEED TO REDO YOUR CONFIG FILE* + - Removed 'true/false' debug message from Inspect command + +Version 1.3.02 + + Added in game guides for Mining, Excavation, and Acrobatics. Simply type /skillname ? to access them + ! Changed Tree Feller to hand out 1/4 of normal XP for each JUNGLE LOG block it fells + ! Changed Tree Feller to only fell trees if you have enough durability + ! Changed Tree Feller to cause injury if your axe splinters from a failed Tree Feller attempt + ! Changed invincibility checks in EntityDamage listeners to accommodate for vanilla MC behaviour + ! Changed Ignition to add fire ticks rather than replacing them. + ! Changed Axes critical to have a max critical rate of 37.5% down from 75% + = Fixed bug where Taming defensive checks got called twice + = Fixed Shake not working correctly + = Fixed bug with Axes command displaying wrong Greater Impact bonus damage + = Fixed bug where Impact didn't apply bonus damage + = Fixed Impact proccing multiple times in a row + = Fixed bug where PVE skills didn't level + +Version 1.3.01 + = Fixed bug where Tree Feller had no cooldown + = Fixed bug with activating Skull Splitter after using Tree Feller + +Version 1.3.00 + + Added ability to customize drops for Excavation skill (treasures.yml) + + Added ability to customize drops for Fishing skill (treasures.yml) + + Added messages to nearby players when your abilities wear off + + Added jungle trees to Woodcutting XP tables + + Added player notification for when they stop Bleeding + + Added configuration option to control mcMMO reporting damage events + + Added hunger regain bonuses to Herbalism skill + + Added Blast Mining subskills to Mining + + Added Fast Food Service subskill to Taming + + Added size limit to Tree Feller in config as Tree Feller Threshold + + Added /inspect (works on offline players) + + Added /addlevels commands + + Added /mcremove command which lets you remove users from MySQL or FlatFile + + Added config values for XP multipliers for different hostile mobs + + Added 'mcmmo.commands.inspect' permission node for the new /inspect command + + Added Impact & Greater Impact subskills to Axes + + Re-added mcMMO reporting damage events + = Fixed bug with updating MySQL tables to include fishing on servers using custom table prefixes + = Fixed bug where Disarm didn't work at all ever + = Fixed bug where Swords command showed Bleed Length twice instead of Bleed Chance + = Fixed bug where Tree Feller wasn't checking for Tree Feller permission + = Fixed bug where Leaf Blower required Tree Feller permissions rather than Woodcutting permissions + = Fixed Leaf Blower preventing the use of shears to collect leaves + = Fixed Green Thumb & Green Terra not consuming or requiring seeds to replant Wheat + = Fixed Super Breaker & Giga Drill Breaker failing to damage tools + = Fixed Tree Feller not giving proper XP for different kinds of trees + = Fixed Skill Abilities conflicting with NoCheat + = Fixed memory leak with mob spawner tracking + = Fixed /mcability not respecting permissions + = Prettied up new config files + = Various skill function optimizations + ! Changed how mcMMO calculates distance between two points (optimizations) + ! Changed how mcMMO handles MySQL connections (optimizations) + ! Changed the description /mcmmo provides to be more up to date and relevant + ! Changed mcMMO user information to be stored for 2 minutes after log out to reduce lag on rejoins + ! Changed Food+ to be named Farmer's Diet in Herbalism + ! Changed default values of Woodcutting XP tables + ! Changed 'Pine' to be renamed 'Oak' in Woodcutting XP tables + ! Changed the name of Unarmed Apprentice/Mastery to Iron Arm Style + ! Changed Axes to gain bonus damage every 50 skill levels + ! Changed Unarmed to start with a +3 DMG (1 Heart = 2 DMG) bonus from Iron Arm Style to make leveling it more viable + ! Changed Unarmed to gain bonus damage every 50 skill levels + ! Changed Unarmed to gain more bonus damage total than before + ! Changed Unarmed to have a max disarm chance of 33.3% rather than 25% + ! Changed Tree Feller to take down entire trees + ! Changed mob spawn tracking to use Unique Entity ID instead of Entity Object + ! Changed stats command name to mcstats for better plugin compatibility + ! Changed god mode to turn off if player enters world where he does not have mcgod permission + ! Changed Taming to also gain XP from animal taming + ! Changed Swords Bleeding effect to never kill + ! Changed Bleeding to never go beyond 10 ticks + ! Changed to use Bukkit's built-in ignoreCancelledEvents system + ! Changed chat logging for /p & /a + ! Changed Tree Feller to use per-use ArrayList + - Removed /mcstats console functionality + - Removed /whois command (replaced with /inspect which has similar functionality) + - Removed Master/Apprentice chat notifications to reduce spam + - Removed MySpawn system (You can still use Chimaera Wings) due to being outdated and unwanted + - Removed duplicate settings in config.yml + - Removed unused settings from config.yml (HP Regen) + - Removed Nether Brick from Mining XP Tables + - Removed Stone Brick from Mining XP Tables + +Version 1.2.12 + - Fixed issue that caused terrible MySQL performance and negative XP on levelup (Issue #134) + - Fixed addxp command taking xprate and skill modifiers into account + - Added anonymous usage statistics (you can opt out in plugins/PluginMetrics/config.yml) + - Modified onEntityDamage priority to have better compatibility with other plugins (Factions, WorldGuard, etc...) + - Fixed /mcgod & /mmoedit permissions defaulting to true + - Fixed Fishing not working or handing out XP + - Fixed error with Skull Splitter / Serrated Strikes that caused server instability and log spam + - Fixed config.yml not having values for End Stone & other new mining blocks + - Fixed Green Thumb/Green Terra not correctly planting wheat (Issue #133) + +Version 1.2.11 + - Removed legacy Permission & PEX dependency. (PEX still works fine with mcMMO) + - Made Smooth Brick to Mossy Brick and Dirt to Grass for green thumb configurable (Issue #120) + - Added MagmaCube to XP tables + - Made optimizations to Skull Splitter/Serrated Strikes + - Made it so players take damage if they try to log out with Serrated Strikes stacked onto them (Issue #131) + - Changed mcMMO to save data periodically to optimize performance with FlatFile & MySQL (Issue #138) + - Added a configurable save interval for the new save system + - Fixed a bug with the odds calculations for Serrated Strikes + - Fixed several commands not working from console (mmoedit, etc..) (Issue #150) + - Added a success message when executing xprate from console + +Version 1.2.10 + - Fixed issue with receiving Woodcutting XP for all blocks broken (Issue #103) + - Fixed issue with Spout images & sounds not working (Issue #93) + - Fixed typo with repairing Leather Armor & Bows + - Fixed issue with Silk Touch & Double/Triple drops not working properly + - Fixed conflict with NoCheat plugin & Super Breaker/Giga Drill Breaker/Berserk/Leaf Blower (Issue #104) + - Fixed counter-attacking non-LivingEntity (Issue #100 & Issue #107) + - Fixed various bugs with Leaf Blower + - Added Monitor & ignoreCancelledEvents to onBlockPlace + - Made Anvil ID configurable + +Version 1.2.09 + - Fixed issue with Repair Mastery (Issue #47) + - Made Arcane Forging fully configurable (Pull Request #52) + - Made Fishing configurable (Pull Request #60) + - Changed timer to be a bit more efficient (Issue #19) + - Changed to fire EntityDamageEvents for all damage done by mcMMO + - New custom event for developers McMMOPlayerLevelUpEvent + - New custom event for developers McMMOItemSpawnEvent + - Changed LoadProperties from the old Configuration to FileConfiguration + - Removed aliasing from config.yml + - Fixed mining procs from Super Break & Silk Touch + - Unused smelt property removed + - Minor optimizations + - Fix for setting properly block damage values + - Initial skill level capping added + - Initial command alias framework added + - Fixed abilities not handling Unbreaking items + - Fix for treefeller glitch + - Super secret anniversary easter egg! + +Version 1.2.08 + - Changed Bukkit events to new event system + - Changed aliasing to send both the mcmmo command and the command used. + - Changes in combat exp (Pull Request #49) + - Repair for bows & leather armor (Pull Request #46) + - Fixed missing images (Pull Request #45) + - POM Changes for dependencies (Pull Request #36) + - Fishing & Repair fixes (Pull Request #31) + - Fixed CraftOfflinePlayer issue (Issue #212) errors for offline wolf owners + - Pull in commit from @NuclearW for issue from previous commit + +Version 1.2.07 +Fixed mctop not working at all (whoops!) +Fixed problem with multithreading in mcMMO causing errors +Fixed bug with Repair where it would remove the enchantments if you could not even repair the item +The command mmoupdate now runs in its own thread to ease the burden on the server + +Version 1.2.06 +German translation has been updated +Fixed fishing not being applied to MySQL DB when converting from Flat File -> MySQL +Fixed mctop not taking Fishing into account some of the time +Fixed bug where Taming would try to grab the name of offline players +Fixed bug where Fishing would try to add an enchantment level not normally possible +Fixed another bug with mmoedit and Fishing +Added option to only allow tools to ready when you are sneaking, this is off by default +Added Brewing Stand & Enchanters table to the list of blocks that won't cause you to ready your tool on right click + +Version 1.2.05 +Fixed my fix of not being able to place blocks near/on Anvils +Fixed resources in inventory not correctly updating after Repair + +Version 1.2.04 +Fixed bug where you could not place blocks near/on the Anvil + +Version 1.2.03 +skills2 and experience2 will be removed from MySQL DB automagically when this version first runs +Fishing is now stored in skills and experience tables on the MySQL DB as it should have been +Fishing will now save properly for MySQL +Fishing will now work properly with mctop for those using MySQL +Fixed problems with mmoedit and fishing + +Version 1.2.02 +Added measures to prevent easy xp from hacks that cause a ridiculous amount of clicks per second +Fixed bug where Call Of The Wild used only 1 bone to summon +Reduced Endermen XP from 3x to 2x +The number of bonus fish caught from fishing has been reduced +Fishing XP reduced from 1500 to 800 +Fishing XP is now configurable in the config file + +Version 1.2.01 +Added a setting to turn off abilities completely from config +Added a setting to just turn off ability messages from config +Fixed the bug with sword repair +Fixed mcMMO not working properly with Spout +Added Fishing XP icon to Normal/Retro HUDs for Spout +Added icons to Spout notifications for leveling Fishing +Added Fishing Retro XP bar color customization to config file +The number of bones required to use Call of The Wild is now configurable +Reduced the XP animals would give from 1.5x to 1x +Removed current durability value message from Repairing +Fixed bug where Arcane Forging failed to display messages +Fixed bug where Arcane Forging tries to downgrade level 1 enchants +Fixed bug where Arcane Forging always kept enchantments if you had under 100 Repair skill + +Version 1.2.00 +Added Fishing Skill +Added Call Of The Wild to Taming +Added Arcane Forging to Repair +Added new mobs to XP tables +Added Master/Apprentice system to the Party system +Animals now give xp to combat skills (those poor sheep ;_;) +Removed unnecessary sorcery permissions from plugin.yml + +Version 1.1.17 +XP gained in combat is now softcapped by the remaining health of the entity you are damaging, preventing many exploits. +Players in Creative mode no longer gain XP +Compiled against latest Spout & CraftBukkit +Added World PVP check to Ignition, should no longer ignore PVP settings +Enemies should no longer grant XP when hit during their death +Fixed an exploit that led to unlimited ability use +Possibly fixed a bug where the same player would be listed multiple times in mctop +Added author and description to plugin.yml + +/mmoedit and /addxp are useable from the console now +Swearword's statistics tracking removed (He stopped the service, so its gone now.. On a positive note, I did find out 1000-1500 servers installed mcMMO a day) + +Version 1.1.16 +Added Melons to Herbalism xp tables +Endermen added to Combat skill xp tables +Silverfish added to Combat skill xp tables +CaveSpider added to Combat skill xp tables + +Version 1.1.15 +Smooth Brick added to Green Terra +Green thumb can be used to spread moss to Smooth Brick now +Implemented a ghetto fix for the sword durability bug (real fix sometime soon) +Added Spain Spanish localization (es_es) + +Version 1.1.14 +[1.8] Removed the Archery fire rate limiter as its no longer necesarry due to changes in game mechanics +[1.8] Removed the bonus damage from Archery (I'll rework this skill soon) +[1.8] Removed the food bonuses to healing Herbalism provided due to the change of eating in game mechanics +[1.8] Swords no longer parry, no need to compete with in game mechanics +[1.8] mcMMO no longer has an HP Regen system, no need to compete with in game mechanics +[SPOUT] mcMMO now transfers files between [MC Server] -> [Client] rather than [Webserver] -> [Client] +[SPOUT] Temporarily disabled the PartyHUD due to some performance issues +[SPOUT/CONFIG] mcMMO now allows for disabling of the party HUD with the node Spout.Party.HUD.Enabled +[BUG] Fixed a few problems with readying abilities for Woodcutting/Axes +[MYSQL] Improvements have been made to the performance of MySQL thanks to krinsdeath +[CONFIG] Spout.Party.HP tree removed, replaced with Spout.Party.HUD +[CONFIG] Added an option for Excavation to require use of a shovel, on by default +[COMPATIBILITY] Changed the listener priority for OnEntityDamage from High to Monitor (Should make mcMMO compatible with Worldguards pvp regions among other things) +[COMPATIBILITY] Made party/admin chat modes more compatible with chat plugins (vChat) +[API] Added addXpOverride for modders, this will ignore skill modifiers +[SPOUT] The option to change the weburl of mcMMO Images/Sounds has been removed, if you want to customize mcMMO images/sounds you can open mcMMO.jar and replace them there +[LOCALE] Portuguese Brazil locale added (Code: pt_br) +[MISC] Added some experimental usage tracking, you can opt out of this in /plugins/stats/config.yml (Once its generated, may require 2 restarts) + +Version 1.1.13 +Pets are removed from party bars + +Version 1.1.12 +mcMMO now downloads files when you join the server to provide the best experience +mcMMO now uses a brand new Party HUD by Rycochet (from his mmoParty plugin) +Fixed the xpbar and xpicon settings in config to work properly +Fixed infinite HP exploit with Herbalism +Fixed bug where herbalism would heal out of the players normal health range +Fixed bug where entering ':' into your party name caused stat loss among other things +Fixed issue with block break listener priority + +Version 1.1.11 +mcMMO now properly cancels its Async taks when disabled +Fixed newly generated configs using 2 instead of 1 for skill multipliers + +Version 1.1.10 +Added default hud setting to config +Fixed bug where newly generated configs used old xp gain numbers + +Version 1.1.09 +Fixed mcMMO to run fine without Spout :) + +Version 1.1.08 +Fixed repair being 10x slower to level than normal + +Version 1.1.07 +Fixed the default HUD being set to RETRO instead of STANDARD + +Version 1.1.06 +mcMMO menu implemented! Default is 'M', change this in config +Retro HUD implemented! +Retro XP fill color is completely customizable on a per skill basis +New levelup sound thanks to @Rustydaggers ! +With the help of Randomage the XP Formulas have been vastly changed for flexibility +Global modifiers and skill modifiers now support decimals +Global formula modifier dropped from config +GigaDrillBreaker/Berserk doesn't drop clay blocks anymore +Fixed bug where Herbalism didn't heal more for bread/stew when right clicking a block +Fixed bug where Wheat did not use the values form the config file +Fixed bug where Archery gave xp for inflicting self injury +Watch added to clay loot tables and maps remove from clay loot tables + +Version 1.1.05 +Maps dropped from excavation are created correctly, and represent the area they are found in +Fixed an exploit with clay and excavation +Fixed a NPE with locking xp bars +Fixed the !AdeptDiamond! localization error when repairing diamond with a skill below 50 + +Version 1.1.04 +Removed URL settings for XPBAR/XPICON/HPBAR +Added single URL setting for mcMMO +Changed default host from Dropbox to Rycochet's webserver (with apparently unlimited bandwidth!, thanks Rycochet) +Fixed Repair noise not getting played +Fixed a small memory leak with party health bars + +Version 1.1.03 +Fixed a few images being hard-coded still rather than configurable + +Version 1.1.02 +Fixed bug where toggle for xpicon didn't work +Fixed bug where Excavation gave gravel drops to grass +Excavation now uses more enums + +Version 1.1.01 +Fixed toggles for hpbar/xpbar not working + +Version 1.1.0 +Brand new XP Bars, Health bars, and Skill Icons designed by BrandonXP +Added /xplock to lock the xp bar to a skill +Repairing metal now has a sound effect +Shears added to Repair +MySpawn now works correctly when you are in the nether +MySpawn message when you right click a bed is now squelched +Intervals at which players renegerate hp have doubled in length (making it take 100% longer to regenerate than before) +Rewrote many variables stored per player to be integer instead of long, reducing overall memory usage of mcMMO +Rewrote the Timer mcMMO relies on to instead use the BukkitScheduler for performance +Fixed the party member list of /party +Fixed bug where Swords would counter-attack Projectiles +Removed a debug message when repairing diamond armor +Changed chat to use getDisplayName() instead of getName() +Changed chat priority from lowest to highest +Added Clay to excavation +Added new items to Clay's loot tables +Archery now works with the latest CB + +Version 1.0.50 +New /xprate command for those with mcmmo.admin permissions! +mcMMO now uses Spout instead of BukkitContrib +BukkitContrib support dropped +XP Formula is now 100+(skill level value * skill modifier * global modifier) thanks to suggestion +Fixed bug where /mmoupdate used the old directory instead of the new one to find the flat file +Fixed bug where Unarmed Mastery damage bonus only did as much as Unarmed Apprentice +Fixed bug where Pumpkins did not give out XP +Coordinates removed from /whois as they didn't really fit +/mcgod and /mmoedit now require permissions to be setup in some shape or form to be used +Lapus renamed to Lapis in config + +Version 1.0.49 +Updated German locale +Fixed bug where using the party system on a MySQL setup caused errors when writing to non-existent files +Fixed bug where using /accept caused a NPE (hopefully) +Fixed a few missing descriptions for commands + +Version 1.0.48 +Updated French Translation +Updated German Translation +Updated Polish Translation +Placed Coal Ore and Redstone Ore won't give XP anymore +Fixed unusually high memory usage at startup +Added many features to the party system written by NuclearW + +Version 1.0.47 +Fixed another BukkitContrib error for servers not running BukkitContrib + +Version 1.0.46 +Fixed bug preventing Excavation from gaining skill + +Version 1.0.45 +Corrected /stats showing Repair XP as Level for Repair +Corrected /repair showing Repair XP as Level for Repair +Corrected /whois showing Repair XP as Level for Repair + +Version 1.0.44 +Fixed my 'fix' of BukkitContrib errors with Tree Feller + +Version 1.0.43 +Stopped things from being auto-smelt'd + +Version 1.0.42 +Corrected 2 more errors involving not running BukkitContrib + +Version 1.0.41 +Fixed errors using Tree Feller if your server wasn't running BukkitContrib (sorry!) +Fixed some more leftover stuff involving the new half-finished mining skill +Fixed excavation's Giga Drill Breaker not working on placed blocks + +Version 1.0.40 +Fixed errors if your server wasn't running BukkitContrib + +Version 1.0.39 +mcMMO won't auto-download and auto-run BukkitContrib anymore + +Version 1.0.38 +Commented code for the half-finished Infernal Pick subskill (Whoops) + +Version 1.0.37 +The donation message in /mcmmo is now toggle-able +The anvil message now only gets shown the first time you place an anvil (after login) +Reworked /mcmmo (an improvement I would say) +Added /mcmmo text to localization file +Archery fire rate now configurable +Berserk mode stops items from being collected +Taming no longer receives xp from wolves being harmed +Fixed bug where /stats required Tree Feller permission to show Woodcutting skill +Fixed bug where players with mcgod could be harmed by AoE +Fixed bug where modifying a skill also modified the xp to the same amount (when it should be zero) + +BukkitContrib Stuff +Added a pop-up when placing an Anvil +Added pop-ups on levelup +Added basic sound effects to various abilities (Berserk, Tree Feller, Super Breaker, Leaf Blower, etc...) + +Code Stuff +Added checkXp(SkillType, Player) for plugin devs (use this after modifying XP to check for levels) +Added getPlayerProfile() which returns a PlayerProfile object for plugin devs (You can do almost everything with this object) +100% more enums +Changed how checking skill xp worked to be more efficient + +Version 1.0.36 +mcMMO now properly supports Bukkit/PEX/Permissions for Permissions +Config.yml will no longer generate Performance Debugging nodes +Registered permission nodes to plugin.yml +Some more changes to Permissions code +Fixed bug where Super Breaker activated where it shouldn't +Fixed bug with enabling/disabling mcgod in config.yml +Fixed bug with Excavation not kicking in until 1 level higher + +Version 1.0.35 +Added a Toggle for Chimaera Wing in config.yml +Added customization of what item is used for Chimaera Wing in config.yml +Fixed bug with randomly receiving Taming XP +mcmmo.users file moved into /plugins/mcMMO/FlatFileStuff/ +Leaderboard files now moved into /plugins/mcMMO/FlatFileStuff/Leaderboards +Locale files now have the prefix locale_ instead of messages_ +Locale files are now located inside com/gmail/nossr50/locale/ instead of com/gmail/nossr50/ +Updated the code that handles permissions (this may mean 3.1.6 will finally play well!) +Some more source code organization +Fixed warnings for compiler +Removed dependencies on CraftBukkit +Registered commands to OnCommand +Removed performance debugging +Removed some useless settings from the config file + +Version 1.0.34 +Fixed the PVP setting determining whether or not you would hurt yourself from AoE Abilities +Added Dutch (nl) language support +Super Breaker now gives the correct XP as determined by config.yml +Sand Stone XP is now configurable and no longer shares the 'stone' node +/mining now shows mining values instead of taming values + +Version 1.0.33 +Fixed the toggle for the Excavation drop 'Cocoa Beans' +Fixed bug where Unarmed users could disarm without being bare handed +Cocoa Beans now have an XP modifier in config.yml +You can now toggle whether or not Mobspawners will give XP (in config.yml) +MySQL version now makes requests to the MySQL server less frequently (should help performance) +Fixed bug with Skull Splitter hitting the user + +Version 1.0.32 +Added "General.Performance.Print_Reports" node to config.yml to help identify causes of performance issues +Fixed bug of swords users hurting themselves with serrated strikes + +Version 1.0.31 +Fixed bug of trying to cast Animals to non-animals + +Version 1.0.30 +Mobs that spawn from spawners no longer give XP (for reals this time) + +Version 1.0.29 +Mobs that spawn from spawners no longer give XP (again) +Fixed bug where Serrated Strikes did not Bleed additional targets +Identified and solved a potential memory leak in Bleed Simulation +Renamed the Object Config to Misc and rewrote parts of it +Rewrote Party/Admin/God toggles +Added Polish language support (pl) + +Version 1.0.28 +Actually fixed /stats showing excavation values for swords +Made some improvements to how Bleed Simulation was handled for different entity types +Obsidian now does normal durability damage during Super Breaker + +Version 1.0.27 +Fixed /stats showing excavation values for swords +Hopefully fixed a wide range of NPE errors +Updated German (de) localization + +Version 1.0.26 +Fixed accidentally making power levels go above 9,000 + +Version 1.0.25 +Compatible with the latest CB +Beast Lore now functions correctly +Wolves are no longer invincible to players +Changed the look of Beast Lore +Skill info pages now show your stat in that skill (if you have permission) +/stats and /whois has been alphabetized and divided into three categories (Gathering/Combat/Misc) +Abilities will not trigger on Trap Doors + +Version 1.0.24 +Now compatible with latest RB (928) +Taming now receives XP from your wolves harming foes +Taming is now easier to level +Green Thumb now drops seeds when harvesting Wheat + +Version 1.0.23 +Modified Bleed Simulation to fix performance problems +Rewrote MySpawn to be more efficient when calculating time left +Rewrote Skills to be more efficient when calculating time left + +Version 1.0.22 +Added 'Name' nodes to commands for renaming them + +Version 1.0.21 +Fixed Skull Splitter length in /axes displaying incorrectly +Fire rate limiter now correctly uses the value in the config file +Stone XP now correctly uses the value in the config file +Cobble -> Mossy now correctly uses the value in the config file +Removed setmyspawn from config file as it serves no purpose +All commands now have an 'Enabled' node in the config file that when set to false disables the command completely +Fixed color scheme inconsistency for Mining in /whois results + +Version 1.0.20 +Fixed Array Index Out of Bounds error + +Version 1.0.19 +Removed a failsafe for the Timer that is no longer necessary (should improve performance) +Fixed /myspawn not working by rewriting it :3 +Fixed exploit where players could break a freshly placed mushroom for XP +MySQL User Passwords can now be blank (Although you really should have a password...) +Fixed a few NPE errors + +Version 1.0.18 +Fixed MySQL default TablePrefix +Fixed Wheat not being configurable + +Version 1.0.17 +Brand new YAML Configuration file +Ability to configure XP for all gathering skills in config file +German Language added to mcMMO +French Language added to mcMMO +MySpawn will no longer heal players +/ commands now also check for their localized names for displaying help +Added many more Strings to localization files +Added more safeguards to MySpawn for NPE +Fixed bug where Tree Feller Radius depended on WoodCutting XP rather than Skill Level +Fixed bug where Readying a Hoe returned a missing localization string +Added some safeguards into Bleed Simulation to prevent possible memory leaks +Performance improvements to storing/calling Skill/XP Values +Plugged a potential memory leak with PlayerProfiles not being removed correctly +Disabled the mob spawner camping anti-exploit in favor of performance + +Version 1.0.16 +Fixed bug where localization file failed to load +Changed en_US to lowercase +mcMMO now requires locale files to be in lowercase +Fixed a few strings missing from the localization file + +Version 1.0.15 +Removed leftover code that spammed SQL errors + +Version 1.0.14 +Added many missed strings into localization +Finnish Localization updated for the new strings +Green Thumb should respect Block Protection plugins now +Fixed Number Format Exception when loading a PlayerProfile + +Version 1.0.13 +Fixed bug/NPE where stats would not load and therefore 'reset' for players +Fixed NPE involving /ptp +Added "enableMOTD" setting to properties file + +Version 1.0.12 +Fixed another NPE error +Non-Gathering skills should correctly gain XP if PVP is set to false now +Localization will now support language codes that do not have two parts like "fi" +Fixed bug where Wiki MOTD message would not be loaded from localization file + +Version 1.0.11 +Fixed bug where players could not gain experience in several skills +Removed PVP flag from mcmmo.properties as its not needed anymore +Fixed a few NPE errors +Mushroom XP reduced from 25 to 15 +Fixed an exploit where players who just logged in could be farmed for experience because they were invulnerable + +Version 1.0.10 +Added Localization/String Customization +Mushroom XP reduced from 40 to 25 +Removed "clears inventory" warning in /mcc for /myspawn since this no longer happens + +Version 1.0.09 +Fixed the NPE that occurs when players gain experience (Sorry!) +Fixed bug where /myspawn & /clearmyspawn would work if MySpawn was disabled in the properties file +Changed strings containing "MMO" to read "mcMMO" +Removed a lot of unused or unnecessary variables from the PlayerProfiles in mcMMO, this should lower the memory footprint +Added getXpToLevel() for modders + +Version 1.0.08 +Added removeXP() for modders +Fixed bug where stone swords only repaired by 33% instead of 50% +Fixed bug where stone/wooden hoes wouldn't repair +Big overhaul to how skill values and xp values were handled in the code +Modifying the players skill levels now sets the corresponding skill xp to zero +Using Serrated Strikes/Skull Splitter on mobs should no longer harm nearby players when PVP is disabled +Switching to another weapon after firing your bow should no longer trigger procs for that weapon when the arrow hits +Slimes/Ghasts now give XP for combat skills +Added "EnableHpRegeneration" property setting +Added "EnableMySpawn" property setting + +Version 1.0.07 +Added more repair customization by solarcloud7 +Leaderboards ignore players with the respective stat at 0 +Reconnecting to MySQL will reload player data +Fixed a NPE with MySQL's Leaderboards +Removed "Loop iteration" debug message from mcMMO + +Version 1.0.06 +MySQL will attempt to reconnect if the connection is closed +Breaking the bottom block of Cactus/Reeds will award the correct experience and double drops +Added support for Minecraft Statistics +Fixed NPE with /myspawn command + +Version 1.0.05 +PVP interactions now check for permissions before handing out any experience +Many skill abilities now check for permissions correctly +All interactions with Taming now check for permissions +mcMMO now checks for its pvp flag being true before handling pvp interactions + +Version 1.0.04 +Fixed bug where players would be informed incorrectly when their cooldowns refreshed +Fixed exploit where players could reconnect to reset their cooldowns +Added new "cooldowns" table to MySQL +Berserk now breaks through snow +Lightning no longer gives Taming XP +Shortened /mcc to fit the screen + +Version 1.0.03 +Bleed will no longer trigger on friendly wolves +Axes criticals will no longer trigger on friendly wolves + +Version 1.0.02 +Fixed bug where the Timer would start before everything else was ready +Fixed bug where mcrefresh also required mcability permission node +Fixed bug where Unarmed was not checking for disarm procs +Green Thumb now checks for herbalism permissions +Added "enableGreenThumbCobbleToMossy" to config file, this also changes Green Terra +AoE abilities now harm wolves + +Version 1.0.01 +Removed debug message when wolves are struck +Fixed issue with reloading mcMMO when MySQL was enabled +Fixed a NPE with MySpawn +Fixed a NPE with removing users from PlayerProfile +Unarmed no longer starts with a damage bonus +Unarmed apprentice DMG bonus changed from 3 to 2 + +Version 1.0 +Players can now repair Stone/Wood tools +Fixed duping bug with WG/Block Protection Plugins +Added Leaf Blower to WoodCutting +Different Trees give different WoodCutting XP +Water changing Gravel to Clay removed +Code Organized/Optimized further +MySQL Support +Taming Skill +Leaderboards +Players won't hand out XP if they died within the last 5 seconds + +Version 0.9.29 +Fixes critical bug involving water turning anything into clay + +Version 0.9.28 +Green thumb can now spread grass to dirt using seeds +Adding XP will check for level ups again +Acrobatics won't hand out XP on death anymore +Acrobatics will check plugins for the event being cancelled before handing out XP + +Version 0.9.27 +Fixed Herbalism not properly receiving Triple Drops from Green Terra +Fixed Herbalism not handing out any XP outside of Green Terra +Fixed Herbalism asking for seeds on things that did not require it + +Version 0.9.26 +Fixed Green Terra going off without readiness +Fixed Hoe trying to ready when tilling Grass + +Version 0.9.25 +Fixed issue with anti-exploits and Herbalism +MySpawn works like a hearthstone now, no inv pentality, 1hr cooldown +Added Green Terra Ability to Herbalism +Added Green Thumb ability to Herbalism +Fixed Repair not working for Iron Tools +Fixed bug where Axes Ability checked for Unarmed Ability Permission +Added Cocoa Beans to Excavation XP/Loot Tables, Found in Grass/Dirt +Using Super Breaker on Obsidian significantly damages it compared to other materials +Added Obsidian to Mining XP Table/Super Breaker +Added Pumpkins/Reeds/Cactus to Herbalism XP Tables/Double Drops +Corrected "mcMMMO" to "mcMMO" in MOTD + +Version 0.9.24 +PLAYER_BED_ENTER removed due to its unusual issues +Added info about the Wiki to the motd +/mcrefresh will reset if you were recently hurt (Chimaera Wing/HP Regen) +Fixed Armor Repair not adding XP +Boosted Repair XP of Armor to match Tools +Repairing Armor won't trigger Super Repair twice anymore +Setting your MySpawn now just requires right clicking a bed (still requires the setmyspawn permission node) + +Version 0.9.23 +Players will now announce ability usage within a short distance to nearby players +Chimaera Wing now takes the world into account +Acrobatics won't give XP on death, and will fail if you would've died after the damage reduction +Added yet another check to see if a Player is not in the Users system for NPC mod compatibility + + +Version 0.9.22 +Fixed bug where chimaera wing was unusable after being hurt even after the cooldown + +Version 0.9.21 +/mcrefresh fixed to work properly with the new ability monitoring system +Ability lengths are now based on your skill level directly rather than a tiered system +Chimaera Wings won't trigger on things they shouldn't (Doors, Chests, ETC) +Chimaera Wings will properly tell you how long you have to wait to use it if you've been recently hurt + +Version 0.9.20 +Fixed Tree Feller not checking if their cooldown was refreshed and always activating +/stats and /whois will now show the powerlevel based on permissions +Shovels will no longer say you've lowered your axe +/myspawn will no longer say your inventory has been cleared if the server settings disable this feature + + +Version 0.9.19 +Fixed Anti-Exploit XP stuff not working + +Version 0.9.18 +Added failsafe to prevent abilities from going on forever, abilities will check if they should've expired when being used in case the Timer fails +Archery Spam has been nerf'd, you can only fire once per second now (Toggle-able in config file) +Fixed bug when just having the Admin Chat permission wouldn't allow you to see Admin Chat +Fixed bug where Axes ability could be used without permission +Abilities are monitored with Timestamps rather than a Timer monitored tick rate +When players were last hurt is now monitored with Timestamps rather than a Timer monitored tick rate +Made Anti XP-Exploits more Robust +Repair XP is now based on durability restored +Acrobatics rolling will now reduce damage if you go over the damage threshold +Acrobatics rolling damage threshold lowered to 10 from 20 +Added Graceful Roll to Acrobatics, hold Shift when falling to do a Graceful Roll +mcMMO now checks for the blockBreak and EntityDamage events being canceled before proceeding +Dodge notification shortened +Dodge won't negate damage completely anymore +Added 3 more functions for plugin authors to call, getPartyName(Player player), inParty(Player player), and getParties() + +Version 0.9.17 +Players now set their MySpawn by entering a bed, it requires the setmyspawn permission node +/setmyspawn has been removed +Compatible with CB 670 +Fixed errors related to Repair +Abilities will no longer trigger from Bed interactions +/unarmed will now tell the player when they will receive unarmed master (if they have apprentice) + +Version 0.9.16 +Logs placed by the player won't grant XP/Double Drops anymore +Added more functions plugin authors can call +Acrobatics roll has a damage threshold of 20, going above this means a failed Roll + + +Version 0.9.15 +Acrobatics will now behave properly +AoE Abilities ignore wolves (temp fix) +Added "all" parameter to /mmoedit & /addxp +After giving XP to a player it will now check for level ups in skills + +Version 0.9.14 +mcMMO checks for abilities being active before sending the fake block break event + +Version 0.9.13 +Fixed excavation ignoring the xpGainMultiplier +Now compatible with CB 600+ +Fixed bug where Dodge acted maxed out no matter your skill level + +Version 0.9.12 +mcMMO now fakes a block break event for abilities to maximize plugin compatibility +/herbalism will return the correct values now +New /addxp command + +Version 0.9.11 +PVE Combat Skills experience is now based on damage dealt +The Timer will no longer break from Bleed Simulation +Tree feller no longer "damages" saplings +Bleed+ (Serrated Strikes) lasts 5 ticks down from 12 +Bleed/Bleed+ now do 2 damage instead of 1 +Power Level is now based on permissions +Counter Attack added to swords +Parry is now based directly on Swords skill level +Parry maximum proc chance raised to 30% from 20% +Serrated Strikes now properly applies Bleed+ to targets +Players who parry can no longer be disarmed +Acrobatics now has a Dodge passive skill reducing damage +Repair skill now effects how much durability is restored +Super repair now doubles the repair amount on proc +Unarmed now starts with a bonus to damage to encourage use +Unarmed now has two steps to damage scaling, Appentice, and Mastery +Unarmed disarm now caps at 25% for 1000 skill +Fixed problem where Archery skill procs would ignore other plugins +Ignition changed to 25% chance +Ignition length will be based on archery skill level +/myspawn now has a warning about the inventory loss penalty in /mcc +mcMMO Timer now runs in 1 second intervals rather than 2 + +Version 0.9.10 +Party invites now show who they are from +Mushrooms added to Dirt/Grass excavation loot tables, drops with 500+ skill +mcMMO configuration files property setting names have been changed for readability +Fixed bug where Gold and Iron wouldn't drop anything during Super Breaker +Added /mcability info to /mcc +Potentially fixed NPE error when checking players for being in same party for PVP XP +Removed sand specific diamond drop from sand excavation loot table, Diamonds can still drop globally for sand +Added a global XP gain multiplier, increase it to increase XP gained +Reduced PVE XP for Unarmed, now identical to Axes/Swords +Changed Chat priority in mcMMO to be higher, this should help plugin conflicts +Mushroom XP raised to 40 from 10 +Flower XP raised to 10 from 3 + +Version 0.9.9 +Fixed problem where entities never got removed from the arrow retrieval list of entities + +Version 0.9.8 +EntityLiving shouldn't be cast to entities that are not an instance of EntityLiving +Added a null check in the timer for players being null before proceeding + +Version 0.9.7 +Procs/XP Gain will no longer happen when the Entity is immune to damage (Thanks EdwardHand!) +Axes critical damage versus players reduced to 150% damage from 200% damage +Fixed bug where Daze might not proc +Changed archery Daze to follow smooth transition +Added archery Daze chance info to /archery +Cooldown lengths are now customizable, they are in seconds and multiplied by 2 by mcMMO + +Version 0.9.6 +Timer checks for player being null before adding them to the mcUsers system +Cooldowns will now show how much time is remaining when trying to use their respective abilities +SkullSpliiter will now correctly inform the player when they are too tired to use it +Acrobatics will no longer give XP if the event was cancelled by another plugin +Version 0.9.5 +Super Breaker now gives a chance for Triple Drops based on mining skill +Ability durability loss down from 15 to 2 +Ability durability loss is now toggle-able +Ability durability loss can be adjusted in the configuration file +Mining Picks are no longer lowered after activating Super Breaker + +Version 0.9.4 +Flowers won't drop wheat anymore +Signs won't trigger ability readiness anymore +Version 0.9.3 +Bug stopping abilities from never wearing of may have been fixed +Changed color of "X Ability has worn off" to RED from GRAY +Super Breaker, Giga Drill Breaker, and Tree Feller now damage the tool significantly during use +Netherrack and Glowstone now give Mining XP +Netherrack and Glowstone are now effected by Super Breaker +Abilities will no longer be readied when you right click signs or beds +Chimaera Wings won't activate on blocks you can interact with and signs +Abilities now adjust their effects depending on tool quality +Superbreaker won't break things that tool couldn't normally break +Giga Drill Breaker will only give triple xp and triple drops for diamond tools, with a reduced effect for lesser tools +Skull Splitter now has a limit of opponents nearby it will strike based on your tool quality +Serrated Strikes now has a limit of opponents nearby it will strike based on your tool quality +Modified /mcmmo description to be a little bit more relevant. + +Version 0.9.2 +Changed priority of some of the mcMMO listeners +Now when certain abilities are activated it shouldn't say "You lower your x" + +Version 0.9.1 +Fixed "Unknown console command" errors with CB 556 +Added /mcability command to toggle being able to trigger abilities with right click +Added some more nullchecks for people reporting NPE errors +Compatibility with NPC mods improved (Mainly for archery!) +Other plugins can now call inSameParty() from mcMMO to increase compatibility + +Version 0.9 +--NEW CONTENT-- +Woodcutting now has the "Tree Feller" Ability +Unarmed now has the "Berserk" Ability +Swords now has the "Serrated Strikes" Ability +Mining now has the "Super Breaker" Ability +Axes now has the "Skull Splitter" Ability +Excavation now has the "Giga Drill Breaker" Ability +Added /mcrefresh - tool for refreshing cooldowns +Unarmed now has the "Deflect Arrows" passive skill +Chimaera Wing Item Added + +--CHANGES-- +HP Regen & Bleed are back +Woodcutting will drop the appropriate log on double drop procs +Herbalism now applies double drops to herbs +/ now shows much more information to the player regarding their stats +Axes skill Critical Strikes are now based directly on your skill level +Swords skill Bleed chance is now based directly on your skill level +Unarmed disarm chance is now based directly on your skill level +Acrobatics now gives XP when you roll + +--BUGFIXES-- +Memory Leak Fixed +Axes not doing critical strikes +Gold Armor repair +Capped skills now have the correct proc chance +/mmoedit is no longer case sensitive +More NPE errors fixed +Many bugs I forgot to write down + +--PLUGIN COMPATABILITY FIXES-- +If combat interactions are cancelled by other plugins mcMMO should ignore the event +If block damage interactions are cancelled by other plugins mcMMO should ignore the event + +Version 0.8.22 + Fixed bug where Axes did less damage than normal + Acrobatic rolls now give XP + Acrobatics XP increased for non-rolls +Version 0.8.21 + Fixed bug where axe criticals would dupe items +Version 0.8.20 + 99.99% sure I fixed anvils that suddenly stop working +Version 0.8.19 + Fixed being able to excavate placed blocks + Added toggle option to mining requiring a pickaxe + Added toggle option to woodcutting requiring an axe + PVP interactions now reward XP based on the damage caused (this is effected by skills) + PVP XP gain can be disabled in the configuration file + PVP XP has a modifier, increase the modifier for higher XP rewards from PVP combat +Version 0.8.18 + Fixed sandstone not being watched for exploitation +Version 0.8.17 + mcmmo.users moved to plugins/mcMMO/ + Snowballs and Eggs will no longer trigger Ignition + Loot tables for excavation adjusted + Mining benefits now require the player to be holding a mining pick + Woodcutting benefits now require the player to be holding an axe +Version 0.8.16 + Moved configuration file to /plugins/mcMMO + Arrows now have a chance to Ignite enemiesw + Fixed arrows not being retrievable from corpses + Added info about ignition to /archery +Version 0.8.14 + Mining, Woodcutting, Herbalism, and Acrobatics proc rates now are based on your skill level directly rather than tiers you unlock via skill levels + Archery's ability to retrieve arrows from corpses now is based on your skill level directly rather than tiers you unlock via skill levels + Mining, Woodcutting, Herbalism, Archery, and Acrobatics now show their proc % relative to your skill if you type / + You can now adjust what level is required to repair diamond in the configuration file + Changed mining XP rates to be a tad higher for some things + You can now get XP from sandstone + XP rates increased for gathering glowstone with excavation + XP rates increased a bit for excavation + Skill info is now a bit more detailed for certain skills + Added info about arrow retrieval to /archery +Version 0.8.13 + Enemies no longer look like they have frozen when they die + Item duping fix +Version 0.8.11 + Performance improvements + Memory leak fixed + NPE error with MySpawn really fixed +Version 0.8.9 + Fixed NPE for My Spawn + Fixed NPE for onBlockDamage + Bleed proc now correctly checks for Swords permissions +Version 0.8.8 + Gold can now be repaired + Tweaked Mining XP gains + Reorganized code + Added /mcgod godmode command + Fixed the pvp toggle in the settings file +Version 0.8.7 + Removed packet-sending stuff wasn't working anyways + Fixed another NPE with the TimerTask + Skills now only show up in /stats if you have permissions for them +Version 0.8.6 + Added a null check in bleed simulation to prevent a NPE +Version 0.8.5 + Players are now added to files when they connect (to fix a NPE) + onPlayerCommand stuff moved into onPlayerCommandPreprocess +Version 0.8.4 + Fixed another nullpointer error for TimerTask + Fixed bug making regeneration take twice as long to kick in after combat +Version 0.8.3 + Modified the timer intervals (from 1 second to 2) + All skills now have an individual modifier (Set by default to 2) + There is now a global XP modifier (Set by default to 1) + Herbalism now correctly follows its skill curve + Unarmed no longer gives experience for harming other players + Players can no longer exploit mob spawners for experience +Version 0.8.2 + Fixed Concurrent Modification Exception + Fixed some incorrect skill descriptions + First tier of HP Regeneration is now available from the start + Fixed bleed proc rate for very high skill levels + Changed regeneration permissions to 'mcmmo.regeneration' +Version 0.8 + Archery skill now lets players recover arrows from downed foes + Health regenerates based on power level + Added toggle to myspawn clearing player inventory in settings file + Swords now have a bleed effect + Rewrote Skill descriptions to be more informative/better +Version 0.7.9 + XP Curve now follows a new formula + Acrobatics XP gains changed + Compiled against permissions 2.1 +Version 0.7.8 + Massive tweaks to XP gain for Archery, Swords, Axes, Unarmed +Version 0.7.7 + Minor tweak to how players are added to the flat file + Fixed some nullpointer exceptions when players die +Version 0.7.6 + Fixed being able to repair diamond armor with below 50 skill + Myspawn now supports multiple worlds, clearing myspawn will set it to the first world created by the server +Version 0.7.5 + Removed random checks for herbalism XP + Herbalism is now called properly (This should fix gaining no xp or double drops) +Version 0.7.4 + Work around for a bukkit bug that broke my onBlockDamage event + Added /clearmyspawn +Version 0.7.3 + Fixed to work with build 424 of CB + Lowered the XP of gold due to it not being that rare anymore +Version 0.7.2 + Fixed security flaw where players could access /mmoedit if the server was not running permissions + Reduced XP gain of woodcutting a bit +Version 0.7 + Completely rewrote the XP system + Added an XP skillrate modifier to the settings file + +Version 0.6.2 + Axes now do critical strikes against farm animals + Removed the "Stupidly Long Constructor" + Now compatible with the latest CB builds +Version 0.6.1 + Customizable command names + Axes can now be modified with /mmoedit + Party members are now correctly informed when you leave the party + Fixed incorrect commands in /mcc +Version 0.5.17 + + Changed namespaces to fit bukkits new standard + Adjusted excavation proc rates + Modified excavation loot tables + Added Party Invite System + +Version 0.5.16 + + Fixed unarmed not checking for permissions when hitting players + +Version 0.5.15 + Fixed stone swords not being recognized as swords + Fixed /a not working if you were an op but did not have permissions + +Version 0.5.14 + Added permissions for skills + +Version 0.5.13 + + Removed skillgain from succesful parries + Repair now refreshed the inventory + +Version 0.5.12 + + Fixed being able to hurt party members with the bow and arrow + +Version 0.5.11 + + Added /mmoedit command + Fixed bug preventing player versus player damage + Fixed bug preventing damage from scaling with unarmed & bows + Fixed disarm proc making the opponent dupe his/her items + Added mcmmo.tools.mmoedit permission + Added mcmmo.commands.setmyspawn permission + Added totalskill to /stats + Changed the look of /stats + +Version 0.5.10 + + Fixed trying to set health to an invalid value + +Version 0.5.9 + + Fixed duping inventories on death + +Version 0.5.8 + + Fixed bug where players inventories would dupe during combat + +Version 0.5.7 + + Fixed monsters instant killing players + Misc fixes +Version 0.5.4 + + Changed herbalism skill gain from wheat to be WAAAAY slower + +Version 0.5.3 + + Players will now correctly drop their inventories when killed by a monster + +Version 0.5.2 + + Fixed MAJOR bug preventing swords skill from gaining through combat + +Version 0.5 + + Archery Added + Swords Added + Acrobatics Added + Logging for Party/Admin chat added + Fixed whois to show correct values for Excavation + Made death messages much much more specific + +Version 0.4.4 + + Fixed being able to repair full durability iron tools + Fixed herbalism benefits not behaving properly + Fixed removing 1 diamond from every stack of diamond when repairing diamond + +Version 0.4.2 + + Removed myspawn from the motd + +Version 0.4.1 + + Fixed /mcc showing incorrect command for herbalism + Changed unarmed skillrate to be much slower than before + Modified a few skill descriptions + Added permission for /whois + Players can now use admin chat without being op as long as they have the correct permission (requires Permissions) + +Version 0.4 + + Permissions support + Removed OPs having different names than normal players + Removed /setspawn & /spawn + Slowed down excavation skill rate + Fixed excavation coal drop being too rare + +Version 0.3.4 + + Creepers now give double xp for unarmed + Iron armor can now be repaired! + Fixed bug stopping items from being repaired + +Version 0.3.3 + + Yet another herbalism skill gain tweak + +Version 0.3.2 + + Changed excavation loot tables to be more rewarding + Changed sand to give normal excavation xp instead of double xp + Fixed herbalism skill exploit + Mobs killed with unarmed now drop loot properly + Unarmed xp rate depends on mob (zombies lowest fyi) + Huge player crashing bug fix on disarm! + +Version 0.3.1 + + Fixed excavation not saving properly + Fixed repair using excavation values + +Version 0.3 + + Unarmed skill + Herbalism skill + Excavation skill + Many bugfixes (thanks for reporting them!) + / - Detailed information about skills in game + +Version 0.2.1 + + Misc bugfixes + +Version 0.2 + + Repair ability added + Repair skill added + Iron Armor repair temporarily disabled + Anvils (Iron Block) added + /mcmmo & /mcc added + Misc changes to existing commands + Misc bug fixes + +Version 0.1 + + Releasing my awesome plugin + diff --git a/README.creole b/README.creole deleted file mode 100644 index 0a354a512..000000000 --- a/README.creole +++ /dev/null @@ -1,28 +0,0 @@ -== mcMMO -**The RPG lovers mod** - -=== Dev builds -http://ci.mcmmo.info Download the latest dev build of mcMMO here. - -=== Brief Description -mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience. - -If you want an original RPG experience like no other mod out there, mcMMO is for you. - -=== About the Developer -I've always wanted to make games and in the last year I decided to take a swing at developing Minecraft mods as a platform to teach myself programming, the biggest project I have made to date is mcMMO. I went from knowing nothing about Java to what I know now purely from modding Minecraft, and I plan to move onto game development in the not so distant future. - -I take design very seriously, I am not the kind of person who can be satisfied giving a project anything less than my all. As you will see reflected in the quality of the mods I make, I take great care in my work. - -Hearing that people enjoy mcMMO and seeing the daily youtube videos about my mod has become a joy, I really can't believe how popular my mod has gotten! - -=== Compiling - -Required Libraries: -* Spout API -* JUnit - -Required to Run: -* Bukkit - -http://dev.bukkit.org/server-mods/mcmmo for more up to date information. diff --git a/README.md b/README.md new file mode 100644 index 000000000..3620dc39e --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# mcMMO +## The RPG lovers mod + +### Dev builds +Our latest development builds are available [here](http://ci.mcmmo.info). + +### Brief Description +mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience. + +If you want an original RPG experience like no other mod out there, mcMMO is for you. + +## About the Team + +mcMMO is currently developed by a team of individuals from all over the world. +### Glorious Leader +[![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)] +(https://github.com/gmcferrin) + +### Developers +[![bm01](http://www.gravatar.com/avatar/ec8146f5358177f12e9a252271bbc391.png)] +(https://github.com/bm01) +[![Glitchfinder](http://www.gravatar.com/avatar/5aa4cce22f72ae9c002ecec30f061d00.png)] +(https://github.com/Glitchfinder) +[![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)] +(https://github.com/nossr50) +[![NuclearW](http://www.gravatar.com/avatar/90926bdcf1c8a75918df5ea5fa801ce6.png)] +(https://github.com/NuclearW) +[![shatteredbeam](http://www.gravatar.com/avatar/cad3b5d7d39cf5387afb87f494389610.png)] +(https://github.com/shatteredbeam) +[![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)] +(https://github.com/TfT-02) +[![t00thpick1](http://www.gravatar.com/avatar/??.png)] +(https://github.com/t00thpick1) + +## Compiling + +mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO. + +The typical command used to build mcMMO is: mvn clean package install + +Required Libraries: +* Spout API +* JUnit +* Metrics +* Bukkit + +http://dev.bukkit.org/server-mods/mcmmo for more up to date information. diff --git a/pom.xml b/pom.xml index 1ee4ef445..3c0b7cc91 100755 --- a/pom.xml +++ b/pom.xml @@ -1,182 +1,182 @@ - - 4.0.0 - com.gmail.nossr50.mcMMO - mcMMO - 1.4.00-dev5 - mcMMO - https://github.com/mcMMO-Dev/mcMMO - - https://github.com/mcMMO-Dev/mcMMO/issues - GitHub - - - mcMMO - ${basedir}/src/main/java - - - . - true - ${basedir}/src/main/resources/ - - *.yml - .jenkins - - - - resources - false - ${basedir}/src/main/resources/xpbar/ - - xpbar*.png - - - - resources - false - ${basedir}/src/main/resources/healthbar/ - - health*.png - - - - resources - false - ${basedir}/src/main/resources/skillicon/ - - *.png - - - - resources - false - ${basedir}/src/main/resources/sound/ - - *.wav - - - - com/gmail/nossr50/locale - true - ${basedir}/src/main/resources/locale/ - - locale*.properties - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - - - maven-assembly-plugin - - - src/main/assembly/package.xml - - - - - build - package - - single - - - - - - org.apache.maven.plugins - maven-shade-plugin - 1.5 - - - - com.turt2live.metrics:MetricsExtension - - - - - com.turt2live.metrics - com.gmail.nossr50.util.mcstats - - - - - - package - - shade - - - - - - - - org.apache.maven.wagon - wagon-file - 2.2 - - - - - - bukkit-repo - http://repo.bukkit.org/content/groups/public/ - - - spout-repo - http://nexus.spout.org/content/groups/public/ - - - Plugin MetricsExtension - http://repo.turt2live.com - - - - - org.bukkit - bukkit - LATEST - jar - compile - - - org.getspout - spoutplugin - LATEST - jar - compile - - - junit - junit-dep - 4.10 - test - - - com.turt2live.metrics - MetricsExtension - 0.0.2-SNAPSHOT - jar - compile - - - - - mcmmo-repo - file:///var/lib/jenkins/repo - - - - UTF-8 - - + + 4.0.0 + com.gmail.nossr50.mcMMO + mcMMO + 1.4.00 + mcMMO + https://github.com/mcMMO-Dev/mcMMO + + https://github.com/mcMMO-Dev/mcMMO/issues + GitHub + + + mcMMO + ${basedir}/src/main/java + + + . + true + ${basedir}/src/main/resources/ + + *.yml + .jenkins + + + + resources + false + ${basedir}/src/main/resources/xpbar/ + + xpbar*.png + + + + resources + false + ${basedir}/src/main/resources/healthbar/ + + health*.png + + + + resources + false + ${basedir}/src/main/resources/skillicon/ + + *.png + + + + resources + false + ${basedir}/src/main/resources/sound/ + + *.wav + + + + com/gmail/nossr50/locale + true + ${basedir}/src/main/resources/locale/ + + locale*.properties + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + + maven-assembly-plugin + + + src/main/assembly/package.xml + + + + + build + package + + single + + + + + + org.apache.maven.plugins + maven-shade-plugin + 1.5 + + + + com.turt2live.metrics:MetricsExtension + + + + + com.turt2live.metrics + com.gmail.nossr50.metrics.mcstats + + + + + + package + + shade + + + + + + + + org.apache.maven.wagon + wagon-file + 2.2 + + + + + + bukkit-repo + http://repo.bukkit.org/content/groups/public/ + + + spout-repo + http://nexus.spout.org/content/groups/public/ + + + Plugin MetricsExtension + http://repo.turt2live.com + + + + + org.bukkit + bukkit + LATEST + jar + compile + + + org.getspout + spoutplugin + LATEST + jar + compile + + + junit + junit-dep + 4.10 + test + + + com.turt2live.metrics + MetricsExtension + 0.0.2-SNAPSHOT + jar + compile + + + + + mcmmo-repo + file:///var/lib/jenkins/repo + + + + UTF-8 + + diff --git a/src/main/java/com/gmail/nossr50/api/AbilityAPI.java b/src/main/java/com/gmail/nossr50/api/AbilityAPI.java index 87c6d1e6a..515bf14f3 100644 --- a/src/main/java/com/gmail/nossr50/api/AbilityAPI.java +++ b/src/main/java/com/gmail/nossr50/api/AbilityAPI.java @@ -1,51 +1,51 @@ -package com.gmail.nossr50.api; - -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.util.Users; - -public final class AbilityAPI { - private AbilityAPI() {} - - public static boolean berserkEnabled(Player player) { - return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.BERSERK); - } - - public static boolean gigaDrillBreakerEnabled(Player player) { - return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.GIGA_DRILL_BREAKER); - } - - public static boolean greenTerraEnabled(Player player) { - return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.GREEN_TERRA); - } - - public static boolean serratedStrikesEnabled(Player player) { - return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SERRATED_STRIKES); - } - - public static boolean skullSplitterEnabled(Player player) { - return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER); - } - - public static boolean superBreakerEnabled(Player player) { - return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SUPER_BREAKER); - } - - public static boolean treeFellerEnabled(Player player) { - return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.TREE_FELLER); - } - - public static boolean isAnyAbilityEnabled(Player player) { - PlayerProfile profile = Users.getPlayer(player).getProfile(); - - for (AbilityType ability : AbilityType.values()) { - if (profile.getAbilityMode(ability)) { - return true; - } - } - - return false; - } -} +package com.gmail.nossr50.api; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.util.player.UserManager; + +public final class AbilityAPI { + private AbilityAPI() {} + + public static boolean berserkEnabled(Player player) { + return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.BERSERK); + } + + public static boolean gigaDrillBreakerEnabled(Player player) { + return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.GIGA_DRILL_BREAKER); + } + + public static boolean greenTerraEnabled(Player player) { + return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.GREEN_TERRA); + } + + public static boolean serratedStrikesEnabled(Player player) { + return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.SERRATED_STRIKES); + } + + public static boolean skullSplitterEnabled(Player player) { + return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER); + } + + public static boolean superBreakerEnabled(Player player) { + return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.SUPER_BREAKER); + } + + public static boolean treeFellerEnabled(Player player) { + return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.TREE_FELLER); + } + + public static boolean isAnyAbilityEnabled(Player player) { + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + + for (AbilityType ability : AbilityType.values()) { + if (profile.getAbilityMode(ability)) { + return true; + } + } + + return false; + } +} diff --git a/src/main/java/com/gmail/nossr50/api/ChatAPI.java b/src/main/java/com/gmail/nossr50/api/ChatAPI.java index 357ac0008..61662c312 100644 --- a/src/main/java/com/gmail/nossr50/api/ChatAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ChatAPI.java @@ -5,7 +5,7 @@ import org.bukkit.plugin.Plugin; import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; public final class ChatAPI { private ChatAPI() {} @@ -104,7 +104,7 @@ public final class ChatAPI { * @return true if the player is using party chat, false otherwise */ public static boolean isUsingPartyChat(Player player) { - return Users.getPlayer(player).getPartyChatMode(); + return UserManager.getPlayer(player).getPartyChatMode(); } /** @@ -114,7 +114,7 @@ public final class ChatAPI { * @return true if the player is using party chat, false otherwise */ public static boolean isUsingPartyChat(String playerName) { - return Users.getPlayer(playerName).getPartyChatMode(); + return UserManager.getPlayer(playerName).getPartyChatMode(); } /** @@ -124,7 +124,7 @@ public final class ChatAPI { * @return true if the player is using admin chat, false otherwise */ public static boolean isUsingAdminChat(Player player) { - return Users.getPlayer(player).getAdminChatMode(); + return UserManager.getPlayer(player).getAdminChatMode(); } /** @@ -134,6 +134,6 @@ public final class ChatAPI { * @return true if the player is using admin chat, false otherwise */ public static boolean isUsingAdminChat(String playerName) { - return Users.getPlayer(playerName).getAdminChatMode(); + return UserManager.getPlayer(playerName).getAdminChatMode(); } } diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index 52c798697..cb6283fa7 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -1,335 +1,335 @@ -package com.gmail.nossr50.api; - -import org.bukkit.entity.Player; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Users; - -public final class ExperienceAPI { - private ExperienceAPI() {} - - /** - * Check the XP of a player. This should be called after giving XP to process level-ups. - * - * @param player The player to check - * @param skillType The skill to check - * @deprecated Calling this function is no longer needed and should be avoided - */ - @Deprecated - private static void checkXP(Player player, SkillType skillType) { - SkillTools.xpCheckSkill(skillType, player, Users.getProfile(player)); - } - - /** - * Adds raw XP to the player. - *
- * This function is designed for API usage. - * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * @deprecated Use {@link #addRawXP(Player, String, int)} instead - */ - @Deprecated - public static void addRawXP(Player player, SkillType skillType, int XP) { - Users.getPlayer(player).applyXpGain(skillType, XP); - } - - /** - * Adds raw XP to the player. - *
- * This function is designed for API usage. - * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - */ - public static void addRawXP(Player player, String skillType, int XP) { - Users.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), XP); - } - - /** - * Adds XP to the player, calculates for XP Rate only. - *
- * This function is designed for API usage. - * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * @deprecated Use {@link #addMultipliedXP(Player, String, int)} instead - */ - @Deprecated - public static void addMultipliedXP(Player player, SkillType skillType, int XP) { - Users.getPlayer(player).applyXpGain(skillType, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier())); - } - - /** - * Adds XP to the player, calculates for XP Rate only. - *
- * This function is designed for API usage. - * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - */ - public static void addMultipliedXP(Player player, String skillType, int XP) { - Users.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier())); - } - - /** - * Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party. - *
- * This function is designed for API usage. - * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * @deprecated Use {@link #addXP(Player, String, int)} instead - */ - @Deprecated - public static void addXP(Player player, SkillType skillType, int XP) { - Users.getPlayer(player).beginXpGain(skillType, XP); - } - - /** - * Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party. - *
- * This function is designed for API usage. - * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - */ - public static void addXP(Player player, String skillType, int XP) { - Users.getPlayer(player).beginXpGain(SkillType.getSkill(skillType), XP); - } - - /** - * Get the amount of XP a player has in a specific skill. - *
- * This function is designed for API usage. - * - * @param player The player to get XP for - * @param skillType The skill to get XP for - * @return the amount of XP in a given skill - * @deprecated Use {@link #getXP(Player, String)} instead - */ - @Deprecated - public static int getXP(Player player, SkillType skillType) { - return Users.getPlayer(player).getProfile().getSkillXpLevel(skillType); - } - - /** - * Get the amount of XP a player has in a specific skill. - *
- * This function is designed for API usage. - * - * @param player The player to get XP for - * @param skillType The skill to get XP for - * @return the amount of XP in a given skill - */ - public static int getXP(Player player, String skillType) { - return Users.getPlayer(player).getProfile().getSkillXpLevel(SkillType.getSkill(skillType)); - } - - /** - * Get the amount of XP left before leveling up. - *
- * This function is designed for API usage. - * - * @param player The player to get the XP amount for - * @param skillType The skill to get the XP amount for - * @return the amount of XP left before leveling up a specifc skill - * @deprecated Use {@link #getXPToNextLevel(Player, String)} instead - */ - @Deprecated - public static int getXPToNextLevel(Player player, SkillType skillType) { - return Users.getPlayer(player).getProfile().getXpToLevel(skillType); - } - - /** - * Get the amount of XP left before leveling up. - *
- * This function is designed for API usage. - * - * @param player The player to get the XP amount for - * @param skillType The skill to get the XP amount for - * @return the amount of XP left before leveling up a specifc skill - */ - public static int getXPToNextLevel(Player player, String skillType) { - return Users.getPlayer(player).getProfile().getXpToLevel(SkillType.getSkill(skillType)); - } - - /** - * Add levels to a skill. - *
- * This function is designed for API usage. - * - * @param player The player to add levels to - * @param skillType Type of skill to add levels to - * @param levels Number of levels to add - * @param notify Unused argument - * @deprecated Use addLevel(Player, SKillType, int) instead - */ - public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) { - Users.getProfile(player).addLevels(skillType, levels); - - if (notify) { - checkXP(player, skillType); - } - } - - /** - * Add levels to a skill. - *
- * This function is designed for API usage. - * - * @param player The player to add levels to - * @param skillType Type of skill to add levels to - * @param levels Number of levels to add - * @deprecated Use {@link #addLevel(Player, String, int)} instead - */ - @Deprecated - public static void addLevel(Player player, SkillType skillType, int levels) { - Users.getPlayer(player).getProfile().addLevels(skillType, levels); - } - - /** - * Add levels to a skill. - *
- * This function is designed for API usage. - * - * @param player The player to add levels to - * @param skillType Type of skill to add levels to - * @param levels Number of levels to add - */ - public static void addLevel(Player player, String skillType, int levels) { - Users.getPlayer(player).getProfile().addLevels(SkillType.getSkill(skillType), levels); - } - - /** - * Get the level a player has in a specific skill. - *
- * This function is designed for API usage. - * - * @param player The player to get the level for - * @param skillType The skill to get the level for - * @return the level of a given skill - * @deprecated Use {@link #getLevel(Player, String)} instead - */ - @Deprecated - public static int getLevel(Player player, SkillType skillType) { - return Users.getPlayer(player).getProfile().getSkillLevel(skillType); - } - - /** - * Get the level a player has in a specific skill. - *
- * This function is designed for API usage. - * - * @param player The player to get the level for - * @param skillType The skill to get the level for - * @return the level of a given skill - */ - public static int getLevel(Player player, String skillType) { - return Users.getPlayer(player).getProfile().getSkillLevel(SkillType.getSkill(skillType)); - } - - /** - * Gets the power level of a player. - *
- * This function is designed for API usage. - * - * @param player The player to get the power level for - * @return the power level of the player - */ - public static int getPowerLevel(Player player) { - return Users.getPlayer(player).getPowerLevel(); - } - - /** - * Sets the level of a player in a specific skill type. - *
- * This function is designed for API usage. - * - * @param player The player to set the level of - * @param skillType The skill to set the level for - * @param skillLevel The value to set the level to - * @deprecated Use {@link #setLevel(Player, String, int)} instead - */ - @Deprecated - public static void setLevel(Player player, SkillType skillType, int skillLevel) { - Users.getPlayer(player).getProfile().modifySkill(skillType, skillLevel); - } - - /** - * Sets the level of a player in a specific skill type. - *
- * This function is designed for API usage. - * - * @param player The player to set the level of - * @param skillType The skill to set the level for - * @param skillLevel The value to set the level to - */ - public static void setLevel(Player player, String skillType, int skillLevel) { - Users.getPlayer(player).getProfile().modifySkill(SkillType.getSkill(skillType), skillLevel); - } - - /** - * Sets the XP of a player in a specific skill type. - *
- * This function is designed for API usage. - * - * @param player The player to set the XP of - * @param skillType The skill to set the XP for - * @param newValue The value to set the XP to - * @deprecated Use {@link #setXP(Player, String, int)} instead - */ - @Deprecated - public static void setXP(Player player, SkillType skillType, int newValue) { - Users.getPlayer(player).getProfile().setSkillXpLevel(skillType, newValue); - } - - /** - * Sets the XP of a player in a specific skill type. - *
- * This function is designed for API usage. - * - * @param player The player to set the XP of - * @param skillType The skill to set the XP for - * @param newValue The value to set the XP to - */ - public static void setXP(Player player, String skillType, int newValue) { - Users.getPlayer(player).getProfile().setSkillXpLevel(SkillType.getSkill(skillType), newValue); - } - - /** - * Removes XP from a player in a specific skill type. - *
- * This function is designed for API usage. - * - * @param player The player to change the XP of - * @param skillType The skill to change the XP for - * @param xp The amount of XP to remove - * @deprecated Use {@link #removeXP(Player, String, int)} instead - */ - @Deprecated - public static void removeXP(Player player, SkillType skillType, int xp) { - Users.getPlayer(player).getProfile().removeXp(skillType, xp); - } - - /** - * Removes XP from a player in a specific skill type. - *
- * This function is designed for API usage. - * - * @param player The player to change the XP of - * @param skillType The skill to change the XP for - * @param xp The amount of XP to remove - */ - public static void removeXP(Player player, String skillType, int xp) { - Users.getPlayer(player).getProfile().removeXp(SkillType.getSkill(skillType), xp); - } -} +package com.gmail.nossr50.api; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public final class ExperienceAPI { + private ExperienceAPI() {} + + /** + * Adds raw XP to the player. + *
+ * This function is designed for API usage. + * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @deprecated Use {@link #addRawXP(Player, String, int)} instead + */ + @Deprecated + public static void addRawXP(Player player, SkillType skillType, int XP) { + UserManager.getPlayer(player).applyXpGain(skillType, XP); + } + + /** + * Adds raw XP to the player. + *
+ * This function is designed for API usage. + * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + */ + public static void addRawXP(Player player, String skillType, int XP) { + UserManager.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), XP); + } + + /** + * Adds XP to the player, calculates for XP Rate only. + *
+ * This function is designed for API usage. + * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @deprecated Use {@link #addMultipliedXP(Player, String, int)} instead + */ + @Deprecated + public static void addMultipliedXP(Player player, SkillType skillType, int XP) { + UserManager.getPlayer(player).applyXpGain(skillType, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier())); + } + + /** + * Adds XP to the player, calculates for XP Rate only. + *
+ * This function is designed for API usage. + * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + */ + public static void addMultipliedXP(Player player, String skillType, int XP) { + UserManager.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier())); + } + + /** + * Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party. + *
+ * This function is designed for API usage. + * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @deprecated Use {@link #addXP(Player, String, int)} instead + */ + @Deprecated + public static void addXP(Player player, SkillType skillType, int XP) { + UserManager.getPlayer(player).beginXpGain(skillType, XP); + } + + /** + * Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party. + *
+ * This function is designed for API usage. + * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + */ + public static void addXP(Player player, String skillType, int XP) { + UserManager.getPlayer(player).beginXpGain(SkillType.getSkill(skillType), XP); + } + + /** + * Get the amount of XP a player has in a specific skill. + *
+ * This function is designed for API usage. + * + * @param player The player to get XP for + * @param skillType The skill to get XP for + * @return the amount of XP in a given skill + * @deprecated Use {@link #getXP(Player, String)} instead + */ + @Deprecated + public static int getXP(Player player, SkillType skillType) { + return UserManager.getPlayer(player).getProfile().getSkillXpLevel(skillType); + } + + /** + * Get the amount of XP a player has in a specific skill. + *
+ * This function is designed for API usage. + * + * @param player The player to get XP for + * @param skillType The skill to get XP for + * @return the amount of XP in a given skill + */ + public static int getXP(Player player, String skillType) { + return UserManager.getPlayer(player).getProfile().getSkillXpLevel(SkillType.getSkill(skillType)); + } + + /** + * Get the amount of XP left before leveling up. + *
+ * This function is designed for API usage. + * + * @param player The player to get the XP amount for + * @param skillType The skill to get the XP amount for + * @return the amount of XP left before leveling up a specifc skill + * @deprecated Use {@link #getXPToNextLevel(Player, String)} instead + */ + @Deprecated + public static int getXPToNextLevel(Player player, SkillType skillType) { + return UserManager.getPlayer(player).getProfile().getXpToLevel(skillType); + } + + /** + * Get the amount of XP left before leveling up. + *
+ * This function is designed for API usage. + * + * @param player The player to get the XP amount for + * @param skillType The skill to get the XP amount for + * @return the amount of XP left before leveling up a specifc skill + */ + public static int getXPToNextLevel(Player player, String skillType) { + return UserManager.getPlayer(player).getProfile().getXpToLevel(SkillType.getSkill(skillType)); + } + + /** + * Add levels to a skill. + *
+ * This function is designed for API usage. + * + * @param player The player to add levels to + * @param skillType Type of skill to add levels to + * @param levels Number of levels to add + * @param notify Unused argument + * @deprecated Use addLevel(Player, SKillType, int) instead + */ + public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) { + UserManager.getProfile(player).addLevels(skillType, levels); + + if (notify) { + checkXP(player, skillType); + } + } + + /** + * Add levels to a skill. + *
+ * This function is designed for API usage. + * + * @param player The player to add levels to + * @param skillType Type of skill to add levels to + * @param levels Number of levels to add + * @deprecated Use {@link #addLevel(Player, String, int)} instead + */ + @Deprecated + public static void addLevel(Player player, SkillType skillType, int levels) { + UserManager.getPlayer(player).getProfile().addLevels(skillType, levels); + } + + /** + * Add levels to a skill. + *
+ * This function is designed for API usage. + * + * @param player The player to add levels to + * @param skillType Type of skill to add levels to + * @param levels Number of levels to add + */ + public static void addLevel(Player player, String skillType, int levels) { + UserManager.getPlayer(player).getProfile().addLevels(SkillType.getSkill(skillType), levels); + } + + /** + * Get the level a player has in a specific skill. + *
+ * This function is designed for API usage. + * + * @param player The player to get the level for + * @param skillType The skill to get the level for + * @return the level of a given skill + * @deprecated Use {@link #getLevel(Player, String)} instead + */ + @Deprecated + public static int getLevel(Player player, SkillType skillType) { + return UserManager.getPlayer(player).getProfile().getSkillLevel(skillType); + } + + /** + * Get the level a player has in a specific skill. + *
+ * This function is designed for API usage. + * + * @param player The player to get the level for + * @param skillType The skill to get the level for + * @return the level of a given skill + */ + public static int getLevel(Player player, String skillType) { + return UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.getSkill(skillType)); + } + + /** + * Gets the power level of a player. + *
+ * This function is designed for API usage. + * + * @param player The player to get the power level for + * @return the power level of the player + */ + public static int getPowerLevel(Player player) { + return UserManager.getPlayer(player).getPowerLevel(); + } + + /** + * Sets the level of a player in a specific skill type. + *
+ * This function is designed for API usage. + * + * @param player The player to set the level of + * @param skillType The skill to set the level for + * @param skillLevel The value to set the level to + * @deprecated Use {@link #setLevel(Player, String, int)} instead + */ + @Deprecated + public static void setLevel(Player player, SkillType skillType, int skillLevel) { + UserManager.getPlayer(player).getProfile().modifySkill(skillType, skillLevel); + } + + /** + * Sets the level of a player in a specific skill type. + *
+ * This function is designed for API usage. + * + * @param player The player to set the level of + * @param skillType The skill to set the level for + * @param skillLevel The value to set the level to + */ + public static void setLevel(Player player, String skillType, int skillLevel) { + UserManager.getPlayer(player).getProfile().modifySkill(SkillType.getSkill(skillType), skillLevel); + } + + /** + * Sets the XP of a player in a specific skill type. + *
+ * This function is designed for API usage. + * + * @param player The player to set the XP of + * @param skillType The skill to set the XP for + * @param newValue The value to set the XP to + * @deprecated Use {@link #setXP(Player, String, int)} instead + */ + @Deprecated + public static void setXP(Player player, SkillType skillType, int newValue) { + UserManager.getPlayer(player).getProfile().setSkillXpLevel(skillType, newValue); + } + + /** + * Sets the XP of a player in a specific skill type. + *
+ * This function is designed for API usage. + * + * @param player The player to set the XP of + * @param skillType The skill to set the XP for + * @param newValue The value to set the XP to + */ + public static void setXP(Player player, String skillType, int newValue) { + UserManager.getPlayer(player).getProfile().setSkillXpLevel(SkillType.getSkill(skillType), newValue); + } + + /** + * Removes XP from a player in a specific skill type. + *
+ * This function is designed for API usage. + * + * @param player The player to change the XP of + * @param skillType The skill to change the XP for + * @param xp The amount of XP to remove + * @deprecated Use {@link #removeXP(Player, String, int)} instead + */ + @Deprecated + public static void removeXP(Player player, SkillType skillType, int xp) { + UserManager.getPlayer(player).getProfile().removeXp(skillType, xp); + } + + /** + * Removes XP from a player in a specific skill type. + *
+ * This function is designed for API usage. + * + * @param player The player to change the XP of + * @param skillType The skill to change the XP for + * @param xp The amount of XP to remove + */ + public static void removeXP(Player player, String skillType, int xp) { + UserManager.getPlayer(player).getProfile().removeXp(SkillType.getSkill(skillType), xp); + } + + /** + * Check the XP of a player. This should be called after giving XP to process level-ups. + * + * @param player The player to check + * @param skillType The skill to check + * @deprecated Calling this function is no longer needed and should be avoided + */ + @Deprecated + private static void checkXP(Player player, SkillType skillType) { + SkillUtils.xpCheckSkill(skillType, player, UserManager.getProfile(player)); + } +} diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index b8c540e14..e0c83c36e 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -1,174 +1,174 @@ -package com.gmail.nossr50.api; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public final class PartyAPI { - private PartyAPI() {} - - /** - * Get the name of the party a player is in. - *
- * This function is designed for API usage. - * - * @param player The player to check the party name of - * @return the name of the player's party - */ - public static String getPartyName(Player player) { - return Users.getPlayer(player).getParty().getName(); - } - - /** - * Checks if a player is in a party. - *
- * This function is designed for API usage. - * - * @param player The player to check - * @return true if the player is in a party, false otherwise - */ - public static boolean inParty(Player player) { - return Users.getPlayer(player).inParty(); - } - - /** - * Check if two players are in the same party. - *
- * This function is designed for API usage. - * - * @param playera The first player to check - * @param playerb The second player to check - * @return true if the two players are in the same party, false otherwise - */ - public static boolean inSameParty(Player playera, Player playerb) { - return PartyManager.inSameParty(playera, playerb); - } - - /** - * Get a list of all current parties. - *
- * This function is designed for API usage. - * - * @return the list of parties. - */ - public static List getParties() { - return PartyManager.getParties(); - } - - /** - * Add a player to a party. - *
- * This function is designed for API usage. - * - * @param player The player to add to the party - * @param partyName The party to add the player to - */ - public static void addToParty(Player player, String partyName) { - Party party = PartyManager.getParty(partyName); - - if (party == null) { - party = new Party(); - party.setName(partyName); - party.setLeader(player.getName()); - } - - PartyManager.addToParty(player, Users.getPlayer(player), party); - } - - /** - * Remove a player from a party. - *
- * This function is designed for API usage. - * - * @param player The player to remove - */ - public static void removeFromParty(Player player) { - PartyManager.removeFromParty(player, Users.getPlayer(player).getParty()); - } - - /** - * Get the leader of a party. - *
- * This function is designed for API usage. - * - * @param partyName The party name - * @return the leader of the party - */ - public static String getPartyLeader(String partyName) { - return PartyManager.getPartyLeader(partyName); - } - - /** - * Set the leader of a party. - *
- * This function is designed for API usage. - * - * @param partyName The name of the party to set the leader of - * @param player The player to set as leader - */ - public static void setPartyLeader(String partyName, String player) { - PartyManager.setPartyLeader(player, PartyManager.getParty(partyName)); - } - - /** - * Get a list of all players in this player's party. - *
- * This function is designed for API usage. - * - * @param player The player to check - * @return all the players in the player's party - * @deprecated - */ - @Deprecated - public static List getAllMembers(Player player) { - List memberNames = new ArrayList(); - - for (OfflinePlayer member : PartyManager.getAllMembers(player)) { - memberNames.add(member.getName()); - } - - return memberNames; - } - - /** - * Get a list of all players in this player's party. - *
- * This function is designed for API usage. - * - * @param player The player to check - * @return all the players in the player's party - */ - public static List getOnlineAndOfflineMembers(Player player) { - return PartyManager.getAllMembers(player); - } - - /** - * Get a list of all online players in this party. - *
- * This function is designed for API usage. - * - * @param partyName The party to check - * @return all online players in this party - */ - public static List getOnlineMembers(String partyName) { - return PartyManager.getOnlineMembers(partyName); - } - - /** - * Get a list of all online players in this player's party. - *
- * This function is designed for API usage. - * - * @param player The player to check - * @return all online players in the player's party - */ - public static List getOnlineMembers(Player player) { - return PartyManager.getOnlineMembers(player); - } -} +package com.gmail.nossr50.api; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public final class PartyAPI { + private PartyAPI() {} + + /** + * Get the name of the party a player is in. + *
+ * This function is designed for API usage. + * + * @param player The player to check the party name of + * @return the name of the player's party + */ + public static String getPartyName(Player player) { + return UserManager.getPlayer(player).getParty().getName(); + } + + /** + * Checks if a player is in a party. + *
+ * This function is designed for API usage. + * + * @param player The player to check + * @return true if the player is in a party, false otherwise + */ + public static boolean inParty(Player player) { + return UserManager.getPlayer(player).inParty(); + } + + /** + * Check if two players are in the same party. + *
+ * This function is designed for API usage. + * + * @param playera The first player to check + * @param playerb The second player to check + * @return true if the two players are in the same party, false otherwise + */ + public static boolean inSameParty(Player playera, Player playerb) { + return PartyManager.inSameParty(playera, playerb); + } + + /** + * Get a list of all current parties. + *
+ * This function is designed for API usage. + * + * @return the list of parties. + */ + public static List getParties() { + return PartyManager.getParties(); + } + + /** + * Add a player to a party. + *
+ * This function is designed for API usage. + * + * @param player The player to add to the party + * @param partyName The party to add the player to + */ + public static void addToParty(Player player, String partyName) { + Party party = PartyManager.getParty(partyName); + + if (party == null) { + party = new Party(); + party.setName(partyName); + party.setLeader(player.getName()); + } + + PartyManager.addToParty(player, UserManager.getPlayer(player), party); + } + + /** + * Remove a player from a party. + *
+ * This function is designed for API usage. + * + * @param player The player to remove + */ + public static void removeFromParty(Player player) { + PartyManager.removeFromParty(player, UserManager.getPlayer(player).getParty()); + } + + /** + * Get the leader of a party. + *
+ * This function is designed for API usage. + * + * @param partyName The party name + * @return the leader of the party + */ + public static String getPartyLeader(String partyName) { + return PartyManager.getPartyLeader(partyName); + } + + /** + * Set the leader of a party. + *
+ * This function is designed for API usage. + * + * @param partyName The name of the party to set the leader of + * @param player The player to set as leader + */ + public static void setPartyLeader(String partyName, String player) { + PartyManager.setPartyLeader(player, PartyManager.getParty(partyName)); + } + + /** + * Get a list of all players in this player's party. + *
+ * This function is designed for API usage. + * + * @param player The player to check + * @return all the players in the player's party + * @deprecated + */ + @Deprecated + public static List getAllMembers(Player player) { + List memberNames = new ArrayList(); + + for (OfflinePlayer member : PartyManager.getAllMembers(player)) { + memberNames.add(member.getName()); + } + + return memberNames; + } + + /** + * Get a list of all players in this player's party. + *
+ * This function is designed for API usage. + * + * @param player The player to check + * @return all the players in the player's party + */ + public static List getOnlineAndOfflineMembers(Player player) { + return PartyManager.getAllMembers(player); + } + + /** + * Get a list of all online players in this party. + *
+ * This function is designed for API usage. + * + * @param partyName The party to check + * @return all online players in this party + */ + public static List getOnlineMembers(String partyName) { + return PartyManager.getOnlineMembers(partyName); + } + + /** + * Get a list of all online players in this player's party. + *
+ * This function is designed for API usage. + * + * @param player The player to check + * @return all online players in the player's party + */ + public static List getOnlineMembers(Player player) { + return PartyManager.getOnlineMembers(player); + } +} diff --git a/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java b/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java index dfb3b3df9..f7231bd95 100644 --- a/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java +++ b/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java @@ -1,28 +1,29 @@ -package com.gmail.nossr50.api; - -import org.bukkit.entity.Player; - -import com.gmail.nossr50.spout.SpoutConfig; -import com.gmail.nossr50.spout.huds.HudType; -import com.gmail.nossr50.util.Users; - -public class SpoutHudAPI { - - /** - * Disable the mcMMO XP bar for a player. - *
- * This function is designed for API usage. - */ - public static void disableXpBar(Player player) { - Users.getPlayer(player).getProfile().setHudType(HudType.DISABLED); - } - - /** - * Disable the mcMMO XP bar for the server. - *
- * This function is designed for API usage. - */ - public static void disableXpBar() { - SpoutConfig.getInstance().setXPBarEnabled(false); - } -} +package com.gmail.nossr50.api; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.spout.SpoutConfig; +import com.gmail.nossr50.datatypes.spout.huds.HudType; +import com.gmail.nossr50.util.player.UserManager; + +public class SpoutHudAPI { + private SpoutHudAPI() {} + + /** + * Disable the mcMMO XP bar for a player. + *
+ * This function is designed for API usage. + */ + public static void disableXpBar(Player player) { + UserManager.getPlayer(player).getProfile().setHudType(HudType.DISABLED); + } + + /** + * Disable the mcMMO XP bar for the server. + *
+ * This function is designed for API usage. + */ + public static void disableXpBar() { + SpoutConfig.getInstance().setXPBarEnabled(false); + } +} diff --git a/src/main/java/com/gmail/nossr50/api/SpoutToolsAPI.java b/src/main/java/com/gmail/nossr50/api/SpoutToolsAPI.java index 732c6c383..f737aee85 100644 --- a/src/main/java/com/gmail/nossr50/api/SpoutToolsAPI.java +++ b/src/main/java/com/gmail/nossr50/api/SpoutToolsAPI.java @@ -1,53 +1,53 @@ -package com.gmail.nossr50.api; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.skills.utilities.ToolType; - -public final class SpoutToolsAPI { - public static final List spoutSwords = new ArrayList(); - public static final List spoutAxes = new ArrayList(); - public static final List spoutPickaxes = new ArrayList(); - public static final List spoutHoes = new ArrayList(); - public static final List spoutShovels = new ArrayList(); - - private SpoutToolsAPI() {} - - /** - * Add a custom Spout tool to mcMMO for XP gain & ability use. - *
- * This function is designed for API usage. - * - * @param spoutTool The tool to add - * @param type The type of tool to add - */ - public static void addCustomTool(ItemStack spoutTool, ToolType type) { - switch (type) { - case AXE: - spoutAxes.add(spoutTool); - break; - - case HOE: - spoutHoes.add(spoutTool); - break; - - case PICKAXE: - spoutPickaxes.add(spoutTool); - break; - - case SHOVEL: - spoutShovels.add(spoutTool); - break; - - case SWORD: - spoutSwords.add(spoutTool); - break; - - default: - break; - } - } -} +package com.gmail.nossr50.api; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.datatypes.skills.ToolType; + +public final class SpoutToolsAPI { + public static final List spoutSwords = new ArrayList(); + public static final List spoutAxes = new ArrayList(); + public static final List spoutPickaxes = new ArrayList(); + public static final List spoutHoes = new ArrayList(); + public static final List spoutShovels = new ArrayList(); + + private SpoutToolsAPI() {} + + /** + * Add a custom Spout tool to mcMMO for XP gain & ability use. + *
+ * This function is designed for API usage. + * + * @param spoutTool The tool to add + * @param type The type of tool to add + */ + public static void addCustomTool(ItemStack spoutTool, ToolType type) { + switch (type) { + case AXE: + spoutAxes.add(spoutTool); + break; + + case HOE: + spoutHoes.add(spoutTool); + break; + + case PICKAXE: + spoutPickaxes.add(spoutTool); + break; + + case SHOVEL: + spoutShovels.add(spoutTool); + break; + + case SWORD: + spoutSwords.add(spoutTool); + break; + + default: + break; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/chat/ChatManager.java b/src/main/java/com/gmail/nossr50/chat/ChatManager.java index 989d5feca..551375786 100644 --- a/src/main/java/com/gmail/nossr50/chat/ChatManager.java +++ b/src/main/java/com/gmail/nossr50/chat/ChatManager.java @@ -1,74 +1,78 @@ -package com.gmail.nossr50.chat; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; -import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; - -public final class ChatManager { - public ChatManager () {} - - public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) { - McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync); - mcMMO.p.getServer().getPluginManager().callEvent(chatEvent); - - if (chatEvent.isCancelled()) { - return; - } - - if(Config.getInstance().getAdminDisplayNames()) - displayName = chatEvent.getDisplayName(); - else - displayName = chatEvent.getSender(); - - String adminMessage = chatEvent.getMessage(); - - mcMMO.p.getServer().broadcast(LocaleLoader.getString("Commands.AdminChat.Prefix", displayName) + adminMessage, "mcmmo.chat.adminchat"); - } - - public static void handleAdminChat(Plugin plugin, String senderName, String message) { - handleAdminChat(plugin, senderName, senderName, message); - } - - public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) { - handleAdminChat(plugin, playerName, displayName, message, false); - } - - public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message, boolean isAsync) { - String partyName = party.getName(); - - McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message, isAsync); - mcMMO.p.getServer().getPluginManager().callEvent(chatEvent); - - if (chatEvent.isCancelled()) { - return; - } - - if(Config.getInstance().getPartyDisplayNames()) - displayName = chatEvent.getDisplayName(); - else - displayName = chatEvent.getSender(); - - String partyMessage = chatEvent.getMessage(); - - for (Player member : party.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", displayName) + partyMessage); - } - - mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + ChatColor.stripColor(displayName) + "> " + partyMessage); - } - - public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) { - handlePartyChat(plugin, party, senderName, senderName, message); - } - - public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) { - handlePartyChat(plugin, party, playerName, displayName, message, false); - } +package com.gmail.nossr50.chat; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; +import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; +import com.gmail.nossr50.locale.LocaleLoader; + +public final class ChatManager { + public ChatManager () {} + + public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) { + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync); + mcMMO.p.getServer().getPluginManager().callEvent(chatEvent); + + if (chatEvent.isCancelled()) { + return; + } + + if (Config.getInstance().getAdminDisplayNames()) { + displayName = chatEvent.getDisplayName(); + } + else { + displayName = chatEvent.getSender(); + } + + String adminMessage = chatEvent.getMessage(); + + mcMMO.p.getServer().broadcast(LocaleLoader.getString("Commands.AdminChat.Prefix", displayName) + adminMessage, "mcmmo.chat.adminchat"); + } + + public static void handleAdminChat(Plugin plugin, String senderName, String message) { + handleAdminChat(plugin, senderName, senderName, message); + } + + public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) { + handleAdminChat(plugin, playerName, displayName, message, false); + } + + public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message, boolean isAsync) { + String partyName = party.getName(); + + McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message, isAsync); + mcMMO.p.getServer().getPluginManager().callEvent(chatEvent); + + if (chatEvent.isCancelled()) { + return; + } + + if (Config.getInstance().getPartyDisplayNames()) { + displayName = chatEvent.getDisplayName(); + } + else { + displayName = chatEvent.getSender(); + } + + String partyMessage = chatEvent.getMessage(); + + for (Player member : party.getOnlineMembers()) { + member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", displayName) + partyMessage); + } + + mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + ChatColor.stripColor(displayName) + "> " + partyMessage); + } + + public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) { + handlePartyChat(plugin, party, senderName, senderName, message); + } + + public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) { + handlePartyChat(plugin, party, playerName, displayName, message, false); + } } diff --git a/src/main/java/com/gmail/nossr50/chat/ChatMode.java b/src/main/java/com/gmail/nossr50/chat/ChatMode.java index 5cf18a10b..ff2ebc368 100644 --- a/src/main/java/com/gmail/nossr50/chat/ChatMode.java +++ b/src/main/java/com/gmail/nossr50/chat/ChatMode.java @@ -1,70 +1,70 @@ -package com.gmail.nossr50.chat; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; - -public enum ChatMode { - ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")), - PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off")); - - private String enabledMessage; - private String disabledMessage; - - private ChatMode (String enabledMessage, String disabledMessage) { - this.enabledMessage = enabledMessage; - this.disabledMessage = disabledMessage; - } - - public boolean isEnabled(McMMOPlayer mcMMOPlayer) { - switch (this) { - case ADMIN: - return mcMMOPlayer.getAdminChatMode(); - - case PARTY: - return mcMMOPlayer.getPartyChatMode(); - - default: - return false; - } - } - - public void disable(McMMOPlayer mcMMOPlayer) { - switch (this) { - case ADMIN: - mcMMOPlayer.setAdminChat(false); - return; - - case PARTY: - mcMMOPlayer.setPartyChat(false); - return; - - default: - return; - } - } - - public void enable(McMMOPlayer mcMMOPlayer) { - switch (this) { - case ADMIN: - mcMMOPlayer.setAdminChat(true); - mcMMOPlayer.setPartyChat(false); - return; - - case PARTY: - mcMMOPlayer.setPartyChat(true); - mcMMOPlayer.setAdminChat(false); - return; - - default: - return; - } - } - - public String getEnabledMessage() { - return enabledMessage; - } - - public String getDisabledMessage() { - return disabledMessage; - } -} +package com.gmail.nossr50.chat; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; + +public enum ChatMode { + ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")), + PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off")); + + private String enabledMessage; + private String disabledMessage; + + private ChatMode(String enabledMessage, String disabledMessage) { + this.enabledMessage = enabledMessage; + this.disabledMessage = disabledMessage; + } + + public boolean isEnabled(McMMOPlayer mcMMOPlayer) { + switch (this) { + case ADMIN: + return mcMMOPlayer.getAdminChatMode(); + + case PARTY: + return mcMMOPlayer.getPartyChatMode(); + + default: + return false; + } + } + + public void disable(McMMOPlayer mcMMOPlayer) { + switch (this) { + case ADMIN: + mcMMOPlayer.setAdminChat(false); + return; + + case PARTY: + mcMMOPlayer.setPartyChat(false); + return; + + default: + return; + } + } + + public void enable(McMMOPlayer mcMMOPlayer) { + switch (this) { + case ADMIN: + mcMMOPlayer.setAdminChat(true); + mcMMOPlayer.setPartyChat(false); + return; + + case PARTY: + mcMMOPlayer.setPartyChat(true); + mcMMOPlayer.setAdminChat(false); + return; + + default: + return; + } + } + + public String getEnabledMessage() { + return enabledMessage; + } + + public String getDisabledMessage() { + return disabledMessage; + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java b/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java new file mode 100644 index 000000000..69016d96a --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java @@ -0,0 +1,80 @@ +package com.gmail.nossr50.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; + +public class McabilityCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + PlayerProfile profile; + + switch (args.length) { + case 0: + if (!Permissions.mcability(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + profile = UserManager.getPlayer((Player) sender).getProfile(); + + if (profile.getAbilityUse()) { + sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off")); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Ability.On")); + } + + profile.toggleAbilityUse(); + return true; + + case 1: + if (!Permissions.mcabilityOthers(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + + if (mcMMOPlayer == null) { + profile = new PlayerProfile(args[0], false); + + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + return true; + } + + Player player = mcMMOPlayer.getPlayer(); + profile = mcMMOPlayer.getProfile(); + + if (!player.isOnline()) { + sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + return true; + } + + if (profile.getAbilityUse()) { + player.sendMessage(LocaleLoader.getString("Commands.Ability.Off")); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.Ability.On")); + } + + profile.toggleAbilityUse(); + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/McgodCommand.java b/src/main/java/com/gmail/nossr50/commands/McgodCommand.java new file mode 100644 index 000000000..10ea58a24 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/McgodCommand.java @@ -0,0 +1,89 @@ +package com.gmail.nossr50.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; + +public class McgodCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + PlayerProfile profile; + + switch (args.length) { + case 0: + if (!Permissions.mcgod(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (!(sender instanceof Player)) { + return false; + } + + profile = UserManager.getPlayer((Player) sender).getProfile(); + + if (profile == null) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + if (profile.getGodMode()) { + sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled")); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled")); + } + + profile.toggleGodMode(); + return true; + + case 1: + if (!Permissions.mcgodOthers(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + + if (mcMMOPlayer == null) { + profile = new PlayerProfile(args[0], false); + + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + return true; + } + + profile = mcMMOPlayer.getProfile(); + Player player = mcMMOPlayer.getPlayer(); + + if (!player.isOnline()) { + sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + return true; + } + + if (profile.getGodMode()) { + player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled")); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled")); + } + + profile.toggleGodMode(); + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java b/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java similarity index 67% rename from src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java rename to src/main/java/com/gmail/nossr50/commands/McmmoCommand.java index 5bba02af3..e5a17549b 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java @@ -1,114 +1,113 @@ -package com.gmail.nossr50.commands.player; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.getspout.spoutapi.player.SpoutPlayer; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.commands.PartySubcommandType; -import com.gmail.nossr50.util.Permissions; - -public class McmmoCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - - switch (args.length) { - case 0: - if (!Permissions.mcmmoDescription(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - String description = LocaleLoader.getString("mcMMO.Description"); - String[] mcSplit = description.split(","); - sender.sendMessage(mcSplit); - - if (Config.getInstance().getDonateMessageEnabled()) { - if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) { - SpoutPlayer spoutPlayer = (SpoutPlayer) sender; - spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND); - } - - sender.sendMessage(LocaleLoader.getString("MOTD.Donate")); - sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal"); - } - - sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion())); - return true; - - case 1: - if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) { - if (!Permissions.mcmmoHelp(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header")); - displayPartyCommands(sender); - displayOtherCommands(sender); - - } - return true; - - default: - return false; - } - } - - private void displayPartyCommands(CommandSender sender) { - if (Permissions.party(sender)) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands")); - sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1")); - sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2")); - sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit")); - - if (Permissions.partyChat(sender)) { - sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle")); - } - - sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite")); - sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept")); - - if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) { - sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport")); - } - } - } - - private void displayOtherCommands(CommandSender sender) { - sender.sendMessage(LocaleLoader.getString("Commands.Other")); - sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats")); - sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards")); - - if (Permissions.skillreset(sender)) { - sender.sendMessage("/skillreset " + LocaleLoader.getString("Commands.Reset")); - } - - if (Permissions.mcability(sender)) { - sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility")); - } - - if (Permissions.adminChat(sender)) { - sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle")); - } - - if (Permissions.inspect(sender)) { - sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect")); - } - - if (Permissions.mmoedit(sender)) { - sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit")); - } - - if (Permissions.mcgod(sender)) { - sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod")); - } - - sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo")); - } -} +package com.gmail.nossr50.commands; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.getspout.spoutapi.player.SpoutPlayer; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.commands.party.PartySubcommandType; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; + +public class McmmoCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 0: + if (!Permissions.mcmmoDescription(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + String description = LocaleLoader.getString("mcMMO.Description"); + String[] mcSplit = description.split(","); + sender.sendMessage(mcSplit); + + if (Config.getInstance().getDonateMessageEnabled()) { + if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) { + SpoutPlayer spoutPlayer = (SpoutPlayer) sender; + spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND); + } + + sender.sendMessage(LocaleLoader.getString("MOTD.Donate")); + sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal"); + } + + sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion())); + return true; + + case 1: + if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) { + if (!Permissions.mcmmoHelp(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header")); + displayPartyCommands(sender); + displayOtherCommands(sender); + + } + return true; + + default: + return false; + } + } + + private void displayPartyCommands(CommandSender sender) { + if (Permissions.party(sender)) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands")); + sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1")); + sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2")); + sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit")); + + if (Permissions.partyChat(sender)) { + sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle")); + } + + sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite")); + sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept")); + + if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) { + sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport")); + } + } + } + + private void displayOtherCommands(CommandSender sender) { + sender.sendMessage(LocaleLoader.getString("Commands.Other")); + sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats")); + sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards")); + + if (Permissions.skillreset(sender)) { + sender.sendMessage("/skillreset " + LocaleLoader.getString("Commands.Reset")); + } + + if (Permissions.mcability(sender)) { + sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility")); + } + + if (Permissions.adminChat(sender)) { + sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle")); + } + + if (Permissions.inspect(sender)) { + sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect")); + } + + if (Permissions.mmoedit(sender)) { + sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit")); + } + + if (Permissions.mcgod(sender)) { + sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod")); + } + + sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo")); + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java new file mode 100644 index 000000000..da3a42dcd --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java @@ -0,0 +1,33 @@ +package com.gmail.nossr50.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.player.UserManager; + +public class McnotifyCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 0: + PlayerProfile profile = UserManager.getPlayer((Player) sender).getProfile(); + + if (profile.useChatNotifications()) { + sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off")); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On")); + } + + profile.toggleChatNotifications(); + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java b/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java new file mode 100644 index 000000000..2ca351d4e --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java @@ -0,0 +1,80 @@ +package com.gmail.nossr50.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; + +public class McrefreshCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + PlayerProfile profile; + + switch (args.length) { + case 0: + if (!Permissions.mcrefresh(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (!(sender instanceof Player)) { + return false; + } + + profile = UserManager.getPlayer(sender.getName()).getProfile(); + + profile.setRecentlyHurt(0); + profile.resetCooldowns(); + profile.resetToolPrepMode(); + profile.resetAbilityMode(); + + sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); + return true; + + case 1: + if (!Permissions.mcrefreshOthers(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + + if (mcMMOPlayer == null) { + profile = new PlayerProfile(args[0], false); + + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + return true; + } + profile = mcMMOPlayer.getProfile(); + Player player = mcMMOPlayer.getPlayer(); + + if (!player.isOnline()) { + sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + return true; + } + + profile.setRecentlyHurt(0); + profile.resetCooldowns(); + profile.resetToolPrepMode(); + profile.resetAbilityMode(); + + player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); + sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0])); + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java new file mode 100644 index 000000000..50e9e7c34 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java @@ -0,0 +1,69 @@ +package com.gmail.nossr50.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; + +public class XprateCommand implements CommandExecutor { + private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier(); + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 1: + if (!args[0].equalsIgnoreCase("reset")) { + return false; + } + + if (!Permissions.xprateReset(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (mcMMO.p.isXPEventEnabled()) { + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over")); + mcMMO.p.toggleXpEventEnabled(); + } + + Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate); + return true; + + case 2: + if (!StringUtils.isInt(args[0])) { + return false; + } + + if (!Permissions.xprateSet(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) { + return false; + } + + mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1])); + int newXpRate = Integer.parseInt(args[0]); + Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate); + + if (mcMMO.p.isXPEventEnabled()) { + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0")); + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate)); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate)); + } + + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java deleted file mode 100644 index c4a295b79..000000000 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; - -public class AddlevelsCommand implements CommandExecutor{ - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - int levels; - boolean allSkills = false; - SkillType skill = null; - - switch (args.length) { - case 2: - if (!Permissions.addlevels(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (!(sender instanceof Player)) { - return false; - } - - if (args[0].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillTools.isSkill(args[0])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } - - if (!StringUtils.isInt(args[1])) { - return false; - } - - levels = Integer.parseInt(args[1]); - profile = Users.getPlayer((Player) sender).getProfile(); - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - profile.addLevels(skillType, levels); - } - } - else { - skill = SkillType.getSkill(args[0]); - profile.addLevels(skill, levels); - } - - if (allSkills) { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels)); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill))); - } - - return true; - - case 3: - if (!Permissions.addlevelsOthers(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (args[1].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillTools.isSkill(args[1])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } - - if (!StringUtils.isInt(args[2])) { - return false; - } - - McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); - levels = Integer.parseInt(args[2]); - - // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. - if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); - - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - profile.addLevels(skillType, levels); - } - } - else { - skill = SkillType.getSkill(args[1]); - profile.addLevels(skill, levels); - } - - profile.save(); // Since this is a temporary profile, we save it here. - } - else { - profile = mcMMOPlayer.getProfile(); - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - profile.addLevels(skillType, levels); - } - - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels)); - } - else { - skill = SkillType.getSkill(args[1]); - profile.addLevels(skill, levels); - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill))); - } - } - - if (allSkills) { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0])); - } - - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java deleted file mode 100644 index 0e53ef5dd..000000000 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; - -public class AddxpCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - int xp; - McMMOPlayer mcMMOPlayer; - PlayerProfile profile; - boolean allSkills = false; - SkillType skill = null; - - switch (args.length) { - case 2: - if (!Permissions.addxp(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (!(sender instanceof Player)) { - return false; - } - - if (args[0].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillTools.isSkill(args[0])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } - - if (!StringUtils.isInt(args[1])) { - return false; - } - - xp = Integer.parseInt(args[1]); - mcMMOPlayer = Users.getPlayer((Player) sender); - profile = mcMMOPlayer.getProfile(); - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - mcMMOPlayer.applyXpGain(skillType, xp); - } - - sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp)); - } - else { - skill = SkillType.getSkill(args[0]); - - mcMMOPlayer.applyXpGain(skill, xp); - sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill))); - } - - return true; - - case 3: - if (!Permissions.addxpOthers(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (args[1].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillTools.isSkill(args[1])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } - - if (!StringUtils.isInt(args[2])) { - return false; - } - - mcMMOPlayer = Users.getPlayer(args[0]); - xp = Integer.parseInt(args[2]); - - // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. - if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); - - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - // TODO: Currently the offline player doesn't level up automatically - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - profile.setSkillXpLevel(skillType, xp); - } - } - else { - skill = SkillType.getSkill(args[1]); - profile.setSkillXpLevel(skill, xp); - } - - profile.save(); // Since this is a temporary profile, we save it here. - } - else { - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - mcMMOPlayer.applyXpGain(skillType, xp); - } - - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp)); - } - else { - skill = SkillType.getSkill(args[1]); - mcMMOPlayer.applyXpGain(skill, xp); - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill))); - } - } - - if (allSkills) { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0])); - } - - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/admin/HardcoreCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/HardcoreCommand.java deleted file mode 100644 index 500b2b910..000000000 --- a/src/main/java/com/gmail/nossr50/commands/admin/HardcoreCommand.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import java.text.DecimalFormat; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; - -public class HardcoreCommand implements CommandExecutor{ - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - if (!Permissions.hardcoreToggle(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (Config.getInstance().getHardcoreEnabled()) { - disableHardcore(); - } - else { - enableHardcore(); - } - - return true; - - case 1: - if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) { - if (!Permissions.hardcoreToggle(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - enableHardcore(); - return true; - } - - if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) { - if (!Permissions.hardcoreToggle(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - disableHardcore(); - return true; - } - - if (!StringUtils.isDouble(args[0])) { - return false; - } - - if (!Permissions.hardcoreModify(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - DecimalFormat percent = new DecimalFormat("##0.00%"); - double newPercent = Double.parseDouble(args[0]); - - Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent); - sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D))); - return true; - - default: - return false; - } - } - - private void disableHardcore() { - Config.getInstance().setHardcoreEnabled(false); - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled")); - } - - private void enableHardcore() { - Config.getInstance().setHardcoreEnabled(true); - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled")); - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/admin/McgodCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/McgodCommand.java deleted file mode 100644 index 2cc7b61cc..000000000 --- a/src/main/java/com/gmail/nossr50/commands/admin/McgodCommand.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class McgodCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - - switch (args.length) { - case 0: - if (!Permissions.mcgod(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (!(sender instanceof Player)) { - return false; - } - - profile = Users.getPlayer((Player) sender).getProfile(); - - if (profile == null) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - if (profile.getGodMode()) { - sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled")); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled")); - } - - profile.toggleGodMode(); - return true; - - case 1: - if (!Permissions.mcgodOthers(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); - - if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); - - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); - return true; - } - - profile = mcMMOPlayer.getProfile(); - Player player = mcMMOPlayer.getPlayer(); - - if (!player.isOnline()) { - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); - return true; - } - - if (profile.getGodMode()) { - player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled")); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled")); - } - - profile.toggleGodMode(); - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/admin/McrefreshCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/McrefreshCommand.java deleted file mode 100644 index 51455fadc..000000000 --- a/src/main/java/com/gmail/nossr50/commands/admin/McrefreshCommand.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class McrefreshCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - - switch (args.length) { - case 0: - if (!Permissions.mcrefresh(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (!(sender instanceof Player)) { - return false; - } - - profile = Users.getPlayer(sender.getName()).getProfile(); - - profile.setRecentlyHurt(0); - profile.resetCooldowns(); - profile.resetToolPrepMode(); - profile.resetAbilityMode(); - - sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); - return true; - - case 1: - if (!Permissions.mcrefreshOthers(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); - - if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); - - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); - return true; - } - profile = mcMMOPlayer.getProfile(); - Player player = mcMMOPlayer.getPlayer(); - - if (!player.isOnline()) { - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); - return true; - } - - profile.setRecentlyHurt(0); - profile.resetCooldowns(); - profile.resetToolPrepMode(); - profile.resetAbilityMode(); - - player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); - sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0])); - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java deleted file mode 100644 index da4ed8510..000000000 --- a/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; - -public class MmoeditCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - int newValue; - boolean allSkills = false; - SkillType skill = null; - - switch (args.length) { - case 2: - if (!Permissions.mmoedit(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (!(sender instanceof Player)) { - return false; - } - - if (args[0].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillTools.isSkill(args[0])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } - - if (!StringUtils.isInt(args[1])) { - return false; - } - - newValue = Integer.parseInt(args[1]); - profile = Users.getPlayer((Player) sender).getProfile(); - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - profile.modifySkill(skillType, newValue); - } - - sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue)); - } - else { - skill = SkillType.getSkill(args[0]); - profile.modifySkill(skill, newValue); - sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue)); - } - - return true; - - case 3: - if (!Permissions.mmoeditOthers(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (args[1].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillTools.isSkill(args[1])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } - - if (!StringUtils.isInt(args[2])) { - return false; - } - - newValue = Integer.parseInt(args[2]); - McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); - - // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. - if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); - - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - profile.modifySkill(skillType, newValue); - } - } - else { - skill = SkillType.getSkill(args[1]); - profile.modifySkill(skill, newValue); - } - - profile.save(); // Since this is a temporary profile, we save it here. - } - else { - profile = mcMMOPlayer.getProfile(); - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - profile.modifySkill(skillType, newValue); - } - - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue)); - } - else { - skill = SkillType.getSkill(args[1]); - profile.modifySkill(skill, newValue); - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue)); - } - } - - if (allSkills) { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", SkillTools.getSkillName(skill), args[0])); - } - - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java deleted file mode 100644 index 901de47da..000000000 --- a/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class SkillresetCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - boolean allSkills = false; - SkillType skill = null; - String skillName = ""; - - switch (args.length) { - case 1: - if (!Permissions.skillreset(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (!(sender instanceof Player)) { - return false; - } - - if (args[0].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillTools.isSkill(args[0])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } - - profile = Users.getPlayer((Player) sender).getProfile(); - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - if (!Permissions.skillreset(sender, skillType)) { - sender.sendMessage(command.getPermissionMessage()); - continue; - } - - profile.modifySkill(skillType, 0); - } - - sender.sendMessage(LocaleLoader.getString("Commands.Reset.All")); - } - else { - skill = SkillType.getSkill(args[0]); - skillName = SkillTools.getSkillName(skill); - - if (!Permissions.skillreset(sender, skill)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - profile.modifySkill(skill, 0); - sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName)); - } - - return true; - - case 2: - if (!Permissions.skillresetOthers(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (args[1].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillTools.isSkill(args[1])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } - - if (!allSkills) { - skill = SkillType.getSkill(args[1]); - skillName = SkillTools.getSkillName(skill); - - if (!Permissions.skillresetOthers(sender, skill)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - } - - McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); - - // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. - if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); - - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - if (!Permissions.skillresetOthers(sender, skill)) { - sender.sendMessage(command.getPermissionMessage()); - continue; - } - - profile.modifySkill(skillType, 0); - } - } - else { - profile.modifySkill(skill, 0); - } - - profile.save(); // Since this is a temporary profile, we save it here. - } - else { - profile = mcMMOPlayer.getProfile(); - - if (allSkills) { - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - if (!Permissions.skillresetOthers(sender, skillType)) { - sender.sendMessage(command.getPermissionMessage()); - continue; - } - - profile.modifySkill(skillType, 0); - } - - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All")); - } - else { - profile.modifySkill(skill, 0); - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName)); - } - } - - if (allSkills) { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", skillName, args[0])); - } - - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/admin/VampirismCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/VampirismCommand.java deleted file mode 100644 index f4a88303a..000000000 --- a/src/main/java/com/gmail/nossr50/commands/admin/VampirismCommand.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import java.text.DecimalFormat; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; - -public class VampirismCommand implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!Config.getInstance().getHardcoreEnabled()) { - sender.sendMessage(LocaleLoader.getString("Hardcore.Disabled")); - return true; - } - - switch (args.length) { - case 0: - if (!Permissions.vampirismToggle(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (Config.getInstance().getHardcoreVampirismEnabled()) { - disableVampirism(); - } - else { - enableVampirism(); - } - - return true; - - case 1: - if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) { - if (!Permissions.vampirismToggle(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - enableVampirism(); - return true; - } - - if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) { - if (!Permissions.vampirismToggle(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - disableVampirism(); - return true; - } - - if (!StringUtils.isDouble(args[0])) { - return false; - } - - if (!Permissions.vampirismModify(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - DecimalFormat percent = new DecimalFormat("##0.00%"); - double newPercent = Double.parseDouble(args[0]); - - Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent); - sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D))); - return true; - - default: - return false; - } - } - - private void disableVampirism() { - Config.getInstance().setHardcoreVampirismEnabled(false); - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled")); - } - - private void enableVampirism() { - Config.getInstance().setHardcoreVampirismEnabled(true); - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled")); - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java deleted file mode 100644 index f22c53c61..000000000 --- a/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; - -public class XprateCommand implements CommandExecutor { - private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier(); - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - if (!args[0].equalsIgnoreCase("reset")) { - return false; - } - - if (!Permissions.xprateReset(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (mcMMO.p.isXPEventEnabled()) { - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over")); - mcMMO.p.toggleXpEventEnabled(); - } - - Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate); - return true; - - case 2: - if (!StringUtils.isInt(args[0])) { - return false; - } - - if (!Permissions.xprateSet(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) { - return false; - } - - mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1])); - int newXpRate = Integer.parseInt(args[0]); - Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate); - - if (mcMMO.p.isXPEventEnabled()) { - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0")); - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate)); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate)); - } - - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/AdminChatCommand.java similarity index 92% rename from src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java rename to src/main/java/com/gmail/nossr50/commands/chat/AdminChatCommand.java index ccbad7c99..9842c2cb2 100644 --- a/src/main/java/com/gmail/nossr50/chat/commands/AdminChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/AdminChatCommand.java @@ -1,26 +1,26 @@ -package com.gmail.nossr50.chat.commands; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.chat.ChatManager; -import com.gmail.nossr50.chat.ChatMode; -import com.gmail.nossr50.locale.LocaleLoader; - -public class AdminChatCommand extends ChatCommand { - public AdminChatCommand() { - super(ChatMode.ADMIN); - } - - @Override - protected void handleChatSending(CommandSender sender, String[] args) { - if (sender instanceof Player) { - Player player = (Player) sender; - ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), buildChatMessage(args, 0)); - } - else { - ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 0)); - } - } -} +package com.gmail.nossr50.commands.chat; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.chat.ChatManager; +import com.gmail.nossr50.chat.ChatMode; +import com.gmail.nossr50.locale.LocaleLoader; + +public class AdminChatCommand extends ChatCommand { + public AdminChatCommand() { + super(ChatMode.ADMIN); + } + + @Override + protected void handleChatSending(CommandSender sender, String[] args) { + if (sender instanceof Player) { + Player player = (Player) sender; + ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), buildChatMessage(args, 0)); + } + else { + ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 0)); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/chat/commands/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java similarity index 70% rename from src/main/java/com/gmail/nossr50/chat/commands/ChatCommand.java rename to src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index a66fe5bc7..89372157e 100644 --- a/src/main/java/com/gmail/nossr50/chat/commands/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -1,88 +1,89 @@ -package com.gmail.nossr50.chat.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.chat.ChatMode; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.util.Users; - -public abstract class ChatCommand implements CommandExecutor { - protected McMMOPlayer mcMMOPlayer; - protected ChatMode chatMode; - - public ChatCommand (ChatMode chatMode) { - this.chatMode = chatMode; - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - if (!(sender instanceof Player)) { - return false; - } - - mcMMOPlayer = Users.getPlayer((Player) sender); - - if (chatMode.isEnabled(mcMMOPlayer)) { - disableChatMode(sender); - } - else { - enableChatMode(sender); - } - - return true; - - default: - if (args.length == 1) { - if (args[0].equalsIgnoreCase("on")) { - if (!(sender instanceof Player)) { - return false; - } - - enableChatMode(sender); - return true; - } - - if (args[0].equalsIgnoreCase("off")) { - if (!(sender instanceof Player)) { - return false; - } - - disableChatMode(sender); - return true; - } - } - - handleChatSending(sender, args); - return true; - } - } - - private void enableChatMode(CommandSender sender) { - chatMode.enable(mcMMOPlayer); - sender.sendMessage(chatMode.getEnabledMessage()); - } - - private void disableChatMode(CommandSender sender) { - chatMode.disable(mcMMOPlayer); - sender.sendMessage(chatMode.getDisabledMessage()); - } - - protected String buildChatMessage(String[] args, int index) { - StringBuilder builder = new StringBuilder(); - builder.append(args[index]); - - for (int i = index + 1; i < args.length; i++) { - builder.append(" "); - builder.append(args[i]); - } - - return builder.toString(); - } - - protected abstract void handleChatSending(CommandSender sender, String[] args); -} +package com.gmail.nossr50.commands.chat; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.chat.ChatMode; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.util.player.UserManager; + +public abstract class ChatCommand implements CommandExecutor { + protected McMMOPlayer mcMMOPlayer; + protected ChatMode chatMode; + + public ChatCommand(ChatMode chatMode) { + this.chatMode = chatMode; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 0: + if (!(sender instanceof Player)) { + return false; + } + + mcMMOPlayer = UserManager.getPlayer((Player) sender); + + if (chatMode.isEnabled(mcMMOPlayer)) { + disableChatMode(sender); + } + else { + enableChatMode(sender); + } + + return true; + + case 1: + if (args[0].equalsIgnoreCase("on")) { + if (!(sender instanceof Player)) { + return false; + } + + enableChatMode(sender); + return true; + } + + if (args[0].equalsIgnoreCase("off")) { + if (!(sender instanceof Player)) { + return false; + } + + disableChatMode(sender); + return true; + } + + // Fallthrough + + default: + handleChatSending(sender, args); + return true; + } + } + + protected String buildChatMessage(String[] args, int index) { + StringBuilder builder = new StringBuilder(); + builder.append(args[index]); + + for (int i = index + 1; i < args.length; i++) { + builder.append(" "); + builder.append(args[i]); + } + + return builder.toString(); + } + + protected abstract void handleChatSending(CommandSender sender, String[] args); + + private void enableChatMode(CommandSender sender) { + chatMode.enable(mcMMOPlayer); + sender.sendMessage(chatMode.getEnabledMessage()); + } + + private void disableChatMode(CommandSender sender) { + chatMode.disable(mcMMOPlayer); + sender.sendMessage(chatMode.getDisabledMessage()); + } +} diff --git a/src/main/java/com/gmail/nossr50/chat/commands/PartyChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java similarity index 86% rename from src/main/java/com/gmail/nossr50/chat/commands/PartyChatCommand.java rename to src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java index daafd9113..6f198c338 100644 --- a/src/main/java/com/gmail/nossr50/chat/commands/PartyChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java @@ -1,48 +1,48 @@ -package com.gmail.nossr50.chat.commands; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.chat.ChatManager; -import com.gmail.nossr50.chat.ChatMode; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyChatCommand extends ChatCommand { - public PartyChatCommand() { - super(ChatMode.PARTY); - } - - @Override - protected void handleChatSending(CommandSender sender, String[] args) { - if (sender instanceof Player) { - Player player = (Player) sender; - Party party = Users.getPlayer(player).getParty(); - - if (party == null) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); - return; - } - - ChatManager.handlePartyChat(mcMMO.p, party, player.getName(), player.getDisplayName(), buildChatMessage(args, 0)); - } - else { - if (args.length < 2) { - sender.sendMessage(LocaleLoader.getString("Party.Specify")); - return; - } - - Party party = PartyManager.getParty(args[0]); - - if (party == null) { - sender.sendMessage(LocaleLoader.getString("Party.InvalidName")); - return; - } - - ChatManager.handlePartyChat(mcMMO.p, party, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 1)); - } - } -} +package com.gmail.nossr50.commands.chat; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.chat.ChatManager; +import com.gmail.nossr50.chat.ChatMode; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyChatCommand extends ChatCommand { + public PartyChatCommand() { + super(ChatMode.PARTY); + } + + @Override + protected void handleChatSending(CommandSender sender, String[] args) { + if (sender instanceof Player) { + Player player = (Player) sender; + Party party = UserManager.getPlayer(player).getParty(); + + if (party == null) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + return; + } + + ChatManager.handlePartyChat(mcMMO.p, party, player.getName(), player.getDisplayName(), buildChatMessage(args, 0)); + } + else { + if (args.length < 2) { + sender.sendMessage(LocaleLoader.getString("Party.Specify")); + return; + } + + Party party = PartyManager.getParty(args[0]); + + if (party == null) { + sender.sendMessage(LocaleLoader.getString("Party.InvalidName")); + return; + } + + ChatManager.handlePartyChat(mcMMO.p, party, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 1)); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java new file mode 100644 index 000000000..09005c306 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java @@ -0,0 +1,45 @@ +package com.gmail.nossr50.commands.database; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.database.LeaderboardManager; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; + +public class McpurgeCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.mcpurge(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + switch (args.length) { + case 0: + if (Config.getInstance().getUseMySQL()) { + DatabaseManager.purgePowerlessSQL(); + + if (Config.getInstance().getOldUsersCutoff() != -1) { + DatabaseManager.purgeOldSQL(); + } + } + else { + LeaderboardManager.purgePowerlessFlatfile(); + + if (Config.getInstance().getOldUsersCutoff() != -1) { + LeaderboardManager.purgeOldFlatfile(); + } + } + + sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java new file mode 100644 index 000000000..c6615a9f1 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java @@ -0,0 +1,51 @@ +package com.gmail.nossr50.commands.database; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.database.LeaderboardManager; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; + +public class McremoveCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.mcremove(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + switch (args.length) { + case 1: + /* MySQL */ + if (Config.getInstance().getUseMySQL()) { + String tablePrefix = Config.getInstance().getMySQLTablePrefix(); + + if (DatabaseManager.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) { + DatabaseManager.profileCleanup(args[0]); + sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0])); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + } + } + else { + if (LeaderboardManager.removeFlatFileUser(args[0])) { + DatabaseManager.profileCleanup(args[0]); + sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0])); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + } + } + + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java b/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java similarity index 59% rename from src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java rename to src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java index 097c2fcaf..6c819920a 100644 --- a/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java @@ -1,51 +1,51 @@ -package com.gmail.nossr50.database.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.runnables.SQLConversionTask; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class MmoupdateCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!Permissions.mmoupdate(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - switch (args.length) { - case 0: - sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start")); - Users.clearAll(); - convertToMySQL(); - - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { - Users.addUser(player); - } - - sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish")); - return true; - - default: - return false; - } - } - - /** - * Convert FlatFile data to MySQL data. - */ - private void convertToMySQL() { - if (!Config.getInstance().getUseMySQL()) { - return; - } - - mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1); - } -} \ No newline at end of file +package com.gmail.nossr50.commands.database; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.runnables.database.SQLConversionTask; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; + +public class MmoupdateCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.mmoupdate(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + switch (args.length) { + case 0: + sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start")); + UserManager.clearAll(); + convertToMySQL(); + + for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { + UserManager.addUser(player); + } + + sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish")); + return true; + + default: + return false; + } + } + + /** + * Convert FlatFile data to MySQL data. + */ + private void convertToMySQL() { + if (!Config.getInstance().getUseMySQL()) { + return; + } + + mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1); + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java new file mode 100644 index 000000000..f2b146e36 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java @@ -0,0 +1,154 @@ +package com.gmail.nossr50.commands.experience; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class AddlevelsCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + PlayerProfile profile; + int levels; + boolean allSkills = false; + SkillType skill = null; + + switch (args.length) { + case 2: + if (!Permissions.addlevels(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (!(sender instanceof Player)) { + return false; + } + + if (args[0].equalsIgnoreCase("all")) { + allSkills = true; + } + else if (!SkillUtils.isSkill(args[0])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + if (!StringUtils.isInt(args[1])) { + return false; + } + + levels = Integer.parseInt(args[1]); + profile = UserManager.getPlayer((Player) sender).getProfile(); + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + profile.addLevels(skillType, levels); + } + } + else { + skill = SkillType.getSkill(args[0]); + profile.addLevels(skill, levels); + } + + if (allSkills) { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels)); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillUtils.getSkillName(skill))); + } + + return true; + + case 3: + if (!Permissions.addlevelsOthers(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (args[1].equalsIgnoreCase("all")) { + allSkills = true; + } + else if (!SkillUtils.isSkill(args[1])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + if (!StringUtils.isInt(args[2])) { + return false; + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + levels = Integer.parseInt(args[2]); + + // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. + if (mcMMOPlayer == null) { + profile = new PlayerProfile(args[0], false); + + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + profile.addLevels(skillType, levels); + } + } + else { + skill = SkillType.getSkill(args[1]); + profile.addLevels(skill, levels); + } + + profile.save(); // Since this is a temporary profile, we save it here. + } + else { + profile = mcMMOPlayer.getProfile(); + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + profile.addLevels(skillType, levels); + } + + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels)); + } + else { + skill = SkillType.getSkill(args[1]); + profile.addLevels(skill, levels); + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillUtils.getSkillName(skill))); + } + } + + if (allSkills) { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), args[0])); + } + + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java new file mode 100644 index 000000000..c965ef0bb --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java @@ -0,0 +1,152 @@ +package com.gmail.nossr50.commands.experience; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class AddxpCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + int xp; + McMMOPlayer mcMMOPlayer; + PlayerProfile profile; + boolean allSkills = false; + SkillType skill = null; + + switch (args.length) { + case 2: + if (!Permissions.addxp(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (!(sender instanceof Player)) { + return false; + } + + if (args[0].equalsIgnoreCase("all")) { + allSkills = true; + } + else if (!SkillUtils.isSkill(args[0])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + if (!StringUtils.isInt(args[1])) { + return false; + } + + xp = Integer.parseInt(args[1]); + mcMMOPlayer = UserManager.getPlayer((Player) sender); + profile = mcMMOPlayer.getProfile(); + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + mcMMOPlayer.applyXpGain(skillType, xp); + } + + sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp)); + } + else { + skill = SkillType.getSkill(args[0]); + + mcMMOPlayer.applyXpGain(skill, xp); + sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillUtils.getSkillName(skill))); + } + + return true; + + case 3: + if (!Permissions.addxpOthers(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (args[1].equalsIgnoreCase("all")) { + allSkills = true; + } + else if (!SkillUtils.isSkill(args[1])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + if (!StringUtils.isInt(args[2])) { + return false; + } + + mcMMOPlayer = UserManager.getPlayer(args[0]); + xp = Integer.parseInt(args[2]); + + // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. + if (mcMMOPlayer == null) { + profile = new PlayerProfile(args[0], false); + + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + // TODO: Currently the offline player doesn't level up automatically + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + profile.setSkillXpLevel(skillType, xp); + } + } + else { + skill = SkillType.getSkill(args[1]); + profile.setSkillXpLevel(skill, xp); + } + + profile.save(); // Since this is a temporary profile, we save it here. + } + else { + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + mcMMOPlayer.applyXpGain(skillType, xp); + } + + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp)); + } + else { + skill = SkillType.getSkill(args[1]); + mcMMOPlayer.applyXpGain(skill, xp); + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillUtils.getSkillName(skill))); + } + } + + if (allSkills) { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), args[0])); + } + + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java new file mode 100644 index 000000000..a2e878268 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java @@ -0,0 +1,150 @@ +package com.gmail.nossr50.commands.experience; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class MmoeditCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + PlayerProfile profile; + int newValue; + boolean allSkills = false; + SkillType skill = null; + + switch (args.length) { + case 2: + if (!Permissions.mmoedit(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (!(sender instanceof Player)) { + return false; + } + + if (args[0].equalsIgnoreCase("all")) { + allSkills = true; + } + else if (!SkillUtils.isSkill(args[0])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + if (!StringUtils.isInt(args[1])) { + return false; + } + + newValue = Integer.parseInt(args[1]); + profile = UserManager.getPlayer((Player) sender).getProfile(); + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + profile.modifySkill(skillType, newValue); + } + + sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue)); + } + else { + skill = SkillType.getSkill(args[0]); + profile.modifySkill(skill, newValue); + sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), newValue)); + } + + return true; + + case 3: + if (!Permissions.mmoeditOthers(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (args[1].equalsIgnoreCase("all")) { + allSkills = true; + } + else if (!SkillUtils.isSkill(args[1])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + if (!StringUtils.isInt(args[2])) { + return false; + } + + newValue = Integer.parseInt(args[2]); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + + // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. + if (mcMMOPlayer == null) { + profile = new PlayerProfile(args[0], false); + + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + profile.modifySkill(skillType, newValue); + } + } + else { + skill = SkillType.getSkill(args[1]); + profile.modifySkill(skill, newValue); + } + + profile.save(); // Since this is a temporary profile, we save it here. + } + else { + profile = mcMMOPlayer.getProfile(); + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + profile.modifySkill(skillType, newValue); + } + + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue)); + } + else { + skill = SkillType.getSkill(args[1]); + profile.modifySkill(skill, newValue); + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), newValue)); + } + } + + if (allSkills) { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", SkillUtils.getSkillName(skill), args[0])); + } + + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java new file mode 100644 index 000000000..efe3699e7 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java @@ -0,0 +1,169 @@ +package com.gmail.nossr50.commands.experience; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class SkillresetCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + PlayerProfile profile; + boolean allSkills = false; + SkillType skill = null; + String skillName = ""; + + switch (args.length) { + case 1: + if (!Permissions.skillreset(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (!(sender instanceof Player)) { + return false; + } + + if (args[0].equalsIgnoreCase("all")) { + allSkills = true; + } + else if (!SkillUtils.isSkill(args[0])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + profile = UserManager.getPlayer((Player) sender).getProfile(); + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + if (!Permissions.skillreset(sender, skillType)) { + sender.sendMessage(command.getPermissionMessage()); + continue; + } + + profile.modifySkill(skillType, 0); + } + + sender.sendMessage(LocaleLoader.getString("Commands.Reset.All")); + } + else { + skill = SkillType.getSkill(args[0]); + skillName = SkillUtils.getSkillName(skill); + + if (!Permissions.skillreset(sender, skill)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + profile.modifySkill(skill, 0); + sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName)); + } + + return true; + + case 2: + if (!Permissions.skillresetOthers(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (args[1].equalsIgnoreCase("all")) { + allSkills = true; + } + else if (!SkillUtils.isSkill(args[1])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + if (!allSkills) { + skill = SkillType.getSkill(args[1]); + skillName = SkillUtils.getSkillName(skill); + + if (!Permissions.skillresetOthers(sender, skill)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + + // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. + if (mcMMOPlayer == null) { + profile = new PlayerProfile(args[0], false); + + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + if (!Permissions.skillresetOthers(sender, skill)) { + sender.sendMessage(command.getPermissionMessage()); + continue; + } + + profile.modifySkill(skillType, 0); + } + } + else { + profile.modifySkill(skill, 0); + } + + profile.save(); // Since this is a temporary profile, we save it here. + } + else { + profile = mcMMOPlayer.getProfile(); + + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + if (!Permissions.skillresetOthers(sender, skillType)) { + sender.sendMessage(command.getPermissionMessage()); + continue; + } + + profile.modifySkill(skillType, 0); + } + + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All")); + } + else { + profile.modifySkill(skill, 0); + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName)); + } + } + + if (allSkills) { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", skillName, args[0])); + } + + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreCommand.java b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreCommand.java new file mode 100644 index 000000000..c4c07a043 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreCommand.java @@ -0,0 +1,85 @@ +package com.gmail.nossr50.commands.hardcore; + +import java.text.DecimalFormat; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; + +public class HardcoreCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 0: + if (!Permissions.hardcoreToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (Config.getInstance().getHardcoreEnabled()) { + disableHardcore(); + } + else { + enableHardcore(); + } + + return true; + + case 1: + if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) { + if (!Permissions.hardcoreToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + enableHardcore(); + return true; + } + + if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) { + if (!Permissions.hardcoreToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + disableHardcore(); + return true; + } + + if (!StringUtils.isDouble(args[0])) { + return false; + } + + if (!Permissions.hardcoreModify(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + DecimalFormat percent = new DecimalFormat("##0.00%"); + double newPercent = Double.parseDouble(args[0]); + + Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent); + sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D))); + return true; + + default: + return false; + } + } + + private void disableHardcore() { + Config.getInstance().setHardcoreEnabled(false); + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled")); + } + + private void enableHardcore() { + Config.getInstance().setHardcoreEnabled(true); + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled")); + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/hardcore/VampirismCommand.java b/src/main/java/com/gmail/nossr50/commands/hardcore/VampirismCommand.java new file mode 100644 index 000000000..4abc8deb9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/hardcore/VampirismCommand.java @@ -0,0 +1,90 @@ +package com.gmail.nossr50.commands.hardcore; + +import java.text.DecimalFormat; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; + +public class VampirismCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Config.getInstance().getHardcoreEnabled()) { + sender.sendMessage(LocaleLoader.getString("Hardcore.Disabled")); + return true; + } + + switch (args.length) { + case 0: + if (!Permissions.vampirismToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (Config.getInstance().getHardcoreVampirismEnabled()) { + disableVampirism(); + } + else { + enableVampirism(); + } + + return true; + + case 1: + if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) { + if (!Permissions.vampirismToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + enableVampirism(); + return true; + } + + if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) { + if (!Permissions.vampirismToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + disableVampirism(); + return true; + } + + if (!StringUtils.isDouble(args[0])) { + return false; + } + + if (!Permissions.vampirismModify(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + DecimalFormat percent = new DecimalFormat("##0.00%"); + double newPercent = Double.parseDouble(args[0]); + + Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent); + sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D))); + return true; + + default: + return false; + } + } + + private void disableVampirism() { + Config.getInstance().setHardcoreVampirismEnabled(false); + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled")); + } + + private void enableVampirism() { + Config.getInstance().setHardcoreVampirismEnabled(true); + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled")); + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java new file mode 100644 index 000000000..5dd85df1f --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java @@ -0,0 +1,42 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyAcceptCommand implements CommandExecutor { + private McMMOPlayer mcMMOPlayer; + private Player player; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 1: + player = (Player) sender; + mcMMOPlayer = UserManager.getPlayer(player); + + if (!mcMMOPlayer.hasPartyInvite()) { + sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); + return true; + } + + // Changing parties + if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) { + return true; + } + + PartyManager.joinInvitedParty(player, mcMMOPlayer); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept")); + return true; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java new file mode 100644 index 000000000..b1a9d93d0 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java @@ -0,0 +1,34 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyChangeOwnerCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 2: + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + + if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) { + sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); + return true; + } + + PartyManager.setPartyLeader(args[1], playerParty); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + return true; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyChangePasswordCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java similarity index 53% rename from src/main/java/com/gmail/nossr50/party/commands/PartyChangePasswordCommand.java rename to src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java index b69984978..1e4720403 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyChangePasswordCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java @@ -1,50 +1,49 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.util.Users; - -public class PartyChangePasswordCommand implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - Party playerParty = Users.getPlayer((Player) sender).getParty(); - - switch (args.length) { - case 1: - unprotectParty(sender, playerParty); - return true; - - case 2: - if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) { - unprotectParty(sender, playerParty); - return true; - } - - protectParty(sender, playerParty, args[1]); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "[clear|reset]")); - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">")); - return true; - } - } - - private void unprotectParty(CommandSender sender, Party playerParty) { - playerParty.setLocked(true); - playerParty.setPassword(null); - sender.sendMessage(LocaleLoader.getString("Party.Password.Removed")); - } - - private void protectParty(CommandSender sender, Party playerParty, String password) { - playerParty.setLocked(true); - playerParty.setPassword(password); - sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password)); - } -} +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyChangePasswordCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + + switch (args.length) { + case 1: + unprotectParty(sender, playerParty); + return true; + + case 2: + if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) { + unprotectParty(sender, playerParty); + return true; + } + + protectParty(sender, playerParty, args[1]); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "[clear|reset]")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">")); + return true; + } + } + + private void unprotectParty(CommandSender sender, Party playerParty) { + playerParty.setLocked(true); + playerParty.setPassword(null); + sender.sendMessage(LocaleLoader.getString("Party.Password.Removed")); + } + + private void protectParty(CommandSender sender, Party playerParty, String password) { + playerParty.setLocked(true); + playerParty.setPassword(password); + sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password)); + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java new file mode 100644 index 000000000..06bb51a27 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -0,0 +1,154 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.commands.chat.PartyChatCommand; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.commands.CommandUtils; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyCommand implements CommandExecutor { + private McMMOPlayer mcMMOPlayer; + private Player player; + + private CommandExecutor partyJoinCommand = new PartyJoinCommand(); + private CommandExecutor partyAcceptCommand = new PartyAcceptCommand(); + private CommandExecutor partyCreateCommand = new PartyCreateCommand(); + private CommandExecutor partyQuitCommand = new PartyQuitCommand(); + private CommandExecutor partyExpShareCommand = new PartyExpShareCommand(); + private CommandExecutor partyItemShareCommand = new PartyItemShareCommand(); + private CommandExecutor partyInviteCommand = new PartyInviteCommand(); + private CommandExecutor partyKickCommand = new PartyKickCommand(); + private CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); + private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); + private CommandExecutor partyLockCommand = new PartyLockCommand(); + private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); + private CommandExecutor partyRenameCommand = new PartyRenameCommand(); + private CommandExecutor partyInfoCommand = new PartyInfoCommand(); + private CommandExecutor partyHelpCommand = new PartyHelpCommand(); + private CommandExecutor partyTeleportCommand = new PtpCommand(); + private CommandExecutor partyChatCommand = new PartyChatCommand(); + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + + if (!Permissions.party(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + player = (Player) sender; + mcMMOPlayer = UserManager.getPlayer(player); + + if (args.length < 1) { + if (!mcMMOPlayer.inParty()) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + return printUsage(); + } + + return partyInfoCommand.onCommand(sender, command, label, args); + } + + PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]); + + if (subcommand == null) { + return printUsage(); + } + + // Can't use this for lock/unlock since they're handled by the same command + if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !Permissions.partySubcommand(sender, subcommand)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + switch (subcommand) { + case JOIN: + return partyJoinCommand.onCommand(sender, command, label, args); + case ACCEPT: + return partyAcceptCommand.onCommand(sender, command, label, args); + case CREATE: + return partyCreateCommand.onCommand(sender, command, label, args); + case HELP: + return partyHelpCommand.onCommand(sender, command, label, args); + default: + break; + } + + // Party member commands + if (!mcMMOPlayer.inParty()) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + return printUsage(); + } + + switch (subcommand) { + case INFO: + return partyInfoCommand.onCommand(sender, command, label, args); + case QUIT: + return partyQuitCommand.onCommand(sender, command, label, args); + case INVITE: + return partyInviteCommand.onCommand(sender, command, label, args); + case TELEPORT: + return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args)); + case CHAT: + return partyChatCommand.onCommand(sender, command, label, extractArgs(args)); + default: + break; + } + + // Party leader commands + if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) { + sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); + return true; + } + + switch (subcommand) { + case EXPSHARE: + return partyExpShareCommand.onCommand(sender, command, label, args); + case ITEMSHARE: + return partyItemShareCommand.onCommand(sender, command, label, args); + case KICK: + return partyKickCommand.onCommand(sender, command, label, args); + case DISBAND: + return partyDisbandCommand.onCommand(sender, command, label, args); + case OWNER: + return partyChangeOwnerCommand.onCommand(sender, command, label, args); + case LOCK: + // Fallthrough + case UNLOCK: + return partyLockCommand.onCommand(sender, command, label, args); + case PASSWORD: + return partyChangePasswordCommand.onCommand(sender, command, label, args); + case RENAME: + return partyRenameCommand.onCommand(sender, command, label, args); + default: + break; + } + + return true; + } + + private boolean printUsage() { + player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join")); + player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); + player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?")); + return true; + } + + private String[] extractArgs(String[] args) { + String[] newArgs = new String[args.length - 1]; + + for (int i = 1; i < args.length; i++) { + newArgs[i - 1] = args[1]; + } + + return newArgs; + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java new file mode 100644 index 000000000..febfa694a --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java @@ -0,0 +1,56 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyCreateCommand implements CommandExecutor { + private McMMOPlayer mcMMOPlayer; + private Player player; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 2: + // Fallthrough + case 3: + Party newParty = PartyManager.getParty(args[1]); + + // Check to see if the party exists, and if it does cancel creating a new party + if (newParty != null) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", args[1])); + return true; + } + + player = (Player) sender; + mcMMOPlayer = UserManager.getPlayer(player); + + // Changing parties + if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) { + return true; + } + + PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args)); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "create", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); + return true; + } + } + + private String getPassword(String[] args) { + if (args.length == 3) { + return args[2]; + } + + return null; + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java new file mode 100644 index 000000000..472335ddc --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java @@ -0,0 +1,37 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyDisbandCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 1: + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + + for (Player member : playerParty.getOnlineMembers()) { + if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) { + return true; + } + + member.sendMessage(LocaleLoader.getString("Party.Disband")); + } + + PartyManager.disbandParty(playerParty); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband")); + return true; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyExpShareCommand.java similarity index 56% rename from src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java rename to src/main/java/com/gmail/nossr50/commands/party/PartyExpShareCommand.java index 8743d0827..c181ef643 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyExpShareCommand.java @@ -1,55 +1,55 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.ShareHandler; -import com.gmail.nossr50.party.ShareHandler.ShareMode; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; - -public class PartyExpShareCommand implements CommandExecutor { - private Party playerParty; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!Config.getInstance().getExpShareEnabled()) { - sender.sendMessage(LocaleLoader.getString("Party.ExpShare.Disabled")); - return true; - } - - switch (args.length) { - case 2: - playerParty = Users.getPlayer((Player) sender).getParty(); - - if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { - handleChangingShareMode(ShareMode.NONE); - } - else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) { - handleChangingShareMode(ShareMode.EQUAL); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE | EQUAL]")); - } - - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "")); - return true; - } - } - - private void handleChangingShareMode(ShareHandler.ShareMode mode) { - playerParty.setXpShareMode(mode); - - for (Player member : playerParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())))); - } - } -} +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.ShareHandler; +import com.gmail.nossr50.party.ShareHandler.ShareMode; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyExpShareCommand implements CommandExecutor { + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Config.getInstance().getExpShareEnabled()) { + sender.sendMessage(LocaleLoader.getString("Party.ExpShare.Disabled")); + return true; + } + + switch (args.length) { + case 2: + playerParty = UserManager.getPlayer((Player) sender).getParty(); + + if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { + handleChangingShareMode(ShareMode.NONE); + } + else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) { + handleChangingShareMode(ShareMode.EQUAL); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE | EQUAL]")); + } + + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "")); + return true; + } + } + + private void handleChangingShareMode(ShareHandler.ShareMode mode) { + playerParty.setXpShareMode(mode); + + for (Player member : playerParty.getOnlineMembers()) { + member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())))); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java new file mode 100644 index 000000000..23749be76 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java @@ -0,0 +1,30 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.locale.LocaleLoader; + +public class PartyHelpCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 1: + sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); + sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); + sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); + sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); + sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); + sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader")); + sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help")); + return true; + } + } + +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java similarity index 91% rename from src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java rename to src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index ac85a4e1a..d079b5426 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -1,102 +1,102 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.party.ShareHandler; -import com.gmail.nossr50.util.Users; - -public class PartyInfoCommand implements CommandExecutor { - private Player player; - private Party playerParty; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - player = (Player) sender; - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); - playerParty = mcMMOPlayer.getParty(); - - displayPartyHeader(); - displayShareModeInfo(); - displayMemberInfo(); - return true; - } - - private String createMembersList() { - StringBuilder memberList = new StringBuilder(); - - for (OfflinePlayer member : playerParty.getMembers()) { - if (playerParty.getLeader().equals(member.getName())) { - memberList.append(ChatColor.GOLD).append(member.getName()).append(" "); - } - else if (member.isOnline()) { - memberList.append(ChatColor.WHITE).append(member.getName()).append(" "); - } - else { - memberList.append(ChatColor.GRAY).append(member.getName()).append(" "); - } - } - - return memberList.toString(); - } - - private void displayShareModeInfo() { - boolean xpShareEnabled = Config.getInstance().getExpShareEnabled(); - boolean itemShareEnabled = Config.getInstance().getItemShareEnabled(); - boolean itemSharingActive = playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE; - - if (!xpShareEnabled && !itemShareEnabled) { - return; - } - - String expShareInfo = ""; - String itemShareInfo = ""; - String separator = ""; - - if (xpShareEnabled) { - expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString()); - } - - if (itemShareEnabled) { - itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString()); - } - - if (xpShareEnabled && itemShareEnabled) { - separator = ChatColor.DARK_GRAY + " || "; - } - - player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo); - if (itemSharingActive) { - player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories())); - } - } - - private void displayPartyHeader() { - player.sendMessage(LocaleLoader.getString("Commands.Party.Header")); - - if (playerParty.isLocked()) { - player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked"))); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked"))); - } - } - - private void displayMemberInfo() { - int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size(); - int membersOnline = playerParty.getOnlineMembers().size() - 1; - - player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); - player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline)); - player.sendMessage(LocaleLoader.getString("Commands.Party.Members", createMembersList())); - } -} +package com.gmail.nossr50.commands.party; + +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.party.ShareHandler; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyInfoCommand implements CommandExecutor { + private Player player; + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + player = (Player) sender; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + playerParty = mcMMOPlayer.getParty(); + + displayPartyHeader(); + displayShareModeInfo(); + displayMemberInfo(); + return true; + } + + private String createMembersList() { + StringBuilder memberList = new StringBuilder(); + + for (OfflinePlayer member : playerParty.getMembers()) { + if (playerParty.getLeader().equals(member.getName())) { + memberList.append(ChatColor.GOLD).append(member.getName()).append(" "); + } + else if (member.isOnline()) { + memberList.append(ChatColor.WHITE).append(member.getName()).append(" "); + } + else { + memberList.append(ChatColor.GRAY).append(member.getName()).append(" "); + } + } + + return memberList.toString(); + } + + private void displayShareModeInfo() { + boolean xpShareEnabled = Config.getInstance().getExpShareEnabled(); + boolean itemShareEnabled = Config.getInstance().getItemShareEnabled(); + boolean itemSharingActive = playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE; + + if (!xpShareEnabled && !itemShareEnabled) { + return; + } + + String expShareInfo = ""; + String itemShareInfo = ""; + String separator = ""; + + if (xpShareEnabled) { + expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString()); + } + + if (itemShareEnabled) { + itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString()); + } + + if (xpShareEnabled && itemShareEnabled) { + separator = ChatColor.DARK_GRAY + " || "; + } + + player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo); + if (itemSharingActive) { + player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories())); + } + } + + private void displayPartyHeader() { + player.sendMessage(LocaleLoader.getString("Commands.Party.Header")); + + if (playerParty.isLocked()) { + player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked"))); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked"))); + } + } + + private void displayMemberInfo() { + int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size(); + int membersOnline = playerParty.getOnlineMembers().size() - 1; + + player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); + player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline)); + player.sendMessage(LocaleLoader.getString("Commands.Party.Members", createMembersList())); + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java new file mode 100644 index 000000000..fe25cc11c --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -0,0 +1,72 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyInviteCommand implements CommandExecutor { + private McMMOPlayer mcMMOTarget; + private Player target; + + private McMMOPlayer mcMMOPlayer; + private Player player; + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 2: + if (!mcMMO.p.getServer().getOfflinePlayer(args[1]).isOnline()) { + sender.sendMessage(LocaleLoader.getString("Party.NotOnline", args[1])); + return true; + } + + mcMMOTarget = UserManager.getPlayer(args[1]); + + if (mcMMOTarget == null) { + sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); + return true; + } + + target = mcMMOTarget.getPlayer(); + mcMMOPlayer = UserManager.getPlayer((Player) sender); + player = mcMMOPlayer.getPlayer(); + + if (player.equals(target)) { + sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); + return true; + } + + if (PartyManager.inSameParty(player, target)) { + sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName())); + return true; + } + + playerParty = mcMMOPlayer.getParty(); + + if (!PartyManager.canInvite(player, playerParty)) { + player.sendMessage(LocaleLoader.getString("Party.Locked")); + return true; + } + + mcMMOTarget.setPartyInvite(playerParty); + + sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); + target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), player.getName())); + target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1")); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + return true; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java new file mode 100644 index 000000000..6a6172968 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java @@ -0,0 +1,101 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.ShareHandler; +import com.gmail.nossr50.party.ShareHandler.ShareMode; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyItemShareCommand implements CommandExecutor { + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Config.getInstance().getItemShareEnabled()) { + sender.sendMessage(LocaleLoader.getString("Party.ItemShare.Disabled")); + return true; + } + + switch (args.length) { + case 2: + playerParty = UserManager.getPlayer((Player) sender).getParty(); + + if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { + handleChangingShareMode(ShareMode.NONE); + } + else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) { + handleChangingShareMode(ShareMode.EQUAL); + } + else if (args[1].equalsIgnoreCase("random")) { + handleChangingShareMode(ShareMode.RANDOM); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); + } + + return true; + + case 3: + playerParty = UserManager.getPlayer((Player) sender).getParty(); + boolean toggle = false; + + if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("on") || args[2].equalsIgnoreCase("enabled")) { + toggle = true; + } + else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("off") || args[2].equalsIgnoreCase("disabled")) { + toggle = false; + } + + if (args[1].equalsIgnoreCase("loot")) { + playerParty.setSharingLootDrops(toggle); + } + else if (args[1].equalsIgnoreCase("mining")) { + playerParty.setSharingMiningDrops(toggle); + } + else if (args[1].equalsIgnoreCase("herbalism")) { + playerParty.setSharingHerbalismDrops(toggle); + } + else if (args[1].equalsIgnoreCase("woodcutting")) { + playerParty.setSharingWoodcuttingDrops(toggle); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + } + + notifyToggleItemShareCategory(args, toggle); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + return true; + } + } + + private void handleChangingShareMode(ShareHandler.ShareMode mode) { + playerParty.setItemShareMode(mode); + + for (Player member : playerParty.getOnlineMembers()) { + member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())))); + } + } + + private void notifyToggleItemShareCategory(String[] args, boolean toggle) { + String state = "disabled"; + + if (toggle) { + state = "enabled"; + } + + for (Player member : playerParty.getOnlineMembers()) { + member.sendMessage(LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(args[1]), state)); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyJoinCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java similarity index 58% rename from src/main/java/com/gmail/nossr50/party/commands/PartyJoinCommand.java rename to src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java index 17cbb28e7..34db3f510 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyJoinCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java @@ -1,95 +1,96 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyJoinCommand implements CommandExecutor { - private McMMOPlayer mcMMOTarget; - private Player target; - private Party targetParty; - - private McMMOPlayer mcMMOPlayer; - private Player player; - private Party playerParty; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - case 3: - // Verify target exists and is in a different party than the player - if (!canJoinParty(sender, args[1])) { - return true; - } - - String password = getPassword(args); - - // Make sure party passwords match - if (!PartyManager.checkPartyPassword(player, targetParty, password)) { - return true; - } - - // Changing parties - if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) { - return true; - } - - PartyManager.joinParty(player, mcMMOPlayer, targetParty, password); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); - return true; - } - } - - private String getPassword(String[] args) { - if (args.length == 3) { - return args[2]; - } - - return null; - } - - private boolean canJoinParty(CommandSender sender, String targetName) { - if (!mcMMO.p.getServer().getOfflinePlayer(targetName).isOnline()) { - sender.sendMessage(LocaleLoader.getString("Party.NotOnline", targetName)); - return false; - } - - mcMMOTarget = Users.getPlayer(targetName); - - if (mcMMOTarget == null) { - sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); - return false; - } - - target = mcMMOTarget.getPlayer(); - - if (!mcMMOTarget.inParty()) { - sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName)); - return false; - } - - player = (Player) sender; - mcMMOPlayer = Users.getPlayer(player); - playerParty = mcMMOPlayer.getParty(); - targetParty = mcMMOTarget.getParty(); - - if (player.equals(target) || (mcMMOPlayer.inParty() && playerParty.equals(targetParty))) { - sender.sendMessage(LocaleLoader.getString("Party.Join.Self")); - return false; - } - - return true; - } -} +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyJoinCommand implements CommandExecutor { + private McMMOPlayer mcMMOTarget; + private Player target; + private Party targetParty; + + private McMMOPlayer mcMMOPlayer; + private Player player; + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 2: + // Fallthrough + case 3: + // Verify target exists and is in a different party than the player + if (!canJoinParty(sender, args[1])) { + return true; + } + + String password = getPassword(args); + + // Make sure party passwords match + if (!PartyManager.checkPartyPassword(player, targetParty, password)) { + return true; + } + + // Changing parties + if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) { + return true; + } + + PartyManager.joinParty(player, mcMMOPlayer, targetParty, password); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); + return true; + } + } + + private String getPassword(String[] args) { + if (args.length == 3) { + return args[2]; + } + + return null; + } + + private boolean canJoinParty(CommandSender sender, String targetName) { + if (!mcMMO.p.getServer().getOfflinePlayer(targetName).isOnline()) { + sender.sendMessage(LocaleLoader.getString("Party.NotOnline", targetName)); + return false; + } + + mcMMOTarget = UserManager.getPlayer(targetName); + + if (mcMMOTarget == null) { + sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); + return false; + } + + target = mcMMOTarget.getPlayer(); + + if (!mcMMOTarget.inParty()) { + sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName)); + return false; + } + + player = (Player) sender; + mcMMOPlayer = UserManager.getPlayer(player); + playerParty = mcMMOPlayer.getParty(); + targetParty = mcMMOTarget.getParty(); + + if (player.equals(target) || (mcMMOPlayer.inParty() && playerParty.equals(targetParty))) { + sender.sendMessage(LocaleLoader.getString("Party.Join.Self")); + return false; + } + + return true; + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java new file mode 100644 index 000000000..77b4d9c78 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java @@ -0,0 +1,49 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.OfflinePlayer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyKickCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 2: + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + + OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]); + + if (!playerParty.getMembers().contains(target)) { + sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); + return true; + } + + if (target.isOnline()) { + Player onlineTarget = target.getPlayer(); + String partyName = playerParty.getName(); + + if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) { + return true; + } + + onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); + } + + PartyManager.removeFromParty(target, playerParty); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + return true; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java similarity index 63% rename from src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java rename to src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java index b4f2459a1..b29c6618f 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java @@ -1,97 +1,97 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class PartyLockCommand implements CommandExecutor { - private Party playerParty; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - playerParty = Users.getPlayer((Player) sender).getParty(); - - switch (args.length) { - case 1: - if (args[0].equalsIgnoreCase("lock")) { - lockParty(sender, command); - } - else if (args[0].equalsIgnoreCase("unlock")) { - unlockParty(sender, command); - } - - return true; - - case 2: - if (!args[0].equalsIgnoreCase("lock")) { - sendUsageStrings(sender); - return true; - } - - if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) { - lockParty(sender, command); - } - else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { - unlockParty(sender, command); - } - else { - sendUsageStrings(sender); - } - - return true; - - default: - sendUsageStrings(sender); - return true; - } - } - - /** - * Handle locking a party. - */ - private void lockParty(CommandSender sender, Command command) { - if (!Permissions.partySubcommand(sender, PartySubcommandType.LOCK)) { - sender.sendMessage(command.getPermissionMessage()); - return; - } - - if (playerParty.isLocked()) { - sender.sendMessage(LocaleLoader.getString("Party.IsLocked")); - return; - } - - playerParty.setLocked(true); - sender.sendMessage(LocaleLoader.getString("Party.Locked")); - } - - /** - * Handle unlocking a party. - * - * @return true if party is successfully unlocked, false otherwise. - */ - private void unlockParty(CommandSender sender, Command command) { - if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) { - sender.sendMessage(command.getPermissionMessage()); - return; - } - - if (!playerParty.isLocked()) { - sender.sendMessage(LocaleLoader.getString("Party.IsntLocked")); - return; - } - - playerParty.setLocked(false); - sender.sendMessage(LocaleLoader.getString("Party.Unlocked")); - } - - private void sendUsageStrings(CommandSender sender) { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock")); - } -} +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyLockCommand implements CommandExecutor { + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + playerParty = UserManager.getPlayer((Player) sender).getParty(); + + switch (args.length) { + case 1: + if (args[0].equalsIgnoreCase("lock")) { + lockParty(sender, command); + } + else if (args[0].equalsIgnoreCase("unlock")) { + unlockParty(sender, command); + } + + return true; + + case 2: + if (!args[0].equalsIgnoreCase("lock")) { + sendUsageStrings(sender); + return true; + } + + if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) { + lockParty(sender, command); + } + else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { + unlockParty(sender, command); + } + else { + sendUsageStrings(sender); + } + + return true; + + default: + sendUsageStrings(sender); + return true; + } + } + + /** + * Handle locking a party. + */ + private void lockParty(CommandSender sender, Command command) { + if (!Permissions.partySubcommand(sender, PartySubcommandType.LOCK)) { + sender.sendMessage(command.getPermissionMessage()); + return; + } + + if (playerParty.isLocked()) { + sender.sendMessage(LocaleLoader.getString("Party.IsLocked")); + return; + } + + playerParty.setLocked(true); + sender.sendMessage(LocaleLoader.getString("Party.Locked")); + } + + /** + * Handle unlocking a party. + * + * @return true if party is successfully unlocked, false otherwise. + */ + private void unlockParty(CommandSender sender, Command command) { + if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) { + sender.sendMessage(command.getPermissionMessage()); + return; + } + + if (!playerParty.isLocked()) { + sender.sendMessage(LocaleLoader.getString("Party.IsntLocked")); + return; + } + + playerParty.setLocked(false); + sender.sendMessage(LocaleLoader.getString("Party.Unlocked")); + } + + private void sendUsageStrings(CommandSender sender) { + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock")); + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java new file mode 100644 index 000000000..e63d6ff72 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java @@ -0,0 +1,38 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyQuitCommand implements CommandExecutor { + private Player player; + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 1: + player = (Player) sender; + playerParty = UserManager.getPlayer(player).getParty(); + + if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { + return true; + } + + PartyManager.removeFromParty(player, playerParty); + sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave")); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "[quit|q|leave]")); + return true; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java new file mode 100644 index 000000000..0072863cd --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java @@ -0,0 +1,58 @@ +package com.gmail.nossr50.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.player.UserManager; + +public class PartyRenameCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + String leaderName = playerParty.getLeader(); + + switch (args.length) { + case 2: + String newPartyName = args[1]; + + // This is to prevent party leaders from spamming other players with the rename message + if (playerParty.getName().equalsIgnoreCase(newPartyName)) { + sender.sendMessage(LocaleLoader.getString("Party.Rename.Same")); + return true; + } + + Party newParty = PartyManager.getParty(newPartyName); + + // Check to see if the party exists, and if it does cancel renaming the party + if (newParty != null) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", newPartyName)); + return true; + } + + for (Player member : playerParty.getOnlineMembers()) { + if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) { + return true; + } + + if (!member.getName().equals(leaderName)) { + member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName)); + } + } + + playerParty.setName(newPartyName); + + sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName)); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">")); + return true; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java b/src/main/java/com/gmail/nossr50/commands/party/PartySubcommandType.java similarity index 92% rename from src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java rename to src/main/java/com/gmail/nossr50/commands/party/PartySubcommandType.java index fa9432447..2be55ebfe 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartySubcommandType.java @@ -1,48 +1,48 @@ -package com.gmail.nossr50.party.commands; - -public enum PartySubcommandType { - JOIN, - ACCEPT, - CREATE, - HELP, - INFO, - QUIT, - EXPSHARE, - ITEMSHARE, - INVITE, - KICK, - DISBAND, - OWNER, - LOCK, - UNLOCK, - PASSWORD, - RENAME, - TELEPORT, - CHAT; - - public static PartySubcommandType getSubcommand(String commandName) { - for (PartySubcommandType command : values()) { - if (command.name().equalsIgnoreCase(commandName)) { - return command; - } - } - - if (commandName.equalsIgnoreCase("?")) { - return HELP; - } - else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) { - return QUIT; - } - else if (commandName.equalsIgnoreCase("leader")) { - return OWNER; - } - else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) { - return EXPSHARE; - } - else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) { - return ITEMSHARE; - } - - return null; - } -} +package com.gmail.nossr50.commands.party; + +public enum PartySubcommandType { + JOIN, + ACCEPT, + CREATE, + HELP, + INFO, + QUIT, + EXPSHARE, + ITEMSHARE, + INVITE, + KICK, + DISBAND, + OWNER, + LOCK, + UNLOCK, + PASSWORD, + RENAME, + TELEPORT, + CHAT; + + public static PartySubcommandType getSubcommand(String commandName) { + for (PartySubcommandType command : values()) { + if (command.name().equalsIgnoreCase(commandName)) { + return command; + } + } + + if (commandName.equalsIgnoreCase("?")) { + return HELP; + } + else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) { + return QUIT; + } + else if (commandName.equalsIgnoreCase("leader")) { + return OWNER; + } + else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) { + return EXPSHARE; + } + else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) { + return ITEMSHARE; + } + + return null; + } +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java similarity index 73% rename from src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java rename to src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java index 6d943dae2..a84cd9d27 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java @@ -1,219 +1,219 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.commands.CommandHelper; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class PtpCommand implements CommandExecutor { - private Player player; - private McMMOPlayer mcMMOPlayer; - private PlayerProfile playerProfile; - - private Player target; - private McMMOPlayer mcMMOTarget; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noConsoleUsage(sender)) { - return true; - } - - switch (args.length) { - case 1: - player = (Player) sender; - mcMMOPlayer = Users.getPlayer(player); - playerProfile = mcMMOPlayer.getProfile(); - - if (args[0].equalsIgnoreCase("toggle")) { - if (!Permissions.partyTeleportToggle(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - return togglePartyTeleportation(); - } - - if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { - if (!Permissions.partyTeleportAcceptAll(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - return acceptAnyTeleportRequest(); - } - - int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); - - if (playerProfile.getRecentlyHurt() + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown)); - return true; - } - - if (args[0].equalsIgnoreCase("accept")) { - if (!Permissions.partyTeleportAccept(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - return acceptTeleportRequest(); - } - - return sendTeleportRequest(args[0]); - - default: - return false; - } - } - - private boolean sendTeleportRequest(String targetName) { - if (!canTeleport(targetName)) { - return true; - } - - if (!mcMMOTarget.getPtpConfirmRequired()) { - return handlePartyTeleportEvent(player, target); - } - - mcMMOTarget.setPtpRequest(player); - mcMMOTarget.actualizePtpTimeout(); - player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); - - int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout(); - target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); - target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire)); - return true; - } - - private boolean acceptTeleportRequest() { - if (!mcMMOPlayer.hasPtpRequest()) { - player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests")); - return true; - } - - int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout(); - - if ((mcMMOPlayer.getPtpTimeout() + ptpRequestExpire) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) { - mcMMOPlayer.removePtpRequest(); - player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired")); - return true; - } - - target = mcMMOPlayer.getPtpRequest(); - - if (!canTeleport(target.getName())) { - mcMMOPlayer.removePtpRequest(); - return true; - } - - if (Config.getInstance().getPTPCommandWorldPermissions()) { - World targetWorld = target.getWorld(); - World playerWorld = player.getWorld(); - - if (!Permissions.partyTeleportAllWorlds(target)) { - if (!Permissions.partyTeleportWorld(target, targetWorld)) { - target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName())); - return true; - } - else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) { - target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName())); - return true; - } - } - } - - return handlePartyTeleportEvent(target, player); - } - - private boolean acceptAnyTeleportRequest() { - if (mcMMOPlayer.getPtpConfirmRequired()) { - player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled")); - } - - mcMMOPlayer.togglePtpConfirmRequired(); - return true; - } - - private boolean togglePartyTeleportation() { - if (mcMMOPlayer.getPtpEnabled()) { - player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled")); - } - - mcMMOPlayer.togglePtpUse(); - return true; - } - - private boolean canTeleport(String targetName) { - if (!mcMMO.p.getServer().getOfflinePlayer(targetName).isOnline()) { - player.sendMessage(LocaleLoader.getString("Party.NotOnline", targetName)); - return false; - } - - mcMMOTarget = Users.getPlayer(targetName); - - if (mcMMOTarget == null) { - player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); - return false; - } - - target = mcMMOTarget.getPlayer(); - - if (player.equals(target)) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); - return false; - } - - if (!PartyManager.inSameParty(player, target)) { - player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); - return false; - } - - if (!mcMMOTarget.getPtpEnabled()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", target.getName())); - return false; - } - - if (target.isDead()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); - return false; - } - - return true; - } - - private boolean handlePartyTeleportEvent(Player player, Player target) { - McMMOPlayer mcMMOPlayer= Users.getPlayer(player); - - McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName()); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return true; - } - - player.teleport(target); - player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", target.getName())); - target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", player.getName())); - mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis()); - return true; - } +package com.gmail.nossr50.commands.party; + +import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.commands.CommandUtils; +import com.gmail.nossr50.util.player.UserManager; + +public class PtpCommand implements CommandExecutor { + private Player player; + private McMMOPlayer mcMMOPlayer; + private PlayerProfile playerProfile; + + private Player target; + private McMMOPlayer mcMMOTarget; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + + switch (args.length) { + case 1: + player = (Player) sender; + mcMMOPlayer = UserManager.getPlayer(player); + playerProfile = mcMMOPlayer.getProfile(); + + if (args[0].equalsIgnoreCase("toggle")) { + if (!Permissions.partyTeleportToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + return togglePartyTeleportation(); + } + + if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { + if (!Permissions.partyTeleportAcceptAll(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + return acceptAnyTeleportRequest(); + } + + int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); + + if (playerProfile.getRecentlyHurt() + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown)); + return true; + } + + if (args[0].equalsIgnoreCase("accept")) { + if (!Permissions.partyTeleportAccept(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + return acceptTeleportRequest(); + } + + return sendTeleportRequest(args[0]); + + default: + return false; + } + } + + private boolean sendTeleportRequest(String targetName) { + if (!canTeleport(targetName)) { + return true; + } + + if (!mcMMOTarget.getPtpConfirmRequired()) { + return handlePartyTeleportEvent(player, target); + } + + mcMMOTarget.setPtpRequest(player); + mcMMOTarget.actualizePtpTimeout(); + player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); + + int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout(); + target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); + target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire)); + return true; + } + + private boolean acceptTeleportRequest() { + if (!mcMMOPlayer.hasPtpRequest()) { + player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests")); + return true; + } + + int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout(); + + if ((mcMMOPlayer.getPtpTimeout() + ptpRequestExpire) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) { + mcMMOPlayer.removePtpRequest(); + player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired")); + return true; + } + + target = mcMMOPlayer.getPtpRequest(); + + if (!canTeleport(target.getName())) { + mcMMOPlayer.removePtpRequest(); + return true; + } + + if (Config.getInstance().getPTPCommandWorldPermissions()) { + World targetWorld = target.getWorld(); + World playerWorld = player.getWorld(); + + if (!Permissions.partyTeleportAllWorlds(target)) { + if (!Permissions.partyTeleportWorld(target, targetWorld)) { + target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName())); + return true; + } + else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) { + target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName())); + return true; + } + } + } + + return handlePartyTeleportEvent(target, player); + } + + private boolean acceptAnyTeleportRequest() { + if (mcMMOPlayer.getPtpConfirmRequired()) { + player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled")); + } + + mcMMOPlayer.togglePtpConfirmRequired(); + return true; + } + + private boolean togglePartyTeleportation() { + if (mcMMOPlayer.getPtpEnabled()) { + player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled")); + } + + mcMMOPlayer.togglePtpUse(); + return true; + } + + private boolean canTeleport(String targetName) { + if (!mcMMO.p.getServer().getOfflinePlayer(targetName).isOnline()) { + player.sendMessage(LocaleLoader.getString("Party.NotOnline", targetName)); + return false; + } + + mcMMOTarget = UserManager.getPlayer(targetName); + + if (mcMMOTarget == null) { + player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); + return false; + } + + target = mcMMOTarget.getPlayer(); + + if (player.equals(target)) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); + return false; + } + + if (!PartyManager.inSameParty(player, target)) { + player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); + return false; + } + + if (!mcMMOTarget.getPtpEnabled()) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", target.getName())); + return false; + } + + if (target.isDead()) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); + return false; + } + + return true; + } + + private boolean handlePartyTeleportEvent(Player player, Player target) { + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName()); + mcMMO.p.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return true; + } + + player.teleport(target); + player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", target.getName())); + target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", player.getName())); + mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis()); + return true; + } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java index 5dcec8421..24f6967ce 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -5,14 +5,14 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.gmail.nossr50.commands.CommandHelper; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.commands.CommandUtils; +import com.gmail.nossr50.util.player.UserManager; public class InspectCommand implements CommandExecutor { @Override @@ -20,68 +20,68 @@ public class InspectCommand implements CommandExecutor { PlayerProfile profile; switch (args.length) { - case 1: - McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); + case 1: + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); - // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. - if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); //Temporary Profile + // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. + if (mcMMOPlayer == null) { + profile = new PlayerProfile(args[0], false); // Temporary Profile - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - // TODO: Why do we care if this is a player? - if (sender instanceof Player && !Permissions.inspectOffline(sender)) { - sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0])); - - sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION))); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING))); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM))); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING))); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING))); - - sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES))); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY))); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS))); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING))); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED))); - - sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS))); - sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR))); - } - else { - Player target = mcMMOPlayer.getPlayer(); - - if (sender instanceof Player) { - Player inspector = (Player) sender; - - if (!Misc.isNear(inspector.getLocation(), target.getLocation(), 5.0) && !Permissions.inspectFar(inspector)) { - sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); return true; } + + // TODO: Why do we care if this is a player? + if (sender instanceof Player && !Permissions.inspectOffline(sender)) { + sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); + return true; + } + + sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0])); + + sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION))); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING))); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM))); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING))); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING))); + + sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES))); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY))); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS))); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING))); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED))); + + sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS))); + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR))); } - profile = mcMMOPlayer.getProfile(); + else { + Player target = mcMMOPlayer.getPlayer(); - sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); - CommandHelper.printGatheringSkills(target, profile, sender); - CommandHelper.printCombatSkills(target, profile, sender); - CommandHelper.printMiscSkills(target, profile, sender); - sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); - } + if (sender instanceof Player) { + Player inspector = (Player) sender; - return true; + if (!Misc.isNear(inspector.getLocation(), target.getLocation(), 5.0) && !Permissions.inspectFar(inspector)) { + sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); + return true; + } + } + profile = mcMMOPlayer.getProfile(); - default: - return false; + sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); + CommandUtils.printGatheringSkills(target, profile, sender); + CommandUtils.printCombatSkills(target, profile, sender); + CommandUtils.printMiscSkills(target, profile, sender); + sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); + } + + return true; + + default: + return false; } } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McabilityCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McabilityCommand.java deleted file mode 100644 index 2d55255a2..000000000 --- a/src/main/java/com/gmail/nossr50/commands/player/McabilityCommand.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.gmail.nossr50.commands.player; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class McabilityCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - - switch (args.length) { - case 0: - if (!Permissions.mcability(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - profile = Users.getPlayer((Player) sender).getProfile(); - - if (profile.getAbilityUse()) { - sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off")); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Ability.On")); - } - - profile.toggleAbilityUse(); - return true; - - case 1: - if (!Permissions.mcabilityOthers(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); - - if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); - - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); - return true; - } - - Player player = mcMMOPlayer.getPlayer(); - profile = mcMMOPlayer.getProfile(); - - if (!player.isOnline()) { - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); - return true; - } - - if (profile.getAbilityUse()) { - player.sendMessage(LocaleLoader.getString("Commands.Ability.Off")); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.Ability.On")); - } - - profile.toggleAbilityUse(); - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/player/McnotifyCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McnotifyCommand.java deleted file mode 100644 index 345324300..000000000 --- a/src/main/java/com/gmail/nossr50/commands/player/McnotifyCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.gmail.nossr50.commands.player; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Users; - -public class McnotifyCommand implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - PlayerProfile profile = Users.getPlayer((Player) sender).getProfile(); - - if (profile.useChatNotifications()) { - sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off")); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On")); - } - - profile.toggleChatNotifications(); - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index 0a76d52dd..5e0e60cad 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -8,83 +8,83 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.Leaderboard; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.database.LeaderboardManager; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.runnables.McRankAsync; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; public class McrankCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { - case 0: - if (!Permissions.mcrank(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } + case 0: + if (!Permissions.mcrank(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } - if (!(sender instanceof Player)) { + if (!(sender instanceof Player)) { + return false; + } + + if (Config.getInstance().getUseMySQL()) { + sqlDisplay(sender, sender.getName()); + } + else { + LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date + flatfileDisplay(sender, sender.getName()); + } + + return true; + + case 1: + if (!Permissions.mcrankOthers(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + + if (mcMMOPlayer == null) { + PlayerProfile profile = new PlayerProfile(args[0], false); // Temporary Profile + + if (!profile.isLoaded()) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + if (sender instanceof Player && !Permissions.mcrankOffline(sender)) { + sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); + return true; + } + } + else { + Player target = mcMMOPlayer.getPlayer(); + + if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.mcrankFar(sender)) { + sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); + return true; + } + } + + if (Config.getInstance().getUseMySQL()) { + sqlDisplay(sender, args[0]); + } + else { + LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date + flatfileDisplay(sender, args[0]); + } + + return true; + + default: return false; - } - - if (Config.getInstance().getUseMySQL()) { - sqlDisplay(sender, sender.getName()); - } - else { - Leaderboard.updateLeaderboards(); // Make sure the information is up to date - flatfileDisplay(sender, sender.getName()); - } - - return true; - - case 1: - if (!Permissions.mcrankOthers(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); - - if (mcMMOPlayer == null) { - PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile - - if (!profile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - if (sender instanceof Player && !Permissions.mcrankOffline(sender)) { - sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); - return true; - } - } - else { - Player target = mcMMOPlayer.getPlayer(); - - if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.mcrankFar(sender)) { - sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); - return true; - } - } - - if (Config.getInstance().getUseMySQL()) { - sqlDisplay(sender, args[0]); - } - else { - Leaderboard.updateLeaderboards(); // Make sure the information is up to date - flatfileDisplay(sender, args[0]); - } - - return true; - - default: - return false; } } @@ -93,22 +93,22 @@ public class McrankCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName)); for (SkillType skillType : SkillType.values()) { - int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType); + int[] rankInts = LeaderboardManager.getPlayerRank(playerName, skillType); if (skillType.isChildSkill()) { continue; } if (rankInts[1] == 0) { - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills } else { - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), rankInts[0])); + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), rankInts[0])); } } // Show the powerlevel ranking - int[] rankInts = Leaderboard.getPlayerRank(playerName); + int[] rankInts = LeaderboardManager.getPlayerRank(playerName); if (rankInts[1] == 0) { sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills @@ -119,6 +119,6 @@ public class McrankCommand implements CommandExecutor { } private void sqlDisplay(CommandSender sender, String playerName) { - Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McRankAsync(playerName, sender)); + Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McrankCommandAsyncTask(playerName, sender)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java index 4d3f24843..fba5c75cf 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java @@ -1,50 +1,50 @@ -package com.gmail.nossr50.commands.player; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.commands.CommandHelper; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Users; - -public class McstatsCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noConsoleUsage(sender)) { - return true; - } - - switch (args.length) { - case 0: - Player player = (Player) sender; - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); - PlayerProfile profile = mcMMOPlayer.getProfile(); - - player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); - player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); - - CommandHelper.printGatheringSkills(player, profile); - CommandHelper.printCombatSkills(player, profile); - CommandHelper.printMiscSkills(player, profile); - - int powerLevelCap = Config.getInstance().getPowerLevelCap(); - - if (powerLevelCap != Integer.MAX_VALUE) { - player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", mcMMOPlayer.getPowerLevel(), powerLevelCap)); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); - } - - return true; - - default: - return false; - } - } -} +package com.gmail.nossr50.commands.player; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.commands.CommandUtils; +import com.gmail.nossr50.util.player.UserManager; + +public class McstatsCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + + switch (args.length) { + case 0: + Player player = (Player) sender; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + PlayerProfile profile = mcMMOPlayer.getProfile(); + + player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); + player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); + + CommandUtils.printGatheringSkills(player, profile); + CommandUtils.printCombatSkills(player, profile); + CommandUtils.printMiscSkills(player, profile); + + int powerLevelCap = Config.getInstance().getPowerLevelCap(); + + if (powerLevelCap != Integer.MAX_VALUE) { + player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", mcMMOPlayer.getPowerLevel(), powerLevelCap)); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); + } + + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index a4428215b..4d23bd9a2 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -1,115 +1,115 @@ -package com.gmail.nossr50.commands.player; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.Leaderboard; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.runnables.McTopAsync; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; - -public class MctopCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - boolean useMySQL = Config.getInstance().getUseMySQL(); - - switch (args.length) { - case 0: - display(1, "ALL", sender, useMySQL, command); - return true; - - case 1: - if (StringUtils.isInt(args[0])) { - display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command); - } - else if (SkillTools.isSkill(args[0])) { - display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - } - - return true; - - case 2: - if (!StringUtils.isInt(args[1])) { - return false; - } - - if (SkillTools.isSkill(args[0])) { - display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - } - - return true; - - default: - return false; - } - } - - private void display(int page, String skill, CommandSender sender, boolean sql, Command command) { - if (sql) { - if (skill.equalsIgnoreCase("all")) { - sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command); - } - else { - sqlDisplay(page, skill, sender, command); - } - } - else { - flatfileDisplay(page, skill, sender, command); - } - } - - private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) { - if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) { - sender.sendMessage(command.getPermissionMessage()); - return; - } - - Leaderboard.updateLeaderboards(); //Make sure we have the latest information - - String[] info = Leaderboard.retrieveInfo(skill, page); - - if (skill.equalsIgnoreCase("all")) { - sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill))); - } - - int n = (page * 10) - 9; // Position - for (String x : info) { - if (x != null) { - String digit = String.valueOf(n); - - if (n < 10) { - digit = "0" + digit; - } - - String[] splitx = x.split(":"); - - // Format: 1. Playername - skill value - sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]); - n++; - } - } - - sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip")); - } - - private void sqlDisplay(int page, String query, CommandSender sender, Command command) { - Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McTopAsync(page, query, sender, command)); - } -} +package com.gmail.nossr50.commands.player; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.database.LeaderboardManager; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class MctopCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + boolean useMySQL = Config.getInstance().getUseMySQL(); + + switch (args.length) { + case 0: + display(1, "ALL", sender, useMySQL, command); + return true; + + case 1: + if (StringUtils.isInt(args[0])) { + display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command); + } + else if (SkillUtils.isSkill(args[0])) { + display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + } + + return true; + + case 2: + if (!StringUtils.isInt(args[1])) { + return false; + } + + if (SkillUtils.isSkill(args[0])) { + display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + } + + return true; + + default: + return false; + } + } + + private void display(int page, String skill, CommandSender sender, boolean sql, Command command) { + if (sql) { + if (skill.equalsIgnoreCase("all")) { + sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command); + } + else { + sqlDisplay(page, skill, sender, command); + } + } + else { + flatfileDisplay(page, skill, sender, command); + } + } + + private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) { + if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) { + sender.sendMessage(command.getPermissionMessage()); + return; + } + + LeaderboardManager.updateLeaderboards(); // Make sure we have the latest information + + String[] info = LeaderboardManager.retrieveInfo(skill, page); + + if (skill.equalsIgnoreCase("all")) { + sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill))); + } + + int n = (page * 10) - 9; // Position + for (String x : info) { + if (x != null) { + String digit = String.valueOf(n); + + if (n < 10) { + digit = "0" + digit; + } + + String[] splitx = x.split(":"); + + // Format: 1. Playername - skill value + sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]); + n++; + } + } + + sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip")); + } + + private void sqlDisplay(int page, String query, CommandSender sender, Command command) { + Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command)); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java similarity index 92% rename from src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index 29d64e587..481651ccb 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -1,105 +1,105 @@ -package com.gmail.nossr50.skills.acrobatics; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class AcrobaticsCommand extends SkillCommand { - private String dodgeChance; - private String dodgeChanceLucky; - private String rollChance; - private String rollChanceLucky; - private String gracefulRollChance; - private String gracefulRollChanceLucky; - - private boolean canDodge; - private boolean canRoll; - private boolean canGracefulRoll; - - public AcrobaticsCommand() { - super(SkillType.ACROBATICS); - } - - @Override - protected void dataCalculations() { - //DODGE - String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance); - dodgeChance = dodgeStrings[0]; - dodgeChanceLucky = dodgeStrings[1]; - - //ROLL - String[] rollStrings = calculateAbilityDisplayValues(Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance); - rollChance = rollStrings[0]; - rollChanceLucky = rollStrings[1]; - - //GRACEFUL ROLL - String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance); - gracefulRollChance = gracefulRollStrings[0]; - gracefulRollChanceLucky = gracefulRollStrings[1]; - } - - @Override - protected void permissionsCheck() { - canDodge = Permissions.dodge(player); - canRoll = Permissions.roll(player); - canGracefulRoll = Permissions.gracefulRoll(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canDodge || canGracefulRoll || canRoll; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canRoll) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1"))); - } - - if (canGracefulRoll) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3"))); - } - - if (canDodge) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canDodge || canGracefulRoll || canRoll; - } - - @Override - protected void statsDisplay() { - if (canRoll) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { rollChanceLucky })); - } - else { - player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance })); - } - } - - if (canGracefulRoll) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { gracefulRollChanceLucky })); - } - else { - player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance })); - } - } - - if (canDodge) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { dodgeChanceLucky })); - } - else { - player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance })); - } - } - } -} \ No newline at end of file +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.acrobatics.Acrobatics; +import com.gmail.nossr50.util.Permissions; + +public class AcrobaticsCommand extends SkillCommand { + private String dodgeChance; + private String dodgeChanceLucky; + private String rollChance; + private String rollChanceLucky; + private String gracefulRollChance; + private String gracefulRollChanceLucky; + + private boolean canDodge; + private boolean canRoll; + private boolean canGracefulRoll; + + public AcrobaticsCommand() { + super(SkillType.ACROBATICS); + } + + @Override + protected void dataCalculations() { + // DODGE + String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance); + dodgeChance = dodgeStrings[0]; + dodgeChanceLucky = dodgeStrings[1]; + + // ROLL + String[] rollStrings = calculateAbilityDisplayValues(Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance); + rollChance = rollStrings[0]; + rollChanceLucky = rollStrings[1]; + + // GRACEFUL ROLL + String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance); + gracefulRollChance = gracefulRollStrings[0]; + gracefulRollChanceLucky = gracefulRollStrings[1]; + } + + @Override + protected void permissionsCheck() { + canDodge = Permissions.dodge(player); + canRoll = Permissions.roll(player); + canGracefulRoll = Permissions.gracefulRoll(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canDodge || canGracefulRoll || canRoll; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canRoll) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1"))); + } + + if (canGracefulRoll) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3"))); + } + + if (canDodge) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canDodge || canGracefulRoll || canRoll; + } + + @Override + protected void statsDisplay() { + if (canRoll) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { rollChanceLucky })); + } + else { + player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance })); + } + } + + if (canGracefulRoll) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { gracefulRollChanceLucky })); + } + else { + player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance })); + } + } + + if (canDodge) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { dodgeChanceLucky })); + } + else { + player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance })); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java similarity index 92% rename from src/main/java/com/gmail/nossr50/skills/archery/ArcheryCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java index db7af3b29..9901e2708 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -1,104 +1,104 @@ -package com.gmail.nossr50.skills.archery; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class ArcheryCommand extends SkillCommand { - private String skillShotBonus; - private String dazeChance; - private String dazeChanceLucky; - private String retrieveChance; - private String retrieveChanceLucky; - - private boolean canSkillShot; - private boolean canDaze; - private boolean canRetrieve; - - public ArcheryCommand() { - super(SkillType.ARCHERY); - } - - @Override - protected void dataCalculations() { - //SKILL SHOT - double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage; - - if (bonus > Archery.skillShotMaxBonusPercentage) { - skillShotBonus = percent.format(Archery.skillShotMaxBonusPercentage); - } - else { - skillShotBonus = percent.format(bonus); - } - - //DAZE - String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus); - dazeChance = dazeStrings[0]; - dazeChanceLucky = dazeStrings[1]; - - //RETRIEVE - String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance); - retrieveChance = retrieveStrings[0]; - retrieveChanceLucky = retrieveStrings[1]; - } - - @Override - protected void permissionsCheck() { - canSkillShot = Permissions.bonusDamage(player, skill); - canDaze = Permissions.daze(player); - canRetrieve = Permissions.arrowRetrieval(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canSkillShot || canDaze || canRetrieve; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canSkillShot) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1"))); - } - - if (canDaze) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier))); - } - - if (canRetrieve) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canSkillShot || canDaze || canRetrieve; - } - - @Override - protected void statsDisplay() { - if (canSkillShot) { - player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus)); - } - - if (canDaze) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance)); - } - } - - if (canRetrieve) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.archery.Archery; +import com.gmail.nossr50.util.Permissions; + +public class ArcheryCommand extends SkillCommand { + private String skillShotBonus; + private String dazeChance; + private String dazeChanceLucky; + private String retrieveChance; + private String retrieveChanceLucky; + + private boolean canSkillShot; + private boolean canDaze; + private boolean canRetrieve; + + public ArcheryCommand() { + super(SkillType.ARCHERY); + } + + @Override + protected void dataCalculations() { + // SKILL SHOT + double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage; + + if (bonus > Archery.skillShotMaxBonusPercentage) { + skillShotBonus = percent.format(Archery.skillShotMaxBonusPercentage); + } + else { + skillShotBonus = percent.format(bonus); + } + + // DAZE + String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus); + dazeChance = dazeStrings[0]; + dazeChanceLucky = dazeStrings[1]; + + // RETRIEVE + String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance); + retrieveChance = retrieveStrings[0]; + retrieveChanceLucky = retrieveStrings[1]; + } + + @Override + protected void permissionsCheck() { + canSkillShot = Permissions.bonusDamage(player, skill); + canDaze = Permissions.daze(player); + canRetrieve = Permissions.arrowRetrieval(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canSkillShot || canDaze || canRetrieve; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canSkillShot) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1"))); + } + + if (canDaze) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier))); + } + + if (canRetrieve) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canSkillShot || canDaze || canRetrieve; + } + + @Override + protected void statsDisplay() { + if (canSkillShot) { + player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus)); + } + + if (canDaze) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance)); + } + } + + if (canRetrieve) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java similarity index 93% rename from src/main/java/com/gmail/nossr50/skills/axes/AxesCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java index cf9d7e002..45c341df1 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -1,128 +1,128 @@ -package com.gmail.nossr50.skills.axes; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class AxesCommand extends SkillCommand { - private String critChance; - private String critChanceLucky; - private String bonusDamage; - private String impactDamage; - private String greaterImpactDamage; - private String skullSplitterLength; - private String skullSplitterLengthEndurance; - - private boolean canSkullSplitter; - private boolean canCritical; - private boolean canBonusDamage; - private boolean canImpact; - private boolean canGreaterImpact; - - public AxesCommand() { - super(SkillType.AXES); - } - - @Override - protected void dataCalculations() { - //IMPACT - impactDamage = String.valueOf(1 + (skillValue / Axes.impactIncreaseLevel)); - greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage); - - //SKULL SPLITTER - String[] skullSplitterStrings = calculateLengthDisplayValues(); - skullSplitterLength = skullSplitterStrings[0]; - skullSplitterLengthEndurance = skullSplitterStrings[1]; - - //CRITICAL STRIKES - String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance); - critChance = criticalStrikeStrings[0]; - critChanceLucky = criticalStrikeStrings[1]; - - //AXE MASTERY - if (skillValue >= Axes.bonusDamageMaxBonusLevel) { - bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus); - } - else { - bonusDamage = String.valueOf(skillValue / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus)); - } - } - - @Override - protected void permissionsCheck() { - canSkullSplitter = Permissions.skullSplitter(player); - canCritical = Permissions.criticalStrikes(player); - canBonusDamage = Permissions.bonusDamage(player, skill); - canImpact = Permissions.armorImpact(player); - canGreaterImpact = Permissions.greaterImpact(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canSkullSplitter) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1"))); - } - - if (canCritical) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3"))); - } - - if (canBonusDamage) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5"))); - } - - if (canImpact) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7"))); - } - - if (canGreaterImpact) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact; - } - - @Override - protected void statsDisplay() { - if (canBonusDamage) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage))); - } - - if (canImpact) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage))); - } - - if (canGreaterImpact) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", greaterImpactDamage))); - } - - if (canCritical) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance)); - } - } - - if (canSkullSplitter) { - if (hasEndurance) { - player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance)); - } - else { - player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.axes.Axes; +import com.gmail.nossr50.util.Permissions; + +public class AxesCommand extends SkillCommand { + private String critChance; + private String critChanceLucky; + private String bonusDamage; + private String impactDamage; + private String greaterImpactDamage; + private String skullSplitterLength; + private String skullSplitterLengthEndurance; + + private boolean canSkullSplitter; + private boolean canCritical; + private boolean canBonusDamage; + private boolean canImpact; + private boolean canGreaterImpact; + + public AxesCommand() { + super(SkillType.AXES); + } + + @Override + protected void dataCalculations() { + // IMPACT + impactDamage = String.valueOf(1 + (skillValue / Axes.impactIncreaseLevel)); + greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage); + + // SKULL SPLITTER + String[] skullSplitterStrings = calculateLengthDisplayValues(); + skullSplitterLength = skullSplitterStrings[0]; + skullSplitterLengthEndurance = skullSplitterStrings[1]; + + // CRITICAL STRIKES + String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance); + critChance = criticalStrikeStrings[0]; + critChanceLucky = criticalStrikeStrings[1]; + + // AXE MASTERY + if (skillValue >= Axes.bonusDamageMaxBonusLevel) { + bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus); + } + else { + bonusDamage = String.valueOf(skillValue / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus)); + } + } + + @Override + protected void permissionsCheck() { + canSkullSplitter = Permissions.skullSplitter(player); + canCritical = Permissions.criticalStrikes(player); + canBonusDamage = Permissions.bonusDamage(player, skill); + canImpact = Permissions.armorImpact(player); + canGreaterImpact = Permissions.greaterImpact(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canSkullSplitter) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1"))); + } + + if (canCritical) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3"))); + } + + if (canBonusDamage) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5"))); + } + + if (canImpact) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7"))); + } + + if (canGreaterImpact) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact; + } + + @Override + protected void statsDisplay() { + if (canBonusDamage) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage))); + } + + if (canImpact) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage))); + } + + if (canGreaterImpact) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", greaterImpactDamage))); + } + + if (canCritical) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance)); + } + } + + if (canSkullSplitter) { + if (hasEndurance) { + player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance)); + } + else { + player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java similarity index 89% rename from src/main/java/com/gmail/nossr50/skills/excavation/ExcavationCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index 913cf07e7..28f20e0f4 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -1,67 +1,66 @@ -package com.gmail.nossr50.skills.excavation; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class ExcavationCommand extends SkillCommand { - private String gigaDrillBreakerLength; - private String gigaDrillBreakerLengthEndurance; - - private boolean canGigaDrill; - private boolean canTreasureHunt; - - public ExcavationCommand() { - super(SkillType.EXCAVATION); - } - - @Override - protected void dataCalculations() { - //GIGA DRILL BREAKER - String gigaDrillStrings[] = calculateLengthDisplayValues(); - gigaDrillBreakerLength = gigaDrillStrings[0]; - gigaDrillBreakerLengthEndurance = gigaDrillStrings[1]; - } - - @Override - protected void permissionsCheck() { - canGigaDrill = Permissions.gigaDrillBreaker(player); - canTreasureHunt = Permissions.excavationTreasureHunter(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canGigaDrill || canTreasureHunt; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canGigaDrill) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1"))); - } - - if (canTreasureHunt) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canGigaDrill; - } - - @Override - protected void statsDisplay() { - if (canGigaDrill) { - if (hasEndurance) { - player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance)); - } - else { - player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; + +public class ExcavationCommand extends SkillCommand { + private String gigaDrillBreakerLength; + private String gigaDrillBreakerLengthEndurance; + + private boolean canGigaDrill; + private boolean canTreasureHunt; + + public ExcavationCommand() { + super(SkillType.EXCAVATION); + } + + @Override + protected void dataCalculations() { + // GIGA DRILL BREAKER + String gigaDrillStrings[] = calculateLengthDisplayValues(); + gigaDrillBreakerLength = gigaDrillStrings[0]; + gigaDrillBreakerLengthEndurance = gigaDrillStrings[1]; + } + + @Override + protected void permissionsCheck() { + canGigaDrill = Permissions.gigaDrillBreaker(player); + canTreasureHunt = Permissions.excavationTreasureHunter(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canGigaDrill || canTreasureHunt; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canGigaDrill) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1"))); + } + + if (canTreasureHunt) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canGigaDrill; + } + + @Override + protected void statsDisplay() { + if (canGigaDrill) { + if (hasEndurance) { + player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance)); + } + else { + player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java similarity index 90% rename from src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index eb7db1053..603b09203 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -1,125 +1,125 @@ -package com.gmail.nossr50.skills.fishing; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.SkillManagerStore; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class FishingCommand extends SkillCommand { - private int lootTier; - private String magicChance; - private String magicChanceLucky; - private String chanceRaining = ""; - private String shakeChance; - private String shakeChanceLucky; - private String fishermansDietRank; - - private boolean canTreasureHunt; - private boolean canMagicHunt; - private boolean canShake; - private boolean canFishermansDiet; - - public FishingCommand() { - super(SkillType.FISHING); - } - - @Override - protected void dataCalculations() { - lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier(); - - //TREASURE HUNTER - double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier(); - - if (player.getWorld().hasStorm()) { - chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining"); - enchantChance = enchantChance * 1.1D; - } - - String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance); - magicChance = treasureHunterStrings[0]; - magicChanceLucky = treasureHunterStrings[1]; - - //SHAKE - String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability()); - shakeChance = shakeStrings[0]; +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManagerStore; +import com.gmail.nossr50.skills.fishing.Fishing; +import com.gmail.nossr50.util.Permissions; + +public class FishingCommand extends SkillCommand { + private int lootTier; + private String magicChance; + private String magicChanceLucky; + private String chanceRaining = ""; + private String shakeChance; + private String shakeChanceLucky; + private String fishermansDietRank; + + private boolean canTreasureHunt; + private boolean canMagicHunt; + private boolean canShake; + private boolean canFishermansDiet; + + public FishingCommand() { + super(SkillType.FISHING); + } + + @Override + protected void dataCalculations() { + lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier(); + + // TREASURE HUNTER + double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier(); + + if (player.getWorld().hasStorm()) { + chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining"); + enchantChance = enchantChance * 1.1D; + } + + String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance); + magicChance = treasureHunterStrings[0]; + magicChanceLucky = treasureHunterStrings[1]; + + // SHAKE + String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability()); + shakeChance = shakeStrings[0]; shakeChanceLucky = shakeStrings[1]; - - //FISHERMAN'S DIET + + // FISHERMAN'S DIET fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1); - } - - @Override - protected void permissionsCheck() { - canTreasureHunt = Permissions.fishingTreasureHunter(player); - canMagicHunt = Permissions.magicHunter(player); - canShake = Permissions.shake(player); - canFishermansDiet = Permissions.fishermansDiet(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canTreasureHunt || canMagicHunt || canShake; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canTreasureHunt) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1"))); - } - - if (canMagicHunt) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3"))); - } - - if (canShake) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5"))); - } - - if (canFishermansDiet) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canTreasureHunt || canMagicHunt || canShake; - } - - @Override - protected void statsDisplay() { - if (canTreasureHunt) { - player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier)); - } - - if (canMagicHunt) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining); - } - } - - if (canShake) { - if (skillValue < AdvancedConfig.getInstance().getShakeUnlockLevel()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", AdvancedConfig.getInstance().getShakeUnlockLevel()))); - } - else { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance)); - } - } - } - - if (canFishermansDiet) { - player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank)); - } - } -} + } + + @Override + protected void permissionsCheck() { + canTreasureHunt = Permissions.fishingTreasureHunter(player); + canMagicHunt = Permissions.magicHunter(player); + canShake = Permissions.shake(player); + canFishermansDiet = Permissions.fishermansDiet(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canTreasureHunt || canMagicHunt || canShake; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canTreasureHunt) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1"))); + } + + if (canMagicHunt) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3"))); + } + + if (canShake) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5"))); + } + + if (canFishermansDiet) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canTreasureHunt || canMagicHunt || canShake; + } + + @Override + protected void statsDisplay() { + if (canTreasureHunt) { + player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier)); + } + + if (canMagicHunt) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining); + } + } + + if (canShake) { + if (skillValue < AdvancedConfig.getInstance().getShakeUnlockLevel()) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", AdvancedConfig.getInstance().getShakeUnlockLevel()))); + } + else { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance)); + } + } + } + + if (canFishermansDiet) { + player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank)); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java similarity index 93% rename from src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java index cf56d610e..9cee01d2e 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java @@ -1,180 +1,180 @@ -package com.gmail.nossr50.skills.herbalism; - -import org.bukkit.Material; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class HerbalismCommand extends SkillCommand { - private String greenTerraLength; - private String greenTerraLengthEndurance; - private String greenThumbChance; - private String greenThumbChanceLucky; - private String greenThumbStage; - private String farmersDietRank; - private String doubleDropChance; - private String doubleDropChanceLucky; - private String hylianLuckChance; - private String hylianLuckChanceLucky; - private String shroomThumbChance; - private String shroomThumbChanceLucky; - - private boolean hasHylianLuck; - private boolean canGreenTerra; - private boolean canGreenThumbWheat; - private boolean canGreenThumbBlocks; - private boolean canFarmersDiet; - private boolean canDoubleDrop; - private boolean canShroomThumb; - private boolean doubleDropsDisabled; - - public HerbalismCommand() { - super(SkillType.HERBALISM); - } - - @Override - protected void dataCalculations() { - //GREEN TERRA - String[] greenTerraStrings = calculateLengthDisplayValues(); - greenTerraLength = greenTerraStrings[0]; - greenTerraLengthEndurance = greenTerraStrings[1]; - - //FARMERS DIET - farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1); - - //GREEN THUMB - greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel); - - String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance); - greenThumbChance = greenThumbStrings[0]; - greenThumbChanceLucky = greenThumbStrings[1]; - - //DOUBLE DROPS - String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance); - doubleDropChance = doubleDropStrings[0]; - doubleDropChanceLucky = doubleDropStrings[1]; - - //HYLIAN LUCK - String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance); - hylianLuckChance = hylianLuckStrings[0]; - hylianLuckChanceLucky = hylianLuckStrings[1]; - - //SHROOM THUMB - String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance); - shroomThumbChance = shroomThumbStrings[0]; - shroomThumbChanceLucky = shroomThumbStrings[1]; - } - - @Override - protected void permissionsCheck() { - hasHylianLuck = Permissions.hylianLuck(player); - canGreenTerra = Permissions.greenTerra(player); - canGreenThumbWheat = Permissions.greenThumbPlant(player, Material.CROPS); //TODO: This isn't really accurate - they could have perms for other crops but not wheat. - canGreenThumbBlocks = (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK)); - canFarmersDiet = Permissions.farmersDiet(player); - canDoubleDrop = Permissions.doubleDrops(player, skill); - doubleDropsDisabled = skill.getDoubleDropsDisabled(); - canShroomThumb = Permissions.shroomThumb(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canGreenTerra) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1"))); - } - - if (canGreenThumbWheat) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3"))); - } - - if (canGreenThumbBlocks) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5"))); - } - - if (canFarmersDiet) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7"))); - } - - if (hasHylianLuck) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11"))); - } - - if (canShroomThumb) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13"))); - } - - if (canDoubleDrop && !doubleDropsDisabled) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb; - } - - @Override - protected void statsDisplay() { - if (canGreenTerra) { - if (hasEndurance) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance)); - } - else { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength)); - } - } - - if (canGreenThumbBlocks || canGreenThumbWheat) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance)); - } - } - - if (canGreenThumbWheat) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage)); - } - - if (canFarmersDiet) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank)); - } - - if (hasHylianLuck) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance)); - } - } - - if (canShroomThumb) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance)); - } - } - - if (canDoubleDrop && !doubleDropsDisabled) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import org.bukkit.Material; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.herbalism.Herbalism; +import com.gmail.nossr50.util.Permissions; + +public class HerbalismCommand extends SkillCommand { + private String greenTerraLength; + private String greenTerraLengthEndurance; + private String greenThumbChance; + private String greenThumbChanceLucky; + private String greenThumbStage; + private String farmersDietRank; + private String doubleDropChance; + private String doubleDropChanceLucky; + private String hylianLuckChance; + private String hylianLuckChanceLucky; + private String shroomThumbChance; + private String shroomThumbChanceLucky; + + private boolean hasHylianLuck; + private boolean canGreenTerra; + private boolean canGreenThumbWheat; + private boolean canGreenThumbBlocks; + private boolean canFarmersDiet; + private boolean canDoubleDrop; + private boolean canShroomThumb; + private boolean doubleDropsDisabled; + + public HerbalismCommand() { + super(SkillType.HERBALISM); + } + + @Override + protected void dataCalculations() { + // GREEN TERRA + String[] greenTerraStrings = calculateLengthDisplayValues(); + greenTerraLength = greenTerraStrings[0]; + greenTerraLengthEndurance = greenTerraStrings[1]; + + // FARMERS DIET + farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1); + + // GREEN THUMB + greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel); + + String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance); + greenThumbChance = greenThumbStrings[0]; + greenThumbChanceLucky = greenThumbStrings[1]; + + // DOUBLE DROPS + String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance); + doubleDropChance = doubleDropStrings[0]; + doubleDropChanceLucky = doubleDropStrings[1]; + + // HYLIAN LUCK + String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance); + hylianLuckChance = hylianLuckStrings[0]; + hylianLuckChanceLucky = hylianLuckStrings[1]; + + // SHROOM THUMB + String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance); + shroomThumbChance = shroomThumbStrings[0]; + shroomThumbChanceLucky = shroomThumbStrings[1]; + } + + @Override + protected void permissionsCheck() { + hasHylianLuck = Permissions.hylianLuck(player); + canGreenTerra = Permissions.greenTerra(player); + canGreenThumbWheat = Permissions.greenThumbPlant(player, Material.CROPS); // TODO: This isn't really accurate - they could have perms for other crops but not wheat. + canGreenThumbBlocks = (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK)); + canFarmersDiet = Permissions.farmersDiet(player); + canDoubleDrop = Permissions.doubleDrops(player, skill); + doubleDropsDisabled = skill.getDoubleDropsDisabled(); + canShroomThumb = Permissions.shroomThumb(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canGreenTerra) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1"))); + } + + if (canGreenThumbWheat) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3"))); + } + + if (canGreenThumbBlocks) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5"))); + } + + if (canFarmersDiet) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7"))); + } + + if (hasHylianLuck) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11"))); + } + + if (canShroomThumb) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13"))); + } + + if (canDoubleDrop && !doubleDropsDisabled) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb; + } + + @Override + protected void statsDisplay() { + if (canGreenTerra) { + if (hasEndurance) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance)); + } + else { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength)); + } + } + + if (canGreenThumbBlocks || canGreenThumbWheat) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance)); + } + } + + if (canGreenThumbWheat) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage)); + } + + if (canFarmersDiet) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank)); + } + + if (hasHylianLuck) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance)); + } + } + + if (canShroomThumb) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance)); + } + } + + if (canDoubleDrop && !doubleDropsDisabled) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java similarity index 94% rename from src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java index dd44ee0f7..3c2a67db2 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java @@ -1,148 +1,149 @@ -package com.gmail.nossr50.skills.mining; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.SkillManagerStore; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class MiningCommand extends SkillCommand { - private String doubleDropChance; - private String doubleDropChanceLucky; - private String superBreakerLength; - private String superBreakerLengthEndurance; - - private int blastMiningRank; - private int bonusTNTDrops; - private double blastRadiusIncrease; - private String oreBonus; - private String debrisReduction; - private String blastDamageDecrease; - - private boolean canSuperBreaker; - private boolean canDoubleDrop; - private boolean canBlast; - private boolean canBiggerBombs; - private boolean canDemoExpert; - private boolean doubleDropsDisabled; - - public MiningCommand() { - super(SkillType.MINING); - } - - @Override - protected void dataCalculations() { - //SUPER BREAKER - String[] superBreakerStrings = calculateLengthDisplayValues(); - superBreakerLength = superBreakerStrings[0]; - superBreakerLengthEndurance = superBreakerStrings[1]; - - //DOUBLE DROPS - String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance); - doubleDropChance = doubleDropStrings[0]; - doubleDropChanceLucky = doubleDropStrings[1]; - - //BLAST MINING - MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); - blastMiningRank = miningManager.getBlastMiningTier(); - bonusTNTDrops = miningManager.getDropMultiplier(); - oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30% - debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30% - blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D); - blastRadiusIncrease = miningManager.getBlastRadiusModifier(); - } - - @Override - protected void permissionsCheck() { - canBiggerBombs = Permissions.biggerBombs(player); - canBlast = Permissions.remoteDetonation(player); - canDemoExpert = Permissions.demolitionsExpertise(player); - canDoubleDrop = Permissions.doubleDrops(player, skill); - canSuperBreaker = Permissions.superBreaker(player); - doubleDropsDisabled = skill.getDoubleDropsDisabled(); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canSuperBreaker) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1"))); - } - - if (canDoubleDrop && !doubleDropsDisabled) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3"))); - } - - if (canBlast) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5"))); - } - - if (canBiggerBombs) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7"))); - } - - if (canDemoExpert) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker; - } - - @Override - protected void statsDisplay() { - if (canDoubleDrop && !doubleDropsDisabled) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance)); - } - } - - if (canSuperBreaker) { - if (hasEndurance) { - player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance)); - } - else { - player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength)); - } - } - - if (canBlast) { - if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank1()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", AdvancedConfig.getInstance().getBlastMiningRank1()))); - } - else { - player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); - } - } - - if (canBiggerBombs) { - if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank2()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", AdvancedConfig.getInstance().getBlastMiningRank2()))); - } - else { - player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease)); - } - } - - if (canDemoExpert) { - if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank4()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", AdvancedConfig.getInstance().getBlastMiningRank4()))); - } - else { - player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManagerStore; +import com.gmail.nossr50.skills.mining.Mining; +import com.gmail.nossr50.skills.mining.MiningManager; +import com.gmail.nossr50.util.Permissions; + +public class MiningCommand extends SkillCommand { + private String doubleDropChance; + private String doubleDropChanceLucky; + private String superBreakerLength; + private String superBreakerLengthEndurance; + + private int blastMiningRank; + private int bonusTNTDrops; + private double blastRadiusIncrease; + private String oreBonus; + private String debrisReduction; + private String blastDamageDecrease; + + private boolean canSuperBreaker; + private boolean canDoubleDrop; + private boolean canBlast; + private boolean canBiggerBombs; + private boolean canDemoExpert; + private boolean doubleDropsDisabled; + + public MiningCommand() { + super(SkillType.MINING); + } + + @Override + protected void dataCalculations() { + // SUPER BREAKER + String[] superBreakerStrings = calculateLengthDisplayValues(); + superBreakerLength = superBreakerStrings[0]; + superBreakerLengthEndurance = superBreakerStrings[1]; + + // DOUBLE DROPS + String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance); + doubleDropChance = doubleDropStrings[0]; + doubleDropChanceLucky = doubleDropStrings[1]; + + // BLAST MINING + MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); + blastMiningRank = miningManager.getBlastMiningTier(); + bonusTNTDrops = miningManager.getDropMultiplier(); + oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30% + debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30% + blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D); + blastRadiusIncrease = miningManager.getBlastRadiusModifier(); + } + + @Override + protected void permissionsCheck() { + canBiggerBombs = Permissions.biggerBombs(player); + canBlast = Permissions.remoteDetonation(player); + canDemoExpert = Permissions.demolitionsExpertise(player); + canDoubleDrop = Permissions.doubleDrops(player, skill); + canSuperBreaker = Permissions.superBreaker(player); + doubleDropsDisabled = skill.getDoubleDropsDisabled(); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canSuperBreaker) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1"))); + } + + if (canDoubleDrop && !doubleDropsDisabled) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3"))); + } + + if (canBlast) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5"))); + } + + if (canBiggerBombs) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7"))); + } + + if (canDemoExpert) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker; + } + + @Override + protected void statsDisplay() { + if (canDoubleDrop && !doubleDropsDisabled) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance)); + } + } + + if (canSuperBreaker) { + if (hasEndurance) { + player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance)); + } + else { + player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength)); + } + } + + if (canBlast) { + if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank1()) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", AdvancedConfig.getInstance().getBlastMiningRank1()))); + } + else { + player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); + } + } + + if (canBiggerBombs) { + if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank2()) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", AdvancedConfig.getInstance().getBlastMiningRank2()))); + } + else { + player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease)); + } + } + + if (canDemoExpert) { + if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank4()) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", AdvancedConfig.getInstance().getBlastMiningRank4()))); + } + else { + player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java similarity index 88% rename from src/main/java/com/gmail/nossr50/skills/repair/RepairCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 43dfe5bba..a05c16527 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -1,164 +1,166 @@ -package com.gmail.nossr50.skills.repair; - -import org.bukkit.Material; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class RepairCommand extends SkillCommand { - private int arcaneForgingRank; - private String repairMasteryBonus; - private String superRepairChance; - private String superRepairChanceLucky; - - private boolean canSuperRepair; - private boolean canMasterRepair; - private boolean canArcaneForge; - private boolean canSalvage; - private boolean canRepairStone; - private boolean canRepairIron; - private boolean canRepairGold; - private boolean canRepairDiamond; - private boolean canRepairString; - private boolean canRepairLeather; - private boolean canRepairWood; - private boolean arcaneBypass; - - private int diamondLevel; - private int goldLevel; - private int ironLevel; - private int stoneLevel; - - public RepairCommand() { - super(SkillType.REPAIR); - } - - @Override - protected void dataCalculations() { - // We're using pickaxes here, not the best but it works - Repairable diamondRepairable = mcMMO.repairManager.getRepairable(Material.DIAMOND_PICKAXE.getId()); - Repairable goldRepairable = mcMMO.repairManager.getRepairable(Material.GOLD_PICKAXE.getId()); - Repairable ironRepairable = mcMMO.repairManager.getRepairable(Material.IRON_PICKAXE.getId()); - Repairable stoneRepairable = mcMMO.repairManager.getRepairable(Material.STONE_PICKAXE.getId()); - - //TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0 - diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel(); - goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel(); - ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel(); - stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel(); - - //REPAIR MASTERY - if (skillValue >= Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) { - repairMasteryBonus = percent.format(Repair.REPAIR_MASTERY_CHANCE_MAX / 100D); - } - else { - repairMasteryBonus = percent.format((( Repair.REPAIR_MASTERY_CHANCE_MAX / Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) * skillValue) / 100D); - } - - //SUPER REPAIR - String[] superRepairStrings = calculateAbilityDisplayValues(Repair.SUPER_REPAIR_MAX_BONUS_LEVEL, Repair.SUPER_REPAIR_CHANCE_MAX); - superRepairChance = superRepairStrings[0]; - superRepairChanceLucky = superRepairStrings[1]; - - //ARCANE FORGING - arcaneForgingRank = Repair.getArcaneForgingRank(profile); - } - - @Override - protected void permissionsCheck() { - canSuperRepair = Permissions.superRepair(player); - canMasterRepair = Permissions.repairMastery(player); - canArcaneForge = Permissions.arcaneForging(player); - canSalvage = Permissions.salvage(player); - canRepairDiamond = Permissions.repairDiamond(player); - canRepairGold = Permissions.repairGold(player); - canRepairIron = Permissions.repairIron(player); - canRepairStone = Permissions.repairStone(player); - canRepairString = Permissions.repairString(player); - canRepairLeather = Permissions.repairLeather(player); - canRepairWood = Permissions.repairWood(player); - arcaneBypass = Permissions.arcaneBypass(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1"))); - - if (canMasterRepair) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3"))); - } - - if (canSuperRepair) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5"))); - } - - /* Repair Level Requirements */ - - if (canRepairStone && stoneLevel > 0) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15"))); - } - - if (canRepairIron && ironLevel > 0) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13"))); - } - - if (canRepairGold && goldLevel > 0) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11"))); - } - - if (canRepairDiamond && diamondLevel > 0) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7"))); - } - - if (canSalvage && Salvage.salvageUnlockLevel > 0) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Salvage.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17"))); - } - - if (canArcaneForge) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canArcaneForge || canMasterRepair || canSuperRepair; - } - - @Override - protected void statsDisplay() { - if (canMasterRepair) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus)); - } - - if (canSuperRepair) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance)); - } - } - - if (canArcaneForge) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank)); - - if (Repair.arcaneForgingEnchantLoss) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank)))); - } - - if (Repair.arcaneForgingDowngrades) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank)))); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import org.bukkit.Material; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.repair.Repair; +import com.gmail.nossr50.skills.repair.Repairable; +import com.gmail.nossr50.skills.repair.Salvage; +import com.gmail.nossr50.util.Permissions; + +public class RepairCommand extends SkillCommand { + private int arcaneForgingRank; + private String repairMasteryBonus; + private String superRepairChance; + private String superRepairChanceLucky; + + private boolean canSuperRepair; + private boolean canMasterRepair; + private boolean canArcaneForge; + private boolean canSalvage; + private boolean canRepairStone; + private boolean canRepairIron; + private boolean canRepairGold; + private boolean canRepairDiamond; + private boolean canRepairString; + private boolean canRepairLeather; + private boolean canRepairWood; + private boolean arcaneBypass; + + private int diamondLevel; + private int goldLevel; + private int ironLevel; + private int stoneLevel; + + public RepairCommand() { + super(SkillType.REPAIR); + } + + @Override + protected void dataCalculations() { + // We're using pickaxes here, not the best but it works + Repairable diamondRepairable = mcMMO.repairManager.getRepairable(Material.DIAMOND_PICKAXE.getId()); + Repairable goldRepairable = mcMMO.repairManager.getRepairable(Material.GOLD_PICKAXE.getId()); + Repairable ironRepairable = mcMMO.repairManager.getRepairable(Material.IRON_PICKAXE.getId()); + Repairable stoneRepairable = mcMMO.repairManager.getRepairable(Material.STONE_PICKAXE.getId()); + + // TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0 + diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel(); + goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel(); + ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel(); + stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel(); + + // REPAIR MASTERY + if (skillValue >= Repair.repairMasteryMaxBonusLevel) { + repairMasteryBonus = percent.format(Repair.repairMasteryMaxBonus / 100D); + } + else { + repairMasteryBonus = percent.format(((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * skillValue) / 100D); + } + + // SUPER REPAIR + String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance); + superRepairChance = superRepairStrings[0]; + superRepairChanceLucky = superRepairStrings[1]; + + // ARCANE FORGING + arcaneForgingRank = Repair.getArcaneForgingRank(profile); + } + + @Override + protected void permissionsCheck() { + canSuperRepair = Permissions.superRepair(player); + canMasterRepair = Permissions.repairMastery(player); + canArcaneForge = Permissions.arcaneForging(player); + canSalvage = Permissions.salvage(player); + canRepairDiamond = Permissions.repairDiamond(player); + canRepairGold = Permissions.repairGold(player); + canRepairIron = Permissions.repairIron(player); + canRepairStone = Permissions.repairStone(player); + canRepairString = Permissions.repairString(player); + canRepairLeather = Permissions.repairLeather(player); + canRepairWood = Permissions.repairWood(player); + arcaneBypass = Permissions.arcaneBypass(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1"))); + + if (canMasterRepair) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3"))); + } + + if (canSuperRepair) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5"))); + } + + /* Repair Level Requirements */ + + if (canRepairStone && stoneLevel > 0) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15"))); + } + + if (canRepairIron && ironLevel > 0) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13"))); + } + + if (canRepairGold && goldLevel > 0) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11"))); + } + + if (canRepairDiamond && diamondLevel > 0) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7"))); + } + + if (canSalvage && Salvage.salvageUnlockLevel > 0) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Salvage.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17"))); + } + + if (canArcaneForge) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canArcaneForge || canMasterRepair || canSuperRepair; + } + + @Override + protected void statsDisplay() { + if (canMasterRepair) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus)); + } + + if (canSuperRepair) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance)); + } + } + + if (canArcaneForge) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank)); + + if (Repair.arcaneForgingEnchantLoss) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank)))); + } + + if (Repair.arcaneForgingDowngrades) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank)))); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java similarity index 87% rename from src/main/java/com/gmail/nossr50/skills/SkillCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index b9b21b87f..1c7ee9654 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -1,159 +1,159 @@ -package com.gmail.nossr50.skills; - -import java.text.DecimalFormat; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.commands.CommandHelper; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.PerksUtils; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; - -public abstract class SkillCommand implements CommandExecutor { - protected SkillType skill; - private String skillString; - - protected Player player; - protected PlayerProfile profile; - protected float skillValue; - protected boolean isLucky; - protected boolean hasEndurance; - - protected DecimalFormat percent = new DecimalFormat("##0.00%"); - protected DecimalFormat decimal = new DecimalFormat("##0.00"); - - public SkillCommand(SkillType skill) { - this.skill = skill; - this.skillString = StringUtils.getCapitalized(skill.toString()); - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noConsoleUsage(sender)) { - return true; - } - - player = (Player) sender; - profile = Users.getPlayer(player).getProfile(); - - if (profile == null) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - skillValue = profile.getSkillLevel(skill); - isLucky = Permissions.lucky(sender, skill); - hasEndurance = (Permissions.twelveSecondActivationBoost(sender) || Permissions.eightSecondActivationBoost(sender) || Permissions.fourSecondActivationBoost(sender)); - - dataCalculations(); - permissionsCheck(); - - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString(skillString + ".SkillName"))); - - if (!skill.isChildSkill()) { - player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + skillString))); - player.sendMessage(LocaleLoader.getString("Effects.Level", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill))); - } - - if (effectsHeaderPermissions()) { - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); - } - - effectsDisplay(); - - if (statsHeaderPermissions()) { - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self"))); - } - - statsDisplay(); - - return SkillGuide.grabGuidePageForSkill(skill, player, args); - } - - protected String calculateRank(int maxLevel, int rankChangeLevel) { - if (skillValue >= maxLevel) { - return String.valueOf(maxLevel / rankChangeLevel); - } - - return String.valueOf((int) (skillValue / rankChangeLevel)); - } - - protected String[] calculateAbilityDisplayValues(double chance) { - if (isLucky) { - double luckyChance = chance * 1.3333D; - - if (luckyChance >= 100D) { - return new String[] { percent.format(chance / 100.0D), percent.format(1.0D) }; - } - - return new String[] { percent.format(chance / 100.0D), percent.format(luckyChance / 100.0D) }; - } - - return new String[] { percent.format(chance / 100.0D), null }; - } - - protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) { - double abilityChance; - - if (skillValue >= maxBonusLevel) { - abilityChance = maxChance; - } - else { - abilityChance = (maxChance / maxBonusLevel) * skillValue; - } - - if (isLucky) { - double luckyChance = abilityChance * 1.3333D; - - if (luckyChance >= 100D) { - return new String[] { percent.format(abilityChance / 100.0D), percent.format(1.0D) }; - } - - return new String[] { percent.format(abilityChance / 100.0D), percent.format(luckyChance / 100.0D) }; - } - - return new String[] { percent.format(abilityChance / 100.0D), null }; - } - - protected String[] calculateLengthDisplayValues() { - int maxLength = skill.getAbility().getMaxTicks(); - int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength()); - int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength); - - if (maxLength != 0) { - if (length > maxLength) { - length = maxLength; - } - } - - return new String[] { String.valueOf(length), String.valueOf(enduranceLength) }; - } - - protected void luckyEffectsDisplay() { - if (isLucky) { - String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix"); - player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", SkillTools.getSkillName(skill)))); - } - } - - protected abstract void dataCalculations(); - - protected abstract void permissionsCheck(); - - protected abstract boolean effectsHeaderPermissions(); - - protected abstract void effectsDisplay(); - - protected abstract boolean statsHeaderPermissions(); - - protected abstract void statsDisplay(); -} +package com.gmail.nossr50.commands.skills; + +import java.text.DecimalFormat; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.commands.CommandUtils; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.PerksUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public abstract class SkillCommand implements CommandExecutor { + protected SkillType skill; + private String skillString; + + protected Player player; + protected PlayerProfile profile; + protected float skillValue; + protected boolean isLucky; + protected boolean hasEndurance; + + protected DecimalFormat percent = new DecimalFormat("##0.00%"); + protected DecimalFormat decimal = new DecimalFormat("##0.00"); + + public SkillCommand(SkillType skill) { + this.skill = skill; + this.skillString = StringUtils.getCapitalized(skill.toString()); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + + player = (Player) sender; + profile = UserManager.getPlayer(player).getProfile(); + + if (profile == null) { + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + skillValue = profile.getSkillLevel(skill); + isLucky = Permissions.lucky(sender, skill); + hasEndurance = (Permissions.twelveSecondActivationBoost(sender) || Permissions.eightSecondActivationBoost(sender) || Permissions.fourSecondActivationBoost(sender)); + + dataCalculations(); + permissionsCheck(); + + player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString(skillString + ".SkillName"))); + + if (!skill.isChildSkill()) { + player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + skillString))); + player.sendMessage(LocaleLoader.getString("Effects.Level", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill))); + } + + if (effectsHeaderPermissions()) { + player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); + } + + effectsDisplay(); + + if (statsHeaderPermissions()) { + player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self"))); + } + + statsDisplay(); + + return SkillGuideCommand.grabGuidePageForSkill(skill, player, args); + } + + protected String calculateRank(int maxLevel, int rankChangeLevel) { + if (skillValue >= maxLevel) { + return String.valueOf(maxLevel / rankChangeLevel); + } + + return String.valueOf((int) (skillValue / rankChangeLevel)); + } + + protected String[] calculateAbilityDisplayValues(double chance) { + if (isLucky) { + double luckyChance = chance * 1.3333D; + + if (luckyChance >= 100D) { + return new String[] { percent.format(chance / 100.0D), percent.format(1.0D) }; + } + + return new String[] { percent.format(chance / 100.0D), percent.format(luckyChance / 100.0D) }; + } + + return new String[] { percent.format(chance / 100.0D), null }; + } + + protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) { + double abilityChance; + + if (skillValue >= maxBonusLevel) { + abilityChance = maxChance; + } + else { + abilityChance = (maxChance / maxBonusLevel) * skillValue; + } + + if (isLucky) { + double luckyChance = abilityChance * 1.3333D; + + if (luckyChance >= 100D) { + return new String[] { percent.format(abilityChance / 100.0D), percent.format(1.0D) }; + } + + return new String[] { percent.format(abilityChance / 100.0D), percent.format(luckyChance / 100.0D) }; + } + + return new String[] { percent.format(abilityChance / 100.0D), null }; + } + + protected String[] calculateLengthDisplayValues() { + int maxLength = skill.getAbility().getMaxTicks(); + int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength()); + int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength); + + if (maxLength != 0) { + if (length > maxLength) { + length = maxLength; + } + } + + return new String[] { String.valueOf(length), String.valueOf(enduranceLength) }; + } + + protected void luckyEffectsDisplay() { + if (isLucky) { + String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix"); + player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", SkillUtils.getSkillName(skill)))); + } + } + + protected abstract void dataCalculations(); + + protected abstract void permissionsCheck(); + + protected abstract boolean effectsHeaderPermissions(); + + protected abstract void effectsDisplay(); + + protected abstract boolean statsHeaderPermissions(); + + protected abstract void statsDisplay(); +} diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java new file mode 100644 index 000000000..445224f72 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java @@ -0,0 +1,107 @@ +package com.gmail.nossr50.commands.skills; + +import java.util.ArrayList; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public final class SkillGuideCommand { + private SkillGuideCommand() {} + + public static int getTotalPageNumber(String address) { + String[] addressSplit = LocaleLoader.getString(address).split("\n"); + + if (addressSplit.length <= 8) { + return 1; + } + + return (addressSplit.length / 8) + 1; + } + + public static ArrayList grabPageContents(String header, String address, int pagenum) { + int pageIndexStart = 0; + + // Determine what string to start at + if (pagenum > 1) { + pageIndexStart = 8 * (pagenum - 1); + } + + ArrayList allStrings = new ArrayList(); + String split[] = LocaleLoader.getString(address).split("\n"); + + allStrings.add(LocaleLoader.getString("Guides.Header", header)); + + // Add targeted strings + while (allStrings.size() < 9) { + if (pageIndexStart + allStrings.size() > split.length) { + allStrings.add(""); + } + else { + allStrings.add(split[pageIndexStart + allStrings.size() - 1]); + } + } + + allStrings.add("Page " + pagenum + " of " + getTotalPageNumber(address)); + return allStrings; + } + + public static void clearChat(Player player) { + player.sendMessage("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); // Dear god why? + } + + public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) { + String skillName = skilltype.toString(); + String capitalized = StringUtils.getCapitalized(skillName); + String localized = SkillUtils.getSkillName(skilltype); + player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase())); + + String address = "Guides." + capitalized; + + switch (args.length) { + case 0: + // We have to specify this, otherwise we get the usage string every time we call /skillname... + return true; + + case 1: + if (!args[0].equals("?")) { + return false; + } + + SkillGuideCommand.clearChat(player); + + for (String target : SkillGuideCommand.grabPageContents(localized, address, 1)) { + player.sendMessage(target); + } + + return true; + + case 2: + int totalPages = SkillGuideCommand.getTotalPageNumber(address); + + if (!StringUtils.isInt(args[1])) { + player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid")); + return true; + } + + if (Integer.parseInt(args[1]) > totalPages) { + player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages)); + return true; + } + + SkillGuideCommand.clearChat(player); + + for (String target : SkillGuideCommand.grabPageContents(localized, address, Integer.parseInt(args[1]))) { + player.sendMessage(target); + } + + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java similarity index 92% rename from src/main/java/com/gmail/nossr50/skills/smelting/SmeltingCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java index 58f8fd617..09a647af3 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java @@ -1,121 +1,122 @@ -package com.gmail.nossr50.skills.smelting; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.SkillManagerStore; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class SmeltingCommand extends SkillCommand { - private String burnTimeModifier; - private String secondSmeltChance; - private String secondSmeltChanceLucky; - private String fluxMiningChance; - private String fluxMiningChanceLucky; - private int vanillaXPModifier; - - private boolean canFuelEfficiency; - private boolean canSecondSmelt; - private boolean canFluxMine; - private boolean canVanillaXPBoost; - - public SmeltingCommand() { - super(SkillType.SMELTING); - } - - @Override - protected void dataCalculations() { - //FUEL EFFICIENCY - burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier)); - - //SECOND SMELT - String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance); - secondSmeltChance = secondSmeltStrings[0]; - secondSmeltChanceLucky = secondSmeltStrings[1]; - - //FLUX MINING - String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance); - fluxMiningChance = fluxMiningStrings[0]; - fluxMiningChanceLucky = fluxMiningStrings[1]; - - //VANILLA XP BOOST - vanillaXPModifier = SkillManagerStore.getInstance().getSmeltingManager(player.getName()).getVanillaXpMultiplier(); - } - - @Override - protected void permissionsCheck() { - canFuelEfficiency = Permissions.fuelEfficiency(player); - canSecondSmelt = Permissions.doubleDrops(player, skill); - canFluxMine = Permissions.fluxMining(player); - canVanillaXPBoost = Permissions.vanillaXpBoost(player, skill); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canFuelEfficiency) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1"))); - } - - if (canSecondSmelt) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3"))); - } - - if (canVanillaXPBoost) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5"))); - } - - if (canFluxMine) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost; - } - - @Override - protected void statsDisplay() { - if (canFuelEfficiency) { - player.sendMessage(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier)); - } - - if (canSecondSmelt) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance)); - } - } - - if (canVanillaXPBoost) { - if (skillValue < AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()))); - } - else { - player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", vanillaXPModifier)); - } - } - - if (canFluxMine) { - if (skillValue < Smelting.fluxMiningUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel))); - } - else if (isLucky) { - player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManagerStore; +import com.gmail.nossr50.skills.smelting.Smelting; +import com.gmail.nossr50.util.Permissions; + +public class SmeltingCommand extends SkillCommand { + private String burnTimeModifier; + private String secondSmeltChance; + private String secondSmeltChanceLucky; + private String fluxMiningChance; + private String fluxMiningChanceLucky; + + private int vanillaXPModifier; + + private boolean canFuelEfficiency; + private boolean canSecondSmelt; + private boolean canFluxMine; + private boolean canVanillaXPBoost; + + public SmeltingCommand() { + super(SkillType.SMELTING); + } + + @Override + protected void dataCalculations() { + // FUEL EFFICIENCY + burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier)); + + // SECOND SMELT + String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance); + secondSmeltChance = secondSmeltStrings[0]; + secondSmeltChanceLucky = secondSmeltStrings[1]; + + // FLUX MINING + String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance); + fluxMiningChance = fluxMiningStrings[0]; + fluxMiningChanceLucky = fluxMiningStrings[1]; + + // VANILLA XP BOOST + vanillaXPModifier = SkillManagerStore.getInstance().getSmeltingManager(player.getName()).getVanillaXpMultiplier(); + } + + @Override + protected void permissionsCheck() { + canFuelEfficiency = Permissions.fuelEfficiency(player); + canSecondSmelt = Permissions.doubleDrops(player, skill); + canFluxMine = Permissions.fluxMining(player); + canVanillaXPBoost = Permissions.vanillaXpBoost(player, skill); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canFuelEfficiency) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1"))); + } + + if (canSecondSmelt) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3"))); + } + + if (canVanillaXPBoost) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5"))); + } + + if (canFluxMine) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost; + } + + @Override + protected void statsDisplay() { + if (canFuelEfficiency) { + player.sendMessage(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier)); + } + + if (canSecondSmelt) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance)); + } + } + + if (canVanillaXPBoost) { + if (skillValue < AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()))); + } + else { + player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", vanillaXPModifier)); + } + } + + if (canFluxMine) { + if (skillValue < Smelting.fluxMiningUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel))); + } + else if (isLucky) { + player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java similarity index 93% rename from src/main/java/com/gmail/nossr50/skills/swords/SwordsCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java index 0b07cbdc3..3c16e2c7f 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -1,117 +1,117 @@ -package com.gmail.nossr50.skills.swords; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class SwordsCommand extends SkillCommand { - private String counterAttackChance; - private String counterAttackChanceLucky; - private String bleedLength; - private String bleedChance; - private String bleedChanceLucky; - private String serratedStrikesLength; - private String serratedStrikesLengthEndurance; - - private boolean canCounter; - private boolean canSerratedStrike; - private boolean canBleed; - - public SwordsCommand() { - super(SkillType.SWORDS); - } - - @Override - protected void dataCalculations() { - //SERRATED STRIKES - String[] serratedStrikesStrings = calculateLengthDisplayValues(); - serratedStrikesLength = serratedStrikesStrings[0]; - serratedStrikesLengthEndurance = serratedStrikesStrings[1]; - - //BLEED - if (skillValue >= Swords.bleedMaxBonusLevel) { - bleedLength = String.valueOf(Swords.bleedMaxTicks); - } - else { - bleedLength = String.valueOf(Swords.bleedBaseTicks); - } - - String[] bleedStrings = calculateAbilityDisplayValues(Swords.bleedMaxBonusLevel, Swords.bleedMaxChance); - bleedChance = bleedStrings[0]; - bleedChanceLucky = bleedStrings[1]; - - //COUNTER ATTACK - String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance); - counterAttackChance = counterAttackStrings[0]; - counterAttackChanceLucky = counterAttackStrings[1]; - } - - @Override - protected void permissionsCheck() { - canBleed = Permissions.bleed(player); - canCounter = Permissions.counterAttack(player); - canSerratedStrike = Permissions.serratedStrikes(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canBleed || canCounter || canSerratedStrike; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canCounter) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier)))); - } - - if (canSerratedStrike) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier)))); - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks))); - } - - if (canBleed) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canBleed || canCounter || canSerratedStrike; - } - - @Override - protected void statsDisplay() { - if (canCounter) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance)); - } - } - - if (canBleed) { - player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength)); - player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note")); - - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance)); - } - } - - if (canSerratedStrike) { - if (hasEndurance) { - player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance)); - } - else { - player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.swords.Swords; +import com.gmail.nossr50.util.Permissions; + +public class SwordsCommand extends SkillCommand { + private String counterAttackChance; + private String counterAttackChanceLucky; + private String bleedLength; + private String bleedChance; + private String bleedChanceLucky; + private String serratedStrikesLength; + private String serratedStrikesLengthEndurance; + + private boolean canCounter; + private boolean canSerratedStrike; + private boolean canBleed; + + public SwordsCommand() { + super(SkillType.SWORDS); + } + + @Override + protected void dataCalculations() { + // SERRATED STRIKES + String[] serratedStrikesStrings = calculateLengthDisplayValues(); + serratedStrikesLength = serratedStrikesStrings[0]; + serratedStrikesLengthEndurance = serratedStrikesStrings[1]; + + // BLEED + if (skillValue >= Swords.bleedMaxBonusLevel) { + bleedLength = String.valueOf(Swords.bleedMaxTicks); + } + else { + bleedLength = String.valueOf(Swords.bleedBaseTicks); + } + + String[] bleedStrings = calculateAbilityDisplayValues(Swords.bleedMaxBonusLevel, Swords.bleedMaxChance); + bleedChance = bleedStrings[0]; + bleedChanceLucky = bleedStrings[1]; + + // COUNTER ATTACK + String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance); + counterAttackChance = counterAttackStrings[0]; + counterAttackChanceLucky = counterAttackStrings[1]; + } + + @Override + protected void permissionsCheck() { + canBleed = Permissions.bleed(player); + canCounter = Permissions.counterAttack(player); + canSerratedStrike = Permissions.serratedStrikes(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canBleed || canCounter || canSerratedStrike; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canCounter) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier)))); + } + + if (canSerratedStrike) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier)))); + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks))); + } + + if (canBleed) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canBleed || canCounter || canSerratedStrike; + } + + @Override + protected void statsDisplay() { + if (canCounter) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance)); + } + } + + if (canBleed) { + player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength)); + player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note")); + + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance)); + } + } + + if (canSerratedStrike) { + if (hasEndurance) { + player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance)); + } + else { + player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java similarity index 96% rename from src/main/java/com/gmail/nossr50/skills/taming/TamingCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java index b5a89b727..98d44e9d3 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java @@ -1,165 +1,165 @@ -package com.gmail.nossr50.skills.taming; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class TamingCommand extends SkillCommand { - private String goreChance; - private String goreChanceLucky; - - private boolean canBeastLore; - private boolean canGore; - private boolean canSharpenedClaws; - private boolean canEnvironmentallyAware; - private boolean canThickFur; - private boolean canShockProof; - private boolean canCallWild; - private boolean canFastFood; - private boolean canHolyHound; - - public TamingCommand() { - super(SkillType.TAMING); - } - - @Override - protected void dataCalculations() { - String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance); - goreChance = goreStrings[0]; - goreChanceLucky = goreStrings[1]; - } - - @Override - protected void permissionsCheck() { - canBeastLore = Permissions.beastLore(player); - canCallWild = Permissions.callOfTheWild(player); - canEnvironmentallyAware = Permissions.environmentallyAware(player); - canFastFood = Permissions.fastFoodService(player); - canGore = Permissions.gore(player); - canSharpenedClaws = Permissions.sharpenedClaws(player); - canShockProof = Permissions.shockProof(player); - canThickFur = Permissions.thickFur(player); - canHolyHound = Permissions.holyHound(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canBeastLore) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1"))); - } - - if (canGore) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3"))); - } - - if (canSharpenedClaws) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5"))); - } - - if (canEnvironmentallyAware) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7"))); - } - - if (canThickFur) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9"))); - } - - if (canShockProof) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11"))); - } - - if (canFastFood) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17"))); - } - - if (canHolyHound) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19"))); - } - - if (canCallWild) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13"))); - player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost())); - player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost())); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; - } - - @Override - protected void statsDisplay() { - if (canFastFood) { - if (skillValue < Taming.fastFoodServiceUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel))); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D)))); - } - } - - if (canEnvironmentallyAware) { - if (skillValue < Taming.environmentallyAwareUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel))); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1"))); - } - } - - if (canThickFur) { - if (skillValue < Taming.thickFurUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel))); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier))); - } - } - - if (canHolyHound) { - if (skillValue < Taming.holyHoundUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel))); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11"))); - } - } - - if (canShockProof) { - if (skillValue < Taming.shockProofUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel))); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier))); - } - } - - if (canSharpenedClaws) { - if (skillValue < Taming.sharpenedClawsUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel))); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage))); - } - } - - if (canGore) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.taming.Taming; +import com.gmail.nossr50.util.Permissions; + +public class TamingCommand extends SkillCommand { + private String goreChance; + private String goreChanceLucky; + + private boolean canBeastLore; + private boolean canGore; + private boolean canSharpenedClaws; + private boolean canEnvironmentallyAware; + private boolean canThickFur; + private boolean canShockProof; + private boolean canCallWild; + private boolean canFastFood; + private boolean canHolyHound; + + public TamingCommand() { + super(SkillType.TAMING); + } + + @Override + protected void dataCalculations() { + String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance); + goreChance = goreStrings[0]; + goreChanceLucky = goreStrings[1]; + } + + @Override + protected void permissionsCheck() { + canBeastLore = Permissions.beastLore(player); + canCallWild = Permissions.callOfTheWild(player); + canEnvironmentallyAware = Permissions.environmentallyAware(player); + canFastFood = Permissions.fastFoodService(player); + canGore = Permissions.gore(player); + canSharpenedClaws = Permissions.sharpenedClaws(player); + canShockProof = Permissions.shockProof(player); + canThickFur = Permissions.thickFur(player); + canHolyHound = Permissions.holyHound(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canBeastLore) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1"))); + } + + if (canGore) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3"))); + } + + if (canSharpenedClaws) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5"))); + } + + if (canEnvironmentallyAware) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7"))); + } + + if (canThickFur) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9"))); + } + + if (canShockProof) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11"))); + } + + if (canFastFood) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17"))); + } + + if (canHolyHound) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19"))); + } + + if (canCallWild) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13"))); + player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost())); + player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost())); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; + } + + @Override + protected void statsDisplay() { + if (canFastFood) { + if (skillValue < Taming.fastFoodServiceUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel))); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D)))); + } + } + + if (canEnvironmentallyAware) { + if (skillValue < Taming.environmentallyAwareUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel))); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1"))); + } + } + + if (canThickFur) { + if (skillValue < Taming.thickFurUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel))); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier))); + } + } + + if (canHolyHound) { + if (skillValue < Taming.holyHoundUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel))); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11"))); + } + } + + if (canShockProof) { + if (skillValue < Taming.shockProofUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel))); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier))); + } + } + + if (canSharpenedClaws) { + if (skillValue < Taming.sharpenedClawsUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel))); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage))); + } + } + + if (canGore) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java similarity index 93% rename from src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java index ff4579e6a..5c866dd2e 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -1,146 +1,146 @@ -package com.gmail.nossr50.skills.unarmed; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class UnarmedCommand extends SkillCommand { - private String berserkLength; - private String berserkLengthEndurance; - private String deflectChance; - private String deflectChanceLucky; - private String disarmChance; - private String disarmChanceLucky; - private String ironGripChance; - private String ironGripChanceLucky; - private String ironArmBonus; - - private boolean canBerserk; - private boolean canDisarm; - private boolean canBonusDamage; - private boolean canDeflect; - private boolean canIronGrip; - - public UnarmedCommand() { - super(SkillType.UNARMED); - } - - @Override - protected void dataCalculations() { - //BERSERK - String[] berserkStrings = calculateLengthDisplayValues(); - berserkLength = berserkStrings[0]; - berserkLengthEndurance = berserkStrings[1]; - - //DISARM - String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance); - disarmChance = disarmStrings[0]; - disarmChanceLucky = disarmStrings[1]; - - //DEFLECT - String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance); - deflectChance = deflectStrings[0]; - deflectChanceLucky = deflectStrings[1]; - - //IRON ARM - if (skillValue >= ((Unarmed.ironArmMaxBonusDamage - 3) * Unarmed.ironArmIncreaseLevel)) { - ironArmBonus = String.valueOf(Unarmed.ironArmMaxBonusDamage); - } - else { - ironArmBonus = String.valueOf(3 + (skillValue / Unarmed.ironArmIncreaseLevel)); - } - - //IRON GRIP - String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance); - ironGripChance = ironGripStrings[0]; - ironGripChanceLucky = ironGripStrings[1]; - } - - @Override - protected void permissionsCheck() { - canBerserk = Permissions.berserk(player); - canBonusDamage = Permissions.bonusDamage(player, skill); - canDeflect = Permissions.arrowDeflect(player); - canDisarm = Permissions.disarm(player); - canIronGrip = Permissions.ironGrip(player); - } - - @Override - protected boolean effectsHeaderPermissions() { - return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canBerserk) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1"))); - } - - if (canDisarm) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3"))); - } - - if (canBonusDamage) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5"))); - } - - if (canDeflect) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7"))); - } - - if (canIronGrip) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip; - } - - @Override - protected void statsDisplay() { - if (canBonusDamage) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus))); - } - - if (canDeflect) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance)); - } - } - - if (canDisarm) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance)); - } - } - - if (canIronGrip) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance)); - } - } - - if (canBerserk) { - if (hasEndurance) { - player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance)); - } - else { - player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.unarmed.Unarmed; +import com.gmail.nossr50.util.Permissions; + +public class UnarmedCommand extends SkillCommand { + private String berserkLength; + private String berserkLengthEndurance; + private String deflectChance; + private String deflectChanceLucky; + private String disarmChance; + private String disarmChanceLucky; + private String ironGripChance; + private String ironGripChanceLucky; + private String ironArmBonus; + + private boolean canBerserk; + private boolean canDisarm; + private boolean canBonusDamage; + private boolean canDeflect; + private boolean canIronGrip; + + public UnarmedCommand() { + super(SkillType.UNARMED); + } + + @Override + protected void dataCalculations() { + // BERSERK + String[] berserkStrings = calculateLengthDisplayValues(); + berserkLength = berserkStrings[0]; + berserkLengthEndurance = berserkStrings[1]; + + // DISARM + String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance); + disarmChance = disarmStrings[0]; + disarmChanceLucky = disarmStrings[1]; + + // DEFLECT + String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance); + deflectChance = deflectStrings[0]; + deflectChanceLucky = deflectStrings[1]; + + // IRON ARM + if (skillValue >= ((Unarmed.ironArmMaxBonusDamage - 3) * Unarmed.ironArmIncreaseLevel)) { + ironArmBonus = String.valueOf(Unarmed.ironArmMaxBonusDamage); + } + else { + ironArmBonus = String.valueOf(3 + (skillValue / Unarmed.ironArmIncreaseLevel)); + } + + // IRON GRIP + String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance); + ironGripChance = ironGripStrings[0]; + ironGripChanceLucky = ironGripStrings[1]; + } + + @Override + protected void permissionsCheck() { + canBerserk = Permissions.berserk(player); + canBonusDamage = Permissions.bonusDamage(player, skill); + canDeflect = Permissions.arrowDeflect(player); + canDisarm = Permissions.disarm(player); + canIronGrip = Permissions.ironGrip(player); + } + + @Override + protected boolean effectsHeaderPermissions() { + return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canBerserk) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1"))); + } + + if (canDisarm) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3"))); + } + + if (canBonusDamage) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5"))); + } + + if (canDeflect) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7"))); + } + + if (canIronGrip) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip; + } + + @Override + protected void statsDisplay() { + if (canBonusDamage) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus))); + } + + if (canDeflect) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance)); + } + } + + if (canDisarm) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance)); + } + } + + if (canIronGrip) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance)); + } + } + + if (canBerserk) { + if (hasEndurance) { + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance)); + } + else { + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java similarity index 90% rename from src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java rename to src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java index 0b98c0e28..d173baf61 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -1,103 +1,103 @@ -package com.gmail.nossr50.skills.woodcutting; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillCommand; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class WoodcuttingCommand extends SkillCommand { - private String treeFellerLength; - private String treeFellerLengthEndurance; - private String doubleDropChance; - private String doubleDropChanceLucky; - - private boolean canTreeFell; - private boolean canLeafBlow; - private boolean canDoubleDrop; - private boolean doubleDropsDisabled; - - public WoodcuttingCommand() { - super(SkillType.WOODCUTTING); - } - - @Override - protected void dataCalculations() { - //TREE FELLER - String[] treeFellerStrings = calculateLengthDisplayValues(); - treeFellerLength = treeFellerStrings[0]; - treeFellerLengthEndurance = treeFellerStrings[1]; - - //DOUBLE DROPS - String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance); - doubleDropChance = doubleDropStrings[0]; - doubleDropChanceLucky = doubleDropStrings[1]; - } - - @Override - protected void permissionsCheck() { - canTreeFell = Permissions.treeFeller(player); - canDoubleDrop = Permissions.doubleDrops(player, skill); - canLeafBlow = Permissions.leafBlower(player); - doubleDropsDisabled = skill.getDoubleDropsDisabled(); - } - - @Override - protected boolean effectsHeaderPermissions() { - return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell; - } - - @Override - protected void effectsDisplay() { - luckyEffectsDisplay(); - - if (canTreeFell) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1"))); - } - - if (canLeafBlow) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3"))); - } - - if (canDoubleDrop && !doubleDropsDisabled) { - player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5"))); - } - } - - @Override - protected boolean statsHeaderPermissions() { - return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell; - } - - @Override - protected void statsDisplay() { - if (canLeafBlow) { - int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel(); - - if (skillValue < leafBlowerUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel))); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1"))); - } - } - - if (canDoubleDrop && !doubleDropsDisabled) { - if (isLucky) { - player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky)); - } - else { - player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance)); - } - } - - if (canTreeFell) { - if (hasEndurance) { - player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance)); - } - else { - player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength)); - } - } - } -} +package com.gmail.nossr50.commands.skills; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.woodcutting.Woodcutting; +import com.gmail.nossr50.util.Permissions; + +public class WoodcuttingCommand extends SkillCommand { + private String treeFellerLength; + private String treeFellerLengthEndurance; + private String doubleDropChance; + private String doubleDropChanceLucky; + + private boolean canTreeFell; + private boolean canLeafBlow; + private boolean canDoubleDrop; + private boolean doubleDropsDisabled; + + public WoodcuttingCommand() { + super(SkillType.WOODCUTTING); + } + + @Override + protected void dataCalculations() { + // TREE FELLER + String[] treeFellerStrings = calculateLengthDisplayValues(); + treeFellerLength = treeFellerStrings[0]; + treeFellerLengthEndurance = treeFellerStrings[1]; + + // DOUBLE DROPS + String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance); + doubleDropChance = doubleDropStrings[0]; + doubleDropChanceLucky = doubleDropStrings[1]; + } + + @Override + protected void permissionsCheck() { + canTreeFell = Permissions.treeFeller(player); + canDoubleDrop = Permissions.doubleDrops(player, skill); + canLeafBlow = Permissions.leafBlower(player); + doubleDropsDisabled = skill.getDoubleDropsDisabled(); + } + + @Override + protected boolean effectsHeaderPermissions() { + return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell; + } + + @Override + protected void effectsDisplay() { + luckyEffectsDisplay(); + + if (canTreeFell) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1"))); + } + + if (canLeafBlow) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3"))); + } + + if (canDoubleDrop && !doubleDropsDisabled) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5"))); + } + } + + @Override + protected boolean statsHeaderPermissions() { + return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell; + } + + @Override + protected void statsDisplay() { + if (canLeafBlow) { + int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel(); + + if (skillValue < leafBlowerUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel))); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1"))); + } + } + + if (canDoubleDrop && !doubleDropsDisabled) { + if (isLucky) { + player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky)); + } + else { + player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance)); + } + } + + if (canTreeFell) { + if (hasEndurance) { + player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance)); + } + else { + player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength)); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/spout/commands/MchudCommand.java b/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java similarity index 87% rename from src/main/java/com/gmail/nossr50/spout/commands/MchudCommand.java rename to src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java index 839f3fee2..f52501576 100644 --- a/src/main/java/com/gmail/nossr50/spout/commands/MchudCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java @@ -1,29 +1,29 @@ -package com.gmail.nossr50.spout.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.spout.huds.HudType; - -public class MchudCommand extends SpoutCommand { - @Override - protected boolean noArguments(Command command, CommandSender sender, String[] args) { - return false; - } - - @Override - protected boolean oneArgument(Command command, CommandSender sender, String[] args) { - for (HudType hudType : HudType.values()) { - if (hudType.toString().equalsIgnoreCase(args[0])) { - playerProfile.setHudType(hudType); - spoutHud.initializeXpBar(); - spoutHud.updateXpBar(); - return true; - } - } - - sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid")); - return true; - } -} +package com.gmail.nossr50.commands.spout; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.datatypes.spout.huds.HudType; +import com.gmail.nossr50.locale.LocaleLoader; + +public class MchudCommand extends SpoutCommand { + @Override + protected boolean noArguments(Command command, CommandSender sender, String[] args) { + return false; + } + + @Override + protected boolean oneArgument(Command command, CommandSender sender, String[] args) { + for (HudType hudType : HudType.values()) { + if (hudType.toString().equalsIgnoreCase(args[0])) { + playerProfile.setHudType(hudType); + spoutHud.initializeXpBar(); + spoutHud.updateXpBar(); + return true; + } + } + + sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid")); + return true; + } +} diff --git a/src/main/java/com/gmail/nossr50/spout/commands/SpoutCommand.java b/src/main/java/com/gmail/nossr50/commands/spout/SpoutCommand.java similarity index 62% rename from src/main/java/com/gmail/nossr50/spout/commands/SpoutCommand.java rename to src/main/java/com/gmail/nossr50/commands/spout/SpoutCommand.java index b22305b62..5fd56b7c2 100644 --- a/src/main/java/com/gmail/nossr50/spout/commands/SpoutCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/SpoutCommand.java @@ -1,53 +1,54 @@ -package com.gmail.nossr50.spout.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.commands.CommandHelper; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.spout.SpoutConfig; -import com.gmail.nossr50.spout.huds.SpoutHud; -import com.gmail.nossr50.util.Users; - -public abstract class SpoutCommand implements CommandExecutor { - protected PlayerProfile playerProfile; - protected SpoutHud spoutHud; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noConsoleUsage(sender)) { - return true; - } - - if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) { - sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); - return true; - } - - playerProfile = Users.getPlayer((Player) sender).getProfile(); - spoutHud = playerProfile.getSpoutHud(); - - if (spoutHud == null) { - sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); - return true; - } - - switch (args.length) { - case 0: - return noArguments(command, sender, args); - - case 1: - return oneArgument(command, sender, args); - - default: - return false; - } - } - - protected abstract boolean noArguments(Command command, CommandSender sender, String[] args); - protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args); -} +package com.gmail.nossr50.commands.spout; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.spout.SpoutConfig; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.commands.CommandUtils; +import com.gmail.nossr50.util.player.UserManager; + +public abstract class SpoutCommand implements CommandExecutor { + protected PlayerProfile playerProfile; + protected McMMOHud spoutHud; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + + if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) { + sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); + return true; + } + + playerProfile = UserManager.getPlayer((Player) sender).getProfile(); + spoutHud = playerProfile.getSpoutHud(); + + if (spoutHud == null) { + sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); + return true; + } + + switch (args.length) { + case 0: + return noArguments(command, sender, args); + + case 1: + return oneArgument(command, sender, args); + + default: + return false; + } + } + + protected abstract boolean noArguments(Command command, CommandSender sender, String[] args); + + protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args); +} diff --git a/src/main/java/com/gmail/nossr50/spout/commands/XplockCommand.java b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java similarity index 84% rename from src/main/java/com/gmail/nossr50/spout/commands/XplockCommand.java rename to src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java index 5a1c20695..a69ea0cec 100644 --- a/src/main/java/com/gmail/nossr50/spout/commands/XplockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java @@ -1,64 +1,64 @@ -package com.gmail.nossr50.spout.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public class XplockCommand extends SpoutCommand { - @Override - protected boolean noArguments(Command command, CommandSender sender, String[] args) { - if (spoutHud.getXpBarLocked()) { - unlockXpBar(sender); - return true; - } - - lockXpBar(sender, spoutHud.getLastGained()); - return true; - } - - @Override - protected boolean oneArgument(Command command, CommandSender sender, String[] args) { - if (args[0].equalsIgnoreCase("on")) { - lockXpBar(sender, spoutHud.getLastGained()); - return true; - } - - if (args[0].equalsIgnoreCase("off")) { - unlockXpBar(sender); - return true; - } - - if (!SkillTools.isSkill(args[0])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } - - SkillType skill = SkillType.getSkill(args[0]); - - if (!Permissions.xplock(sender, skill)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - lockXpBar(sender, skill); - return true; - } - - private void lockXpBar(CommandSender sender, SkillType skill) { - if (skill != null) { - spoutHud.setXpBarLocked(true); - spoutHud.setSkillLock(skill); - spoutHud.updateXpBar(); - sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillTools.getSkillName(skill))); - } - } - - private void unlockXpBar(CommandSender sender) { - spoutHud.setXpBarLocked(false); - sender.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked")); - } -} +package com.gmail.nossr50.commands.spout; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class XplockCommand extends SpoutCommand { + @Override + protected boolean noArguments(Command command, CommandSender sender, String[] args) { + if (spoutHud.getXpBarLocked()) { + unlockXpBar(sender); + return true; + } + + lockXpBar(sender, spoutHud.getLastGained()); + return true; + } + + @Override + protected boolean oneArgument(Command command, CommandSender sender, String[] args) { + if (args[0].equalsIgnoreCase("on")) { + lockXpBar(sender, spoutHud.getLastGained()); + return true; + } + + if (args[0].equalsIgnoreCase("off")) { + unlockXpBar(sender); + return true; + } + + if (!SkillUtils.isSkill(args[0])) { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + SkillType skill = SkillType.getSkill(args[0]); + + if (!Permissions.xplock(sender, skill)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + lockXpBar(sender, skill); + return true; + } + + private void lockXpBar(CommandSender sender, SkillType skill) { + if (skill != null) { + spoutHud.setXpBarLocked(true); + spoutHud.setSkillLock(skill); + spoutHud.updateXpBar(); + sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillUtils.getSkillName(skill))); + } + } + + private void unlockXpBar(CommandSender sender) { + spoutHud.setXpBarLocked(false); + sender.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked")); + } +} diff --git a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java index 74e84cc4f..111a5fecc 100644 --- a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java @@ -12,7 +12,7 @@ import java.util.Set; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import com.gmail.nossr50.util.metrics.MetricsManager; +import com.gmail.nossr50.metrics.MetricsManager; public abstract class AutoUpdateConfigLoader extends ConfigLoader { public AutoUpdateConfigLoader(String relativePath, String fileName) { @@ -64,7 +64,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader { // Rip out Bukkit's attempt to save comments at the top of the file while (output.indexOf('#') != -1) { - output = output.substring(output.indexOf('\n', output.indexOf('#'))+1); + output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1); } // Read the internal config to get comments, then put them in the new one @@ -81,7 +81,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader { } else if (line.contains(":")) { line = line.substring(0, line.indexOf(":") + 1); - if(!temp.isEmpty()) { + if (!temp.isEmpty()) { comments.put(line, temp); temp = ""; } diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index d36059fc7..86d6ee56b 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -6,8 +6,8 @@ import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.EntityType; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.util.StringUtils; public class Config extends AutoUpdateConfigLoader { diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index d12968216..3220a79f3 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -1,79 +1,80 @@ -package com.gmail.nossr50.config; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; - -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - -import com.gmail.nossr50.mcMMO; - -public abstract class ConfigLoader { - protected static final mcMMO plugin = mcMMO.p; - protected String fileName; - protected File configFile; - protected FileConfiguration config; - - public ConfigLoader(String relativePath, String fileName) { - this.fileName = fileName; - configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName); - loadFile(); - } - - public ConfigLoader(String fileName) { - this.fileName = fileName; - configFile = new File(plugin.getDataFolder(), fileName); - loadFile(); - } - - protected void loadFile() { - if (!configFile.exists()) { - plugin.getLogger().info("Creating mcMMO " + fileName + " File..."); - createFile(); - } - else { - plugin.getLogger().info("Loading mcMMO " + fileName + " File..."); - } - - config = YamlConfiguration.loadConfiguration(configFile); - } - - protected abstract void loadKeys(); - - protected void createFile() { - if (configFile.exists()) { - return; - } - - configFile.getParentFile().mkdirs(); - - InputStream inputStream = plugin.getResource(fileName); - - if (inputStream != null) { - try { - copyStreamToFile(inputStream, configFile); - } catch (Exception e) { - e.printStackTrace(); - } - } - else { - plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors"); - } - } - - private static void copyStreamToFile(InputStream inputStream, File file) throws Exception { - OutputStream outputStream = new FileOutputStream(file); - - int read = 0; - byte[] bytes = new byte[1024]; - - while ((read = inputStream.read(bytes)) != -1) { - outputStream.write(bytes, 0, read); - } - - inputStream.close(); - outputStream.close(); - } -} +package com.gmail.nossr50.config; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import com.gmail.nossr50.mcMMO; + +public abstract class ConfigLoader { + protected static final mcMMO plugin = mcMMO.p; + protected String fileName; + protected File configFile; + protected FileConfiguration config; + + public ConfigLoader(String relativePath, String fileName) { + this.fileName = fileName; + configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName); + loadFile(); + } + + public ConfigLoader(String fileName) { + this.fileName = fileName; + configFile = new File(plugin.getDataFolder(), fileName); + loadFile(); + } + + protected void loadFile() { + if (!configFile.exists()) { + plugin.getLogger().info("Creating mcMMO " + fileName + " File..."); + createFile(); + } + else { + plugin.getLogger().info("Loading mcMMO " + fileName + " File..."); + } + + config = YamlConfiguration.loadConfiguration(configFile); + } + + protected abstract void loadKeys(); + + protected void createFile() { + if (configFile.exists()) { + return; + } + + configFile.getParentFile().mkdirs(); + + InputStream inputStream = plugin.getResource(fileName); + + if (inputStream != null) { + try { + copyStreamToFile(inputStream, configFile); + } + catch (Exception e) { + e.printStackTrace(); + } + } + else { + plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors"); + } + } + + private static void copyStreamToFile(InputStream inputStream, File file) throws Exception { + OutputStream outputStream = new FileOutputStream(file); + + int read = 0; + byte[] bytes = new byte[1024]; + + while ((read = inputStream.read(bytes)) != -1) { + outputStream.write(bytes, 0, read); + } + + inputStream.close(); + outputStream.close(); + } +} diff --git a/src/main/java/com/gmail/nossr50/mods/config/CustomArmorConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java similarity index 83% rename from src/main/java/com/gmail/nossr50/mods/config/CustomArmorConfig.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java index 8f0a67055..6e47a86e0 100644 --- a/src/main/java/com/gmail/nossr50/mods/config/CustomArmorConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java @@ -1,94 +1,101 @@ -package com.gmail.nossr50.mods.config; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -import org.bukkit.configuration.ConfigurationSection; - -import com.gmail.nossr50.config.ConfigLoader; -import com.gmail.nossr50.mods.datatypes.CustomItem; -import com.gmail.nossr50.skills.repair.Repairable; -import com.gmail.nossr50.skills.repair.RepairableFactory; - -public class CustomArmorConfig extends ConfigLoader{ - private static CustomArmorConfig instance; - private List repairables; - public List customBootIDs = new ArrayList(); - public List customChestplateIDs = new ArrayList(); - public List customHelmetIDs = new ArrayList(); - public List customLeggingIDs = new ArrayList(); - public List customIDs = new ArrayList(); - public List customArmorList = new ArrayList(); - public HashMap customArmor = new HashMap(); - - public CustomArmorConfig() { - super("ModConfigs", "armor.yml"); - loadKeys(); - } - - public static CustomArmorConfig getInstance() { - if (instance == null) { - instance = new CustomArmorConfig(); - } - - return instance; - } - - @Override - protected void loadKeys() { - repairables = new ArrayList(); - - loadArmor("Boots", customBootIDs); - loadArmor("Chestplates", customChestplateIDs); - loadArmor("Helmets", customHelmetIDs); - loadArmor("Leggings", customLeggingIDs); - } - - private void loadArmor(String armorType, List idList) { - ConfigurationSection armorSection = config.getConfigurationSection(armorType); - - if (armorSection == null) - return; - - Set armorConfigSet = armorSection.getKeys(false); - - for (String armorName : armorConfigSet) { - int id = config.getInt(armorType + "." + armorName + ".ID", 0); - boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable"); - int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0); - byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0); - int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0); - short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0); - - if (id == 0) { - plugin.getLogger().warning("Missing ID. This item will be skipped."); - continue; - } - - if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) { - plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable."); - repairable = false; - } - - CustomItem armor; - - if (repairable) { - repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability)); - } - - armor = new CustomItem(id, durability); - - idList.add(id); - customIDs.add(id); - customArmorList.add(armor); - customArmor.put(id, armor); - } - } - - public List getLoadedRepairables() { - if (repairables == null) return new ArrayList(); - return repairables; - } -} +package com.gmail.nossr50.config.mods; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +import org.bukkit.configuration.ConfigurationSection; + +import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.datatypes.mods.CustomItem; +import com.gmail.nossr50.skills.repair.Repairable; +import com.gmail.nossr50.skills.repair.RepairableFactory; + +public class CustomArmorConfig extends ConfigLoader { + private static CustomArmorConfig instance; + + private List repairables; + + public List customBootIDs = new ArrayList(); + public List customChestplateIDs = new ArrayList(); + public List customHelmetIDs = new ArrayList(); + public List customLeggingIDs = new ArrayList(); + public List customIDs = new ArrayList(); + + public List customArmorList = new ArrayList(); + public HashMap customArmor = new HashMap(); + + public CustomArmorConfig() { + super("ModConfigs", "armor.yml"); + loadKeys(); + } + + public static CustomArmorConfig getInstance() { + if (instance == null) { + instance = new CustomArmorConfig(); + } + + return instance; + } + + public List getLoadedRepairables() { + if (repairables == null) { + return new ArrayList(); + } + + return repairables; + } + + @Override + protected void loadKeys() { + repairables = new ArrayList(); + + loadArmor("Boots", customBootIDs); + loadArmor("Chestplates", customChestplateIDs); + loadArmor("Helmets", customHelmetIDs); + loadArmor("Leggings", customLeggingIDs); + } + + private void loadArmor(String armorType, List idList) { + ConfigurationSection armorSection = config.getConfigurationSection(armorType); + + if (armorSection == null) { + return; + } + + Set armorConfigSet = armorSection.getKeys(false); + + for (String armorName : armorConfigSet) { + int id = config.getInt(armorType + "." + armorName + ".ID", 0); + boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable"); + int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0); + byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0); + int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0); + short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0); + + if (id == 0) { + plugin.getLogger().warning("Missing ID. This item will be skipped."); + continue; + } + + if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) { + plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable."); + repairable = false; + } + + CustomItem armor; + + if (repairable) { + repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability)); + } + + armor = new CustomItem(id, durability); + + idList.add(id); + customIDs.add(id); + customArmorList.add(armor); + customArmor.put(id, armor); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/mods/config/CustomBlocksConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomBlockConfig.java similarity index 76% rename from src/main/java/com/gmail/nossr50/mods/config/CustomBlocksConfig.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomBlockConfig.java index 5d7568f16..c49a13c7d 100644 --- a/src/main/java/com/gmail/nossr50/mods/config/CustomBlocksConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomBlockConfig.java @@ -1,117 +1,120 @@ -package com.gmail.nossr50.mods.config; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import com.gmail.nossr50.config.ConfigLoader; -import com.gmail.nossr50.mods.datatypes.CustomBlock; - -public class CustomBlocksConfig extends ConfigLoader { - private static CustomBlocksConfig instance; - public List customExcavationBlocks = new ArrayList(); - public List customHerbalismBlocks = new ArrayList(); - public List customMiningBlocks = new ArrayList(); - public List customWoodcuttingBlocks = new ArrayList(); - public List customOres = new ArrayList(); - public List customLogs = new ArrayList(); - public List customLeaves = new ArrayList(); - public List customAbilityBlocks = new ArrayList(); - public List customItems = new ArrayList(); - public List customBlocks = new ArrayList(); - - public CustomBlocksConfig() { - super("ModConfigs", "blocks.yml"); - loadKeys(); - } - - public static CustomBlocksConfig getInstance() { - if (instance == null) { - instance = new CustomBlocksConfig(); - } - - return instance; - } - - @Override - protected void loadKeys() { - loadBlocks("Excavation", customExcavationBlocks); - loadBlocks("Herbalism", customHerbalismBlocks); - loadBlocks("Mining", customMiningBlocks); - loadBlocks("Woodcutting", customWoodcuttingBlocks); - loadBlocks("Ability_Blocks", customAbilityBlocks); - } - - private void loadBlocks(String skillType, List blockList) { - ConfigurationSection skillSection = config.getConfigurationSection(skillType); - - if (skillSection == null) - return; - - Set skillConfigSet = skillSection.getKeys(false); - - for (String blockName : skillConfigSet) { - int id = config.getInt(skillType + "." + blockName + ".ID", 0); - byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0); - int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0); - int tier = config.getInt(skillType + "." + blockName + ".Tier", 1); - boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false); - int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0); - byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0); - int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1); - int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1); - - CustomBlock block; - ItemStack itemDrop; - ItemStack blockItem; - - if (id == 0) { - plugin.getLogger().warning("Missing ID. This block will be skipped."); - continue; - } - - if (skillType.equals("Ability_Blocks")) { - blockItem = (new MaterialData(id, data)).toItemStack(1); - - blockList.add(blockItem); - continue; - } - - if (dropItem && dropID == 0) { - plugin.getLogger().warning("Incomplete item drop information. This block will drop itself."); - dropItem = false; - } - - if (dropItem) { - itemDrop = (new MaterialData(dropID, dropData)).toItemStack(1); - } - else { - itemDrop = (new MaterialData(id, data)).toItemStack(1); - } - - block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id); - blockItem = (new MaterialData(id, data)).toItemStack(1); - - if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) { - customOres.add(blockItem); - } - else if (skillType.equals("Woodcutting")) { - if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) { - customLogs.add(blockItem); - } - else { - customLeaves.add(blockItem); - block.setXpGain(0); //Leaves don't grant XP - } - } - - blockList.add(blockItem); - customItems.add(blockItem); - customBlocks.add(block); - } - } -} +package com.gmail.nossr50.config.mods; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; + +import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.datatypes.mods.CustomBlock; + +public class CustomBlockConfig extends ConfigLoader { + private static CustomBlockConfig instance; + + public List customExcavationBlocks = new ArrayList(); + public List customHerbalismBlocks = new ArrayList(); + public List customMiningBlocks = new ArrayList(); + public List customWoodcuttingBlocks = new ArrayList(); + public List customOres = new ArrayList(); + public List customLogs = new ArrayList(); + public List customLeaves = new ArrayList(); + public List customAbilityBlocks = new ArrayList(); + public List customItems = new ArrayList(); + + public List customBlocks = new ArrayList(); + + public CustomBlockConfig() { + super("ModConfigs", "blocks.yml"); + loadKeys(); + } + + public static CustomBlockConfig getInstance() { + if (instance == null) { + instance = new CustomBlockConfig(); + } + + return instance; + } + + @Override + protected void loadKeys() { + loadBlocks("Excavation", customExcavationBlocks); + loadBlocks("Herbalism", customHerbalismBlocks); + loadBlocks("Mining", customMiningBlocks); + loadBlocks("Woodcutting", customWoodcuttingBlocks); + loadBlocks("Ability_Blocks", customAbilityBlocks); + } + + private void loadBlocks(String skillType, List blockList) { + ConfigurationSection skillSection = config.getConfigurationSection(skillType); + + if (skillSection == null) { + return; + } + + Set skillConfigSet = skillSection.getKeys(false); + + for (String blockName : skillConfigSet) { + int id = config.getInt(skillType + "." + blockName + ".ID", 0); + byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0); + int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0); + int tier = config.getInt(skillType + "." + blockName + ".Tier", 1); + boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false); + int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0); + byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0); + int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1); + int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1); + + CustomBlock block; + ItemStack itemDrop; + ItemStack blockItem; + + if (id == 0) { + plugin.getLogger().warning("Missing ID. This block will be skipped."); + continue; + } + + if (skillType.equals("Ability_Blocks")) { + blockItem = (new MaterialData(id, data)).toItemStack(1); + + blockList.add(blockItem); + continue; + } + + if (dropItem && dropID == 0) { + plugin.getLogger().warning("Incomplete item drop information. This block will drop itself."); + dropItem = false; + } + + if (dropItem) { + itemDrop = (new MaterialData(dropID, dropData)).toItemStack(1); + } + else { + itemDrop = (new MaterialData(id, data)).toItemStack(1); + } + + block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id); + blockItem = (new MaterialData(id, data)).toItemStack(1); + + if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) { + customOres.add(blockItem); + } + else if (skillType.equals("Woodcutting")) { + if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) { + customLogs.add(blockItem); + } + else { + customLeaves.add(blockItem); + block.setXpGain(0); // Leaves don't grant XP + } + } + + blockList.add(blockItem); + customItems.add(blockItem); + customBlocks.add(block); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/mods/config/CustomEntityConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java similarity index 93% rename from src/main/java/com/gmail/nossr50/mods/config/CustomEntityConfig.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java index 763afdb5e..04abfa33a 100644 --- a/src/main/java/com/gmail/nossr50/mods/config/CustomEntityConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java @@ -1,82 +1,84 @@ -package com.gmail.nossr50.mods.config; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.config.ConfigLoader; -import com.gmail.nossr50.mods.datatypes.CustomEntity; - -public class CustomEntityConfig extends ConfigLoader { - private static CustomEntityConfig instance; - public List customEntityIds = new ArrayList(); - public List customHostileEntityIds = new ArrayList(); - public List customNeutralEntityIds = new ArrayList(); - public List customPassiveEntityIds = new ArrayList(); - public List customEntityTypes = new ArrayList(); - public List customEntities = new ArrayList(); - - public CustomEntityConfig() { - super("ModConfigs", "entities.yml"); - loadKeys(); - } - - public static CustomEntityConfig getInstance() { - if (instance == null) { - instance = new CustomEntityConfig(); - } - - return instance; - } - - @Override - protected void loadKeys() { - loadMobs("Hostile", customHostileEntityIds); - loadMobs("Neutral", customNeutralEntityIds); - loadMobs("Passive", customPassiveEntityIds); - } - - private void loadMobs(String entityType, List entityIdList) { - ConfigurationSection entitySection = config.getConfigurationSection(entityType); - - if (entitySection == null) { - return; - } - - Set entityConfigSet = entitySection.getKeys(false); - - for (String entityName : entityConfigSet) { - int id = config.getInt(entityType + "." + entityName + ".ID", 0); - EntityType type = EntityType.fromId(id); - double xpMultiplier = config.getDouble(entityType + "." + entityName + ".XP_Multiplier", 1.0D); - boolean canBeTamed = config.getBoolean(entityType + "." + entityName + ".Tameable", false); - int tamingXp = config.getInt(entityType + "." + entityName + "Taming_XP", 0); - boolean canBeSummoned = config.getBoolean(entityType + "." + entityName + "CanBeSummoned", false); - int callOfTheWildId = config.getInt(entityType + "." + entityName + "COTW_Material_ID", 0); - int callOfTheWildData = config.getInt(entityType + "." + entityName + "COTW_Material_Data", 0); - int callOfTheWildAmount = config.getInt(entityType + "." + entityName + "COTW_Material_Amount", 0); - - CustomEntity entity; - - if (id == 0) { - plugin.getLogger().warning("Missing ID. This block will be skipped."); - continue; - } - - if (canBeSummoned && (callOfTheWildId == 0 || callOfTheWildAmount == 0)) { - plugin.getLogger().warning("Incomplete Call of the Wild information. This enitity will not be able to be summoned by Call of the Wild."); - canBeSummoned = false; - } - - entity = new CustomEntity(id, type, xpMultiplier, canBeTamed, tamingXp, canBeSummoned, new ItemStack(callOfTheWildId, callOfTheWildData), callOfTheWildAmount); - - entityIdList.add(id); - customEntityTypes.add(type); - customEntities.add(entity); - } - } -} +package com.gmail.nossr50.config.mods; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.datatypes.mods.CustomEntity; + +public class CustomEntityConfig extends ConfigLoader { + private static CustomEntityConfig instance; + + public List customEntityIds = new ArrayList(); + public List customHostileEntityIds = new ArrayList(); + public List customNeutralEntityIds = new ArrayList(); + public List customPassiveEntityIds = new ArrayList(); + + public List customEntityTypes = new ArrayList(); + public List customEntities = new ArrayList(); + + public CustomEntityConfig() { + super("ModConfigs", "entities.yml"); + loadKeys(); + } + + public static CustomEntityConfig getInstance() { + if (instance == null) { + instance = new CustomEntityConfig(); + } + + return instance; + } + + @Override + protected void loadKeys() { + loadMobs("Hostile", customHostileEntityIds); + loadMobs("Neutral", customNeutralEntityIds); + loadMobs("Passive", customPassiveEntityIds); + } + + private void loadMobs(String entityType, List entityIdList) { + ConfigurationSection entitySection = config.getConfigurationSection(entityType); + + if (entitySection == null) { + return; + } + + Set entityConfigSet = entitySection.getKeys(false); + + for (String entityName : entityConfigSet) { + int id = config.getInt(entityType + "." + entityName + ".ID", 0); + EntityType type = EntityType.fromId(id); + double xpMultiplier = config.getDouble(entityType + "." + entityName + ".XP_Multiplier", 1.0D); + boolean canBeTamed = config.getBoolean(entityType + "." + entityName + ".Tameable", false); + int tamingXp = config.getInt(entityType + "." + entityName + "Taming_XP", 0); + boolean canBeSummoned = config.getBoolean(entityType + "." + entityName + "CanBeSummoned", false); + int callOfTheWildId = config.getInt(entityType + "." + entityName + "COTW_Material_ID", 0); + int callOfTheWildData = config.getInt(entityType + "." + entityName + "COTW_Material_Data", 0); + int callOfTheWildAmount = config.getInt(entityType + "." + entityName + "COTW_Material_Amount", 0); + + CustomEntity entity; + + if (id == 0) { + plugin.getLogger().warning("Missing ID. This block will be skipped."); + continue; + } + + if (canBeSummoned && (callOfTheWildId == 0 || callOfTheWildAmount == 0)) { + plugin.getLogger().warning("Incomplete Call of the Wild information. This enitity will not be able to be summoned by Call of the Wild."); + canBeSummoned = false; + } + + entity = new CustomEntity(id, type, xpMultiplier, canBeTamed, tamingXp, canBeSummoned, new ItemStack(callOfTheWildId, callOfTheWildData), callOfTheWildAmount); + + entityIdList.add(id); + customEntityTypes.add(type); + customEntities.add(entity); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/mods/config/CustomToolsConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java similarity index 87% rename from src/main/java/com/gmail/nossr50/mods/config/CustomToolsConfig.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java index e5c970b57..1dd080f48 100644 --- a/src/main/java/com/gmail/nossr50/mods/config/CustomToolsConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java @@ -1,101 +1,105 @@ -package com.gmail.nossr50.mods.config; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -import org.bukkit.configuration.ConfigurationSection; - -import com.gmail.nossr50.config.ConfigLoader; -import com.gmail.nossr50.mods.datatypes.CustomTool; -import com.gmail.nossr50.skills.repair.Repairable; -import com.gmail.nossr50.skills.repair.RepairableFactory; - -public class CustomToolsConfig extends ConfigLoader { - private static CustomToolsConfig instance; - private List repairables; - public List customAxeIDs = new ArrayList(); - public List customBowIDs = new ArrayList(); - public List customHoeIDs = new ArrayList(); - public List customPickaxeIDs = new ArrayList(); - public List customShovelIDs = new ArrayList(); - public List customSwordIDs = new ArrayList(); - public List customIDs = new ArrayList(); - public List customToolList = new ArrayList(); - public HashMap customTools = new HashMap(); - - private CustomToolsConfig() { - super("ModConfigs", "tools.yml"); - loadKeys(); - } - - public static CustomToolsConfig getInstance() { - if (instance == null) { - instance = new CustomToolsConfig(); - } - - return instance; - } - - @Override - protected void loadKeys() { - repairables = new ArrayList(); - - loadTool("Axes", customAxeIDs); - loadTool("Bows", customBowIDs); - loadTool("Hoes", customHoeIDs); - loadTool("Pickaxes", customPickaxeIDs); - loadTool("Shovels", customShovelIDs); - loadTool("Swords", customSwordIDs); - } - - private void loadTool(String toolType, List idList) { - ConfigurationSection toolSection = config.getConfigurationSection(toolType); - - if (toolSection == null) - return; - - Set toolConfigSet = toolSection.getKeys(false); - - for (String toolName : toolConfigSet) { - int id = config.getInt(toolType + "." + toolName + ".ID", 0); - double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0); - boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true); - int tier = config.getInt(toolType + "." + toolName + ".Tier", 1); - boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable"); - int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0); - byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0); - int repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 0); - short durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 0); - - if (id == 0) { - plugin.getLogger().warning("Missing ID. This item will be skipped."); - continue; - } - - if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) { - plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable."); - repairable = false; - } - - CustomTool tool; - - if (repairable) { - repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability)); - } - - tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id); - - idList.add(id); - customIDs.add(id); - customToolList.add(tool); - customTools.put(id, tool); - } - } - - public List getLoadedRepairables() { - if (repairables == null) return new ArrayList(); - return repairables; - } -} +package com.gmail.nossr50.config.mods; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +import org.bukkit.configuration.ConfigurationSection; + +import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.datatypes.mods.CustomTool; +import com.gmail.nossr50.skills.repair.Repairable; +import com.gmail.nossr50.skills.repair.RepairableFactory; + +public class CustomToolConfig extends ConfigLoader { + private static CustomToolConfig instance; + private List repairables; + public List customAxeIDs = new ArrayList(); + public List customBowIDs = new ArrayList(); + public List customHoeIDs = new ArrayList(); + public List customPickaxeIDs = new ArrayList(); + public List customShovelIDs = new ArrayList(); + public List customSwordIDs = new ArrayList(); + public List customIDs = new ArrayList(); + public List customToolList = new ArrayList(); + public HashMap customTools = new HashMap(); + + private CustomToolConfig() { + super("ModConfigs", "tools.yml"); + loadKeys(); + } + + public static CustomToolConfig getInstance() { + if (instance == null) { + instance = new CustomToolConfig(); + } + + return instance; + } + + public List getLoadedRepairables() { + if (repairables == null) { + return new ArrayList(); + } + + return repairables; + } + + @Override + protected void loadKeys() { + repairables = new ArrayList(); + + loadTool("Axes", customAxeIDs); + loadTool("Bows", customBowIDs); + loadTool("Hoes", customHoeIDs); + loadTool("Pickaxes", customPickaxeIDs); + loadTool("Shovels", customShovelIDs); + loadTool("Swords", customSwordIDs); + } + + private void loadTool(String toolType, List idList) { + ConfigurationSection toolSection = config.getConfigurationSection(toolType); + + if (toolSection == null) { + return; + } + + Set toolConfigSet = toolSection.getKeys(false); + + for (String toolName : toolConfigSet) { + int id = config.getInt(toolType + "." + toolName + ".ID", 0); + double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0); + boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true); + int tier = config.getInt(toolType + "." + toolName + ".Tier", 1); + boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable"); + int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0); + byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0); + int repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 0); + short durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 0); + + if (id == 0) { + plugin.getLogger().warning("Missing ID. This item will be skipped."); + continue; + } + + if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) { + plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable."); + repairable = false; + } + + CustomTool tool; + + if (repairable) { + repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability)); + } + + tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id); + + idList.add(id); + customIDs.add(id); + customToolList.add(tool); + customTools.put(id, tool); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/config/ItemWeightsConfig.java b/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java similarity index 66% rename from src/main/java/com/gmail/nossr50/config/ItemWeightsConfig.java rename to src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java index 9a1dbe00d..446f718d5 100644 --- a/src/main/java/com/gmail/nossr50/config/ItemWeightsConfig.java +++ b/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java @@ -1,27 +1,25 @@ -package com.gmail.nossr50.config; +package com.gmail.nossr50.config.party; import org.bukkit.Material; +import com.gmail.nossr50.config.ConfigLoader; import com.gmail.nossr50.util.StringUtils; -public class ItemWeightsConfig extends ConfigLoader { - private static ItemWeightsConfig instance; +public class ItemWeightConfig extends ConfigLoader { + private static ItemWeightConfig instance; - private ItemWeightsConfig() { + private ItemWeightConfig() { super("itemweights.yml"); } - public static ItemWeightsConfig getInstance() { + public static ItemWeightConfig getInstance() { if (instance == null) { - instance = new ItemWeightsConfig(); + instance = new ItemWeightConfig(); } return instance; } - @Override - protected void loadKeys() {} - public int getItemWeight(Material material) { String materialName = StringUtils.getPrettyItemString(material).replace(" ", "_"); int itemWeight = config.getInt("Item_Weights.Default"); @@ -31,4 +29,7 @@ public class ItemWeightsConfig extends ConfigLoader { } return itemWeight; } + + @Override + protected void loadKeys() {} } diff --git a/src/main/java/com/gmail/nossr50/config/spout/SpoutConfig.java b/src/main/java/com/gmail/nossr50/config/spout/SpoutConfig.java new file mode 100644 index 000000000..4d3b66f46 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/spout/SpoutConfig.java @@ -0,0 +1,65 @@ +package com.gmail.nossr50.config.spout; + +import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.spout.huds.HudType; + +public class SpoutConfig extends ConfigLoader { + private static SpoutConfig instance; + public HudType defaultHudType; + + private SpoutConfig() { + super("spout.yml"); + loadKeys(); + } + + public static SpoutConfig getInstance() { + if (instance == null) { + instance = new SpoutConfig(); + } + + return instance; + } + + @Override + protected void loadKeys() { + // Setup default HUD + String temp = config.getString("Spout.HUD.Default", "STANDARD"); + + for (HudType hudType : HudType.values()) { + if (hudType.toString().equalsIgnoreCase(temp)) { + defaultHudType = hudType; + break; + } + } + + if (defaultHudType == null) { + defaultHudType = HudType.STANDARD; + } + } + + public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); } + public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); } + + /* XP Bar */ + public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); } + public void setXPBarEnabled(boolean enabled) { config.set("XP.Bar.Enabled", enabled); } + + public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); } + public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); } + public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); } + public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); } + public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); } + + /* HUD Colors */ + public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); } + public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); } + public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); } + public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); } + public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); } + public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); } + + public double getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); } + public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); } + public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); } +} diff --git a/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java similarity index 87% rename from src/main/java/com/gmail/nossr50/config/TreasuresConfig.java rename to src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java index fea503f94..d43a1d5c2 100644 --- a/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -1,285 +1,287 @@ -package com.gmail.nossr50.config; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.bukkit.Material; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; -import com.gmail.nossr50.datatypes.treasure.FishingTreasure; -import com.gmail.nossr50.datatypes.treasure.HylianTreasure; -import com.gmail.nossr50.datatypes.treasure.Treasure; - -public class TreasuresConfig extends ConfigLoader { - private static TreasuresConfig instance; - public List excavationFromDirt = new ArrayList(); - public List excavationFromGrass = new ArrayList(); - public List excavationFromSand = new ArrayList(); - public List excavationFromGravel = new ArrayList(); - public List excavationFromClay = new ArrayList(); - public List excavationFromMycel = new ArrayList(); - public List excavationFromSoulSand = new ArrayList(); - - public List hylianFromBushes = new ArrayList(); - public List hylianFromFlowers = new ArrayList(); - public List hylianFromPots = new ArrayList(); - - public List fishingRewards = new ArrayList(); - - private TreasuresConfig() { - super("treasures.yml"); - loadKeys(); - } - - public static TreasuresConfig getInstance() { - if (instance == null) { - instance = new TreasuresConfig(); - } - - return instance; - } - - @Override - protected void loadKeys() { - Map treasures = new HashMap(); - ConfigurationSection treasureSection = config.getConfigurationSection("Treasures"); - Set treasureConfigSet = treasureSection.getKeys(false); - - for (String treasureName : treasureConfigSet) { - - // Validate all the things! - List reason = new ArrayList(); - - /* - * ID, Amount, and Data - */ - - if (!config.contains("Treasures." + treasureName + ".ID")) { - reason.add("Missing ID"); - } - - if (!config.contains("Treasures." + treasureName + ".Amount")) { - reason.add("Missing Amount"); - } - - if (!config.contains("Treasures." + treasureName + ".Data")) { - reason.add("Missing Data"); - } - - int id = config.getInt("Treasures." + treasureName + ".ID"); - int amount = config.getInt("Treasures." + treasureName + ".Amount"); - int data = config.getInt("Treasures." + treasureName + ".Data"); - - if (Material.getMaterial(id) == null) { - reason.add("Invalid id: " + id); - } - - if (amount < 1) { - reason.add("Invalid amount: " + amount); - } - - if (data > 127 || data < -128) { - reason.add("Invalid data: " + data); - } - - /* - * XP, Drop Chance, and Drop Level - */ - - if (!config.contains("Treasures." + treasureName + ".XP")) { - reason.add("Missing XP"); - } - - if (!config.contains("Treasures." + treasureName + ".Drop_Chance")) { - reason.add("Missing Drop_Chance"); - } - - if (!config.contains("Treasures." + treasureName + ".Drop_Level")) { - reason.add("Missing Drop_Level"); - } - - int xp = config.getInt("Treasures." + treasureName + ".XP"); - Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance"); - int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level"); - - if (xp < 0) { - reason.add("Invalid xp: " + xp); - } - - if (dropChance < 0) { - reason.add("Invalid Drop_Chance: " + dropChance); - } - - if (dropLevel < 0) { - reason.add("Invalid Drop_Level: " + dropLevel); - } - - /* - * Drops From & Max Level - */ - - ItemStack item = (new MaterialData(id, (byte) data)).toItemStack(amount); - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) { - if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) { - reason.add("Fishing drops cannot also be excavation drops"); - } - - if (!config.contains("Treasures." + treasureName + ".Max_Level")) { - reason.add("Missing Max_Level"); - } - - int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level"); - - if (noErrorsInTreasure(reason)) { - FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel); - treasures.put(treasureName, fTreasure); - } - } - else { - ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel); - HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel); - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) { - eTreasure.setDropsFromDirt(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) { - eTreasure.setDropsFromGrass(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) { - eTreasure.setDropsFromSand(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) { - eTreasure.setDropsFromGravel(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) { - eTreasure.setDropsFromClay(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) { - eTreasure.setDropsFromMycel(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) { - eTreasure.setDropsFromSoulSand(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) { - hTreasure.setDropsFromBushes(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) { - hTreasure.setDropsFromFlowers(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) { - hTreasure.setDropsFromPots(); - } - - if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) { - reason.add("Excavation drops cannot also be fishing drops"); - } - - if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) { - treasures.put(treasureName, eTreasure); - } - else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0){ - treasures.put(treasureName, hTreasure); - } - } - } - - List excavationTreasures = config.getStringList("Excavation.Treasure"); - List fishingTreasures = config.getStringList("Fishing.Treasure"); - List hylianTreasures = config.getStringList("Hylian_Luck.Treasure"); - - for (Entry nextEntry : treasures.entrySet()) { - String treasureKey = nextEntry.getKey(); - Treasure treasure = nextEntry.getValue(); - - if (treasure instanceof FishingTreasure) { - if (!fishingTreasures.contains(treasureKey)) { - continue; - } - - fishingRewards.add((FishingTreasure) treasure); - } - else if (treasure instanceof HylianTreasure) { - if (!hylianTreasures.contains(treasureKey)) { - continue; - } - - HylianTreasure hTreasure = (HylianTreasure) treasure; - - if (hTreasure.getDropsFromBushes()) { - hylianFromBushes.add(hTreasure); - } - - if (hTreasure.getDropsFromFlowers()) { - hylianFromFlowers.add(hTreasure); - } - - if (hTreasure.getDropsFromPots()) { - hylianFromPots.add(hTreasure); - } - } - else if (treasure instanceof ExcavationTreasure) { - if (!excavationTreasures.contains(treasureKey)) { - continue; - } - - ExcavationTreasure eTreasure = (ExcavationTreasure) treasure; - - if (eTreasure.getDropsFromDirt()) { - excavationFromDirt.add(eTreasure); - } - - if (eTreasure.getDropsFromGrass()) { - excavationFromGrass.add(eTreasure); - } - - if (eTreasure.getDropsFromSand()) { - excavationFromSand.add(eTreasure); - } - - if (eTreasure.getDropsFromGravel()) { - excavationFromGravel.add(eTreasure); - } - - if (eTreasure.getDropsFromClay()) { - excavationFromClay.add(eTreasure); - } - - if (eTreasure.getDropsFromMycel()) { - excavationFromMycel.add(eTreasure); - } - - if (eTreasure.getDropsFromSoulSand()) { - excavationFromSoulSand.add(eTreasure); - } - } - } - } - - private boolean noErrorsInTreasure(List issues) { - if (issues.isEmpty()) { - return true; - } - - for (String issue : issues) { - plugin.getLogger().warning(issue); - } - return false; - } -} +package com.gmail.nossr50.config.treasure; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; + +import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; +import com.gmail.nossr50.datatypes.treasure.FishingTreasure; +import com.gmail.nossr50.datatypes.treasure.HylianTreasure; +import com.gmail.nossr50.datatypes.treasure.Treasure; + +public class TreasureConfig extends ConfigLoader { + private static TreasureConfig instance; + + public List excavationFromDirt = new ArrayList(); + public List excavationFromGrass = new ArrayList(); + public List excavationFromSand = new ArrayList(); + public List excavationFromGravel = new ArrayList(); + public List excavationFromClay = new ArrayList(); + public List excavationFromMycel = new ArrayList(); + public List excavationFromSoulSand = new ArrayList(); + + public List hylianFromBushes = new ArrayList(); + public List hylianFromFlowers = new ArrayList(); + public List hylianFromPots = new ArrayList(); + + public List fishingRewards = new ArrayList(); + + private TreasureConfig() { + super("treasures.yml"); + loadKeys(); + } + + public static TreasureConfig getInstance() { + if (instance == null) { + instance = new TreasureConfig(); + } + + return instance; + } + + @Override + protected void loadKeys() { + Map treasures = new HashMap(); + ConfigurationSection treasureSection = config.getConfigurationSection("Treasures"); + Set treasureConfigSet = treasureSection.getKeys(false); + + for (String treasureName : treasureConfigSet) { + + // Validate all the things! + List reason = new ArrayList(); + + /* + * ID, Amount, and Data + */ + + if (!config.contains("Treasures." + treasureName + ".ID")) { + reason.add("Missing ID"); + } + + if (!config.contains("Treasures." + treasureName + ".Amount")) { + reason.add("Missing Amount"); + } + + if (!config.contains("Treasures." + treasureName + ".Data")) { + reason.add("Missing Data"); + } + + int id = config.getInt("Treasures." + treasureName + ".ID"); + int amount = config.getInt("Treasures." + treasureName + ".Amount"); + int data = config.getInt("Treasures." + treasureName + ".Data"); + + if (Material.getMaterial(id) == null) { + reason.add("Invalid id: " + id); + } + + if (amount < 1) { + reason.add("Invalid amount: " + amount); + } + + if (data > 127 || data < -128) { + reason.add("Invalid data: " + data); + } + + /* + * XP, Drop Chance, and Drop Level + */ + + if (!config.contains("Treasures." + treasureName + ".XP")) { + reason.add("Missing XP"); + } + + if (!config.contains("Treasures." + treasureName + ".Drop_Chance")) { + reason.add("Missing Drop_Chance"); + } + + if (!config.contains("Treasures." + treasureName + ".Drop_Level")) { + reason.add("Missing Drop_Level"); + } + + int xp = config.getInt("Treasures." + treasureName + ".XP"); + Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance"); + int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level"); + + if (xp < 0) { + reason.add("Invalid xp: " + xp); + } + + if (dropChance < 0) { + reason.add("Invalid Drop_Chance: " + dropChance); + } + + if (dropLevel < 0) { + reason.add("Invalid Drop_Level: " + dropLevel); + } + + /* + * Drops From & Max Level + */ + + ItemStack item = (new MaterialData(id, (byte) data)).toItemStack(amount); + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) { + if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) { + reason.add("Fishing drops cannot also be excavation drops"); + } + + if (!config.contains("Treasures." + treasureName + ".Max_Level")) { + reason.add("Missing Max_Level"); + } + + int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level"); + + if (noErrorsInTreasure(reason)) { + FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel); + treasures.put(treasureName, fTreasure); + } + } + else { + ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel); + HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel); + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) { + eTreasure.setDropsFromDirt(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) { + eTreasure.setDropsFromGrass(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) { + eTreasure.setDropsFromSand(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) { + eTreasure.setDropsFromGravel(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) { + eTreasure.setDropsFromClay(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) { + eTreasure.setDropsFromMycel(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) { + eTreasure.setDropsFromSoulSand(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) { + hTreasure.setDropsFromBushes(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) { + hTreasure.setDropsFromFlowers(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) { + hTreasure.setDropsFromPots(); + } + + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) { + reason.add("Excavation drops cannot also be fishing drops"); + } + + if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) { + treasures.put(treasureName, eTreasure); + } + else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0) { + treasures.put(treasureName, hTreasure); + } + } + } + + List excavationTreasures = config.getStringList("Excavation.Treasure"); + List fishingTreasures = config.getStringList("Fishing.Treasure"); + List hylianTreasures = config.getStringList("Hylian_Luck.Treasure"); + + for (Entry nextEntry : treasures.entrySet()) { + String treasureKey = nextEntry.getKey(); + Treasure treasure = nextEntry.getValue(); + + if (treasure instanceof FishingTreasure) { + if (!fishingTreasures.contains(treasureKey)) { + continue; + } + + fishingRewards.add((FishingTreasure) treasure); + } + else if (treasure instanceof HylianTreasure) { + if (!hylianTreasures.contains(treasureKey)) { + continue; + } + + HylianTreasure hTreasure = (HylianTreasure) treasure; + + if (hTreasure.getDropsFromBushes()) { + hylianFromBushes.add(hTreasure); + } + + if (hTreasure.getDropsFromFlowers()) { + hylianFromFlowers.add(hTreasure); + } + + if (hTreasure.getDropsFromPots()) { + hylianFromPots.add(hTreasure); + } + } + else if (treasure instanceof ExcavationTreasure) { + if (!excavationTreasures.contains(treasureKey)) { + continue; + } + + ExcavationTreasure eTreasure = (ExcavationTreasure) treasure; + + if (eTreasure.getDropsFromDirt()) { + excavationFromDirt.add(eTreasure); + } + + if (eTreasure.getDropsFromGrass()) { + excavationFromGrass.add(eTreasure); + } + + if (eTreasure.getDropsFromSand()) { + excavationFromSand.add(eTreasure); + } + + if (eTreasure.getDropsFromGravel()) { + excavationFromGravel.add(eTreasure); + } + + if (eTreasure.getDropsFromClay()) { + excavationFromClay.add(eTreasure); + } + + if (eTreasure.getDropsFromMycel()) { + excavationFromMycel.add(eTreasure); + } + + if (eTreasure.getDropsFromSoulSand()) { + excavationFromSoulSand.add(eTreasure); + } + } + } + } + + private boolean noErrorsInTreasure(List issues) { + if (issues.isEmpty()) { + return true; + } + + for (String issue : issues) { + plugin.getLogger().warning(issue); + } + return false; + } +} diff --git a/src/main/java/com/gmail/nossr50/database/Database.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java similarity index 67% rename from src/main/java/com/gmail/nossr50/database/Database.java rename to src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 347c9de96..138599fe5 100644 --- a/src/main/java/com/gmail/nossr50/database/Database.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -10,19 +10,19 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.runnables.SQLReconnect; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.spout.SpoutTools; -import com.gmail.nossr50.spout.huds.SpoutHud; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.datatypes.database.DatabaseUpdateType; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; +import com.gmail.nossr50.runnables.database.SQLReconnectTask; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.spout.SpoutUtils; -public final class Database { +public final class DatabaseManager { private static String connectionString; private static String tablePrefix = Config.getInstance().getMySQLTablePrefix(); @@ -32,7 +32,7 @@ public final class Database { private static final double SCALING_FACTOR = 40; // Minimum wait in nanoseconds (default 500ms) - private static final long MIN_WAIT = 500L*1000000L; + private static final long MIN_WAIT = 500L * 1000000L; // Maximum time to wait between reconnects (default 5 minutes) private static final long MAX_WAIT = 5L * 60L * 1000L * 1000000L; @@ -43,10 +43,12 @@ public final class Database { // When next to try connecting to Database in nanoseconds private static long nextReconnectTimestamp = 0L; - // How many connection attemtps have failed + // How many connection attempts have failed private static int reconnectAttempt = 0; - private Database() {} + private static final long ONE_MONTH = 2630000000L; + + private DatabaseManager() {} /** * Attempt to connect to the mySQL database. @@ -68,13 +70,17 @@ public final class Database { connection = DriverManager.getConnection(connectionString, connectionProperties); mcMMO.p.getLogger().info("Connection to MySQL was a success!"); - } catch (SQLException ex) { + } + catch (SQLException ex) { connection = null; + if (reconnectAttempt == 0 || reconnectAttempt >= 11) { mcMMO.p.getLogger().info("Connection to MySQL failed!"); } - } catch (ClassNotFoundException ex) { + } + catch (ClassNotFoundException ex) { connection = null; + if (reconnectAttempt == 0 || reconnectAttempt >= 11) { mcMMO.p.getLogger().info("MySQL database driver not found!"); } @@ -147,108 +153,10 @@ public final class Database { + "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) " + "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); - checkDatabaseStructure(DatabaseUpdate.FISHING); - checkDatabaseStructure(DatabaseUpdate.BLAST_MINING); - checkDatabaseStructure(DatabaseUpdate.CASCADE_DELETE); - checkDatabaseStructure(DatabaseUpdate.INDEX); - } - - /** - * Check database structure for missing values. - * - * @param update Type of data to check updates for - */ - private static void checkDatabaseStructure(DatabaseUpdate update) { - String sql = null; - ResultSet resultSet = null; - HashMap> rows = new HashMap>(); - - switch (update) { - case BLAST_MINING: - sql = "SELECT * FROM `" + tablePrefix + "cooldowns` ORDER BY `" + tablePrefix + "cooldowns`.`blast_mining` ASC LIMIT 0 , 30"; - break; - - case CASCADE_DELETE: - write("ALTER TABLE `" + tablePrefix + "huds` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;"); - write("ALTER TABLE `" + tablePrefix + "experience` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;"); - write("ALTER TABLE `" + tablePrefix + "cooldowns` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;"); - write("ALTER TABLE `" + tablePrefix + "skills` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;"); - break; - - case FISHING: - sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30"; - break; - - case INDEX: - if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13 && checkConnected()) { - mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases"); - write("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_taming` (`taming`) USING BTREE, " - + "ADD INDEX `idx_mining` (`mining`) USING BTREE, " - + "ADD INDEX `idx_woodcutting` (`woodcutting`) USING BTREE, " - + "ADD INDEX `idx_repair` (`repair`) USING BTREE, " - + "ADD INDEX `idx_unarmed` (`unarmed`) USING BTREE, " - + "ADD INDEX `idx_herbalism` (`herbalism`) USING BTREE, " - + "ADD INDEX `idx_excavation` (`excavation`) USING BTREE, " - + "ADD INDEX `idx_archery` (`archery`) USING BTREE, " - + "ADD INDEX `idx_swords` (`swords`) USING BTREE, " - + "ADD INDEX `idx_axes` (`axes`) USING BTREE, " - + "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, " - + "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;"); - } - break; - - default: - break; - } - - PreparedStatement statement = null; - try { - if (!checkConnected()) return; - statement = connection.prepareStatement(sql); - resultSet = statement.executeQuery(); - - while (resultSet.next()) { - ArrayList column = new ArrayList(); - - for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) { - column.add(resultSet.getString(i)); - } - - rows.put(resultSet.getRow(), column); - } - } - catch (SQLException ex) { - switch (update) { - case BLAST_MINING: - mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining..."); - write("ALTER TABLE `"+tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;"); - break; - - case FISHING: - mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing..."); - write("ALTER TABLE `"+tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); - write("ALTER TABLE `"+tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); - break; - - default: - break; - } - } finally { - if (resultSet != null) { - try { - resultSet.close(); - } catch (SQLException e) { - // Ignore the error, we're leaving - } - } - if (statement != null) { - try { - statement.close(); - } catch (SQLException e) { - // Ignore the error, we're leaving - } - } - } + checkDatabaseStructure(DatabaseUpdateType.FISHING); + checkDatabaseStructure(DatabaseUpdateType.BLAST_MINING); + checkDatabaseStructure(DatabaseUpdateType.CASCADE_DELETE); + checkDatabaseStructure(DatabaseUpdateType.INDEX); } /** @@ -258,29 +166,31 @@ public final class Database { * @return true if the query was successfully written, false otherwise. */ public static boolean write(String sql) { - if (checkConnected()) { - PreparedStatement statement = null; - try { - statement = connection.prepareStatement(sql); - statement.executeUpdate(); - return true; - } - catch (SQLException ex) { - printErrors(ex); - return false; - } finally { - if (statement != null) { - try { - statement.close(); - } catch (SQLException e) { - printErrors(e); - return false; - } + if (!checkConnected()) { + return false; + } + + PreparedStatement statement = null; + try { + statement = connection.prepareStatement(sql); + statement.executeUpdate(); + return true; + } + catch (SQLException ex) { + printErrors(ex); + return false; + } + finally { + if (statement != null) { + try { + statement.close(); + } + catch (SQLException e) { + printErrors(e); + return false; } } } - - return false; } /** @@ -291,22 +201,23 @@ public final class Database { */ public static int update(String sql) { int ret = 0; + if (checkConnected()) { PreparedStatement statement = null; try { statement = connection.prepareStatement(sql); ret = statement.executeUpdate(); - return ret; - } catch (SQLException ex) { + } + catch (SQLException ex) { printErrors(ex); - return 0; - } finally { + } + finally { if (statement != null) { try { statement.close(); - } catch (SQLException e) { + } + catch (SQLException e) { printErrors(e); - return 0; } } } @@ -322,12 +233,14 @@ public final class Database { * @return the value in the first row / first field */ public static int getInt(String sql) { - ResultSet resultSet; + ResultSet resultSet = null; int result = 0; if (checkConnected()) { + PreparedStatement statement = null; + try { - PreparedStatement statement = connection.prepareStatement(sql); + statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); if (resultSet.next()) { @@ -336,12 +249,20 @@ public final class Database { else { result = 0; } - - statement.close(); } catch (SQLException ex) { printErrors(ex); } + finally { + if (statement != null) { + try { + statement.close(); + } + catch (SQLException e) { + printErrors(e); + } + } + } } return result; @@ -375,7 +296,8 @@ public final class Database { if (exists) { try { isClosed = connection.isClosed(); - } catch (SQLException e) { + } + catch (SQLException e) { isClosed = true; e.printStackTrace(); printErrors(e); @@ -384,9 +306,9 @@ public final class Database { if (!isClosed) { try { isValid = connection.isValid(VALID_TIMEOUT); - } catch (SQLException e) { - // Don't print stack trace because it's valid to lose idle connections - // to the server and have to restart them. + } + catch (SQLException e) { + // Don't print stack trace because it's valid to lose idle connections to the server and have to restart them. isValid = false; } } @@ -404,7 +326,8 @@ public final class Database { if (exists && !isClosed) { try { connection.close(); - } catch (SQLException ex) { + } + catch (SQLException ex) { // This is a housekeeping exercise, ignore errors } } @@ -417,22 +340,21 @@ public final class Database { if (connection != null && !connection.isClosed()) { // Schedule a database save if we really had an outage if (reconnectAttempt > 1) { - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnect(), 5); + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnectTask(), 5); } nextReconnectTimestamp = 0; reconnectAttempt = 0; return true; } - } catch (SQLException e) { + } + catch (SQLException e) { // Failed to check isClosed, so presume connection is bad and attempt later e.printStackTrace(); printErrors(e); } reconnectAttempt++; - - nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT))); - + nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt * SCALING_FACTOR * MIN_WAIT))); return false; } @@ -447,8 +369,10 @@ public final class Database { HashMap> rows = new HashMap>(); if (checkConnected()) { + PreparedStatement statement = null; + try { - PreparedStatement statement = connection.prepareStatement(sql); + statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); while (resultSet.next()) { @@ -460,12 +384,20 @@ public final class Database { rows.put(resultSet.getRow(), column); } - - statement.close(); } catch (SQLException ex) { printErrors(ex); } + finally { + if (statement != null) { + try { + statement.close(); + } + catch (SQLException e) { + printErrors(e); + } + } + } } return rows; @@ -477,12 +409,15 @@ public final class Database { if (checkConnected()) { try { - for (SkillType skillType: SkillType.values()) { + for (SkillType skillType : SkillType.values()) { if (skillType.isChildSkill()) { continue; } - String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " > (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')"; + String skillName = skillType.name().toLowerCase(); + String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " + + "AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " + + "WHERE user = '" + playerName + "')"; PreparedStatement statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); @@ -491,7 +426,9 @@ public final class Database { int rank = resultSet.getInt("rank"); - sql = "SELECT user, " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " = (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user"; + sql = "SELECT user, " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " + + "AND " + skillName + " = (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " + + "WHERE user = '" + playerName + "') ORDER BY user"; statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); @@ -506,7 +443,11 @@ public final class Database { statement.close(); } - String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')"; + String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " + + "WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 " + + "AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > " + + "(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " + + "FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')"; PreparedStatement statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); @@ -515,7 +456,12 @@ public final class Database { int rank = resultSet.getInt("rank"); - sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing = (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user"; + sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " + + "FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " + + "WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 " + + "AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing = " + + "(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " + + "FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user"; statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); @@ -539,14 +485,20 @@ public final class Database { public static void purgePowerlessSQL() { mcMMO.p.getLogger().info("Purging powerless users..."); - HashMap> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0"); - write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)"); + HashMap> usernames; + + usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u " + "WHERE s.user_id = u.id AND " + + "(s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0"); + + write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM " + + "(SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u " + "WHERE s.user_id = u.id " + + "AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)"); int purgedUsers = 0; for (int i = 1; i <= usernames.size(); i++) { String playerName = usernames.get(i).get(0); - if (playerName == null || Bukkit.getOfflinePlayer(playerName).isOnline()) { + if (playerName == null || mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline()) { continue; } @@ -560,7 +512,7 @@ public final class Database { public static void purgeOldSQL() { mcMMO.p.getLogger().info("Purging old users..."); long currentTime = System.currentTimeMillis(); - long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff(); + long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff(); HashMap> usernames = read("SELECT user FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")"); write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT id FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")) AS p)"); @@ -579,32 +531,137 @@ public final class Database { mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database."); } - private static void printErrors(SQLException ex) { - mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage()); - mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState()); - mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode()); - } - public static void profileCleanup(String playerName) { - McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); - if (mcmmoPlayer != null) { - Player player = mcmmoPlayer.getPlayer(); - SpoutHud spoutHud = mcmmoPlayer.getProfile().getSpoutHud(); + if (mcMMOPlayer != null) { + Player player = mcMMOPlayer.getPlayer(); + McMMOHud spoutHud = mcMMOPlayer.getProfile().getSpoutHud(); if (spoutHud != null) { spoutHud.removeWidgets(); } - Users.remove(playerName); + UserManager.remove(playerName); if (player.isOnline()) { - Users.addUser(player); + UserManager.addUser(player); if (mcMMO.spoutEnabled) { - SpoutTools.reloadSpoutPlayer(player); + SpoutUtils.reloadSpoutPlayer(player); } } } } + + /** + * Check database structure for missing values. + * + * @param update Type of data to check updates for + */ + private static void checkDatabaseStructure(DatabaseUpdateType update) { + String sql = null; + ResultSet resultSet = null; + HashMap> rows = new HashMap>(); + + switch (update) { + case BLAST_MINING: + sql = "SELECT * FROM `" + tablePrefix + "cooldowns` ORDER BY `" + tablePrefix + "cooldowns`.`blast_mining` ASC LIMIT 0 , 30"; + break; + + case CASCADE_DELETE: + write("ALTER TABLE `" + tablePrefix + "huds` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;"); + write("ALTER TABLE `" + tablePrefix + "experience` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;"); + write("ALTER TABLE `" + tablePrefix + "cooldowns` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;"); + write("ALTER TABLE `" + tablePrefix + "skills` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;"); + break; + + case FISHING: + sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30"; + break; + + case INDEX: + if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13 && checkConnected()) { + mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases"); + write("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_taming` (`taming`) USING BTREE, " + + "ADD INDEX `idx_mining` (`mining`) USING BTREE, " + + "ADD INDEX `idx_woodcutting` (`woodcutting`) USING BTREE, " + + "ADD INDEX `idx_repair` (`repair`) USING BTREE, " + + "ADD INDEX `idx_unarmed` (`unarmed`) USING BTREE, " + + "ADD INDEX `idx_herbalism` (`herbalism`) USING BTREE, " + + "ADD INDEX `idx_excavation` (`excavation`) USING BTREE, " + + "ADD INDEX `idx_archery` (`archery`) USING BTREE, " + + "ADD INDEX `idx_swords` (`swords`) USING BTREE, " + + "ADD INDEX `idx_axes` (`axes`) USING BTREE, " + + "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, " + + "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;"); + } + break; + + default: + break; + } + + PreparedStatement statement = null; + try { + if (!checkConnected()) { + return; + } + + statement = connection.prepareStatement(sql); + resultSet = statement.executeQuery(); + + while (resultSet.next()) { + ArrayList column = new ArrayList(); + + for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) { + column.add(resultSet.getString(i)); + } + + rows.put(resultSet.getRow(), column); + } + } + catch (SQLException ex) { + switch (update) { + case BLAST_MINING: + mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining..."); + write("ALTER TABLE `"+tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;"); + break; + + case FISHING: + mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing..."); + write("ALTER TABLE `"+tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); + write("ALTER TABLE `"+tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); + break; + + default: + break; + } + } + finally { + if (resultSet != null) { + try { + resultSet.close(); + } + catch (SQLException e) { + // Ignore the error, we're leaving + } + } + + if (statement != null) { + try { + statement.close(); + } + catch (SQLException e) { + // Ignore the error, we're leaving + } + } + } + } + + private static void printErrors(SQLException ex) { + mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage()); + mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState()); + mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode()); + } } diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseUpdate.java b/src/main/java/com/gmail/nossr50/database/DatabaseUpdate.java deleted file mode 100644 index 3382b0108..000000000 --- a/src/main/java/com/gmail/nossr50/database/DatabaseUpdate.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.gmail.nossr50.database; - -public enum DatabaseUpdate { - FISHING, - BLAST_MINING, - CASCADE_DELETE, - INDEX; -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/database/Leaderboard.java b/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java similarity index 82% rename from src/main/java/com/gmail/nossr50/database/Leaderboard.java rename to src/main/java/com/gmail/nossr50/database/LeaderboardManager.java index 2719da269..247a189e6 100644 --- a/src/main/java/com/gmail/nossr50/database/Leaderboard.java +++ b/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java @@ -10,48 +10,49 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; -import org.bukkit.Bukkit; - import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.datatypes.database.PlayerStat; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.util.StringUtils; -public final class Leaderboard { +public final class LeaderboardManager { private static HashMap> playerStatHash = new HashMap>(); private static List powerLevels = new ArrayList(); private static long lastUpdate = 0; - private Leaderboard() {} + private static final long UPDATE_WAIT_TIME = 600000L; // 10 minutes + private static final long ONE_MONTH = 2630000000L; + + private LeaderboardManager() {} /** * Update the leader boards. */ public static void updateLeaderboards() { - if(System.currentTimeMillis() < lastUpdate + 600000) { - return; //Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently + // Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently + if (System.currentTimeMillis() < lastUpdate + UPDATE_WAIT_TIME) { + return; } - lastUpdate = System.currentTimeMillis(); //Log when the last update was run + lastUpdate = System.currentTimeMillis(); // Log when the last update was run - //Initialize lists - List mining, woodcutting, herbalism, excavation, acrobatics, repair, swords, axes, archery, unarmed, taming, fishing; + // Initialize lists + List mining = new ArrayList(); + List woodcutting = new ArrayList(); + List herbalism = new ArrayList(); + List excavation = new ArrayList(); + List acrobatics = new ArrayList(); + List repair = new ArrayList(); + List swords = new ArrayList(); + List axes = new ArrayList(); + List archery = new ArrayList(); + List unarmed = new ArrayList(); + List taming = new ArrayList(); + List fishing = new ArrayList(); + List powerLevels = new ArrayList(); - mining = new ArrayList(); - woodcutting = new ArrayList(); - herbalism = new ArrayList(); - excavation = new ArrayList(); - acrobatics = new ArrayList(); - repair = new ArrayList(); - swords = new ArrayList(); - axes = new ArrayList(); - archery = new ArrayList(); - unarmed = new ArrayList(); - taming = new ArrayList(); - fishing = new ArrayList(); - powerLevels = new ArrayList(); - - //Read from the FlatFile database and fill our arrays with information + // Read from the FlatFile database and fill our arrays with information try { FileReader file = new FileReader(mcMMO.getUsersFilePath()); BufferedReader in = new BufferedReader(file); @@ -64,7 +65,7 @@ public final class Leaderboard { String p = character[0]; int powerLevel = 0; - //Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...) + // Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...) if (players.contains(p)) { continue; } @@ -136,10 +137,11 @@ public final class Leaderboard { in.close(); } catch (Exception e) { - mcMMO.p.getLogger().severe(("Exception while reading " + mcMMO.getUsersFilePath() + " (Are you sure you formatted it correctly?)" + e.toString())); + mcMMO.p.getLogger().severe("Exception while reading " + mcMMO.getUsersFilePath() + " (Are you sure you formatted it correctly?)" + e.toString()); } SkillComparator c = new SkillComparator(); + Collections.sort(mining, c); Collections.sort(woodcutting, c); Collections.sort(repair, c); @@ -227,6 +229,7 @@ public final class Leaderboard { currentPos++; continue; } + return new int[] {0, 0}; } @@ -246,19 +249,13 @@ public final class Leaderboard { currentPos++; continue; } + return new int[] {0, 0}; } return new int[] {0, 0}; } - private static class SkillComparator implements Comparator { - @Override - public int compare(PlayerStat o1, PlayerStat o2) { - return (o2.statVal - o1.statVal); - } - } - public static boolean removeFlatFileUser(String playerName) { boolean worked = false; @@ -274,18 +271,18 @@ public final class Leaderboard { while ((line = in.readLine()) != null) { - /* Write out the same file but when we get to the player we want to remove, we skip his line. */ + // Write out the same file but when we get to the player we want to remove, we skip his line. if (!line.split(":")[0].equalsIgnoreCase(playerName)) { writer.append(line).append("\r\n"); } else { mcMMO.p.getLogger().info("User found, removing..."); worked = true; - continue; //Skip the player + continue; // Skip the player } } - out = new FileWriter(usersFilePath); //Write out the new file + out = new FileWriter(usersFilePath); // Write out the new file out.write(writer.toString()); } catch (Exception e) { @@ -314,13 +311,12 @@ public final class Leaderboard { return worked; } - public static void purgePowerlessFlatfile() { mcMMO.p.getLogger().info("Purging powerless users..."); int purgedUsers = 0; for (PlayerStat stat : powerLevels) { - if (stat.statVal == 0 && removeFlatFileUser(stat.name) && !Bukkit.getOfflinePlayer(stat.name).isOnline()) { + if (stat.statVal == 0 && removeFlatFileUser(stat.name) && !mcMMO.p.getServer().getOfflinePlayer(stat.name).isOnline()) { purgedUsers++; } } @@ -337,7 +333,7 @@ public final class Leaderboard { private static int removeOldFlatfileUsers() { int removedPlayers = 0; long currentTime = System.currentTimeMillis(); - long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff(); + long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff(); BufferedReader in = null; FileWriter out = null; @@ -351,7 +347,7 @@ public final class Leaderboard { while ((line = in.readLine()) != null) { - /* Write out the same file but when we get to the player we want to remove, we skip his line. */ + // Write out the same file but when we get to the player we want to remove, we skip his line. String[] splitLine = line.split(":"); if (splitLine.length > 37) { @@ -361,7 +357,7 @@ public final class Leaderboard { else { mcMMO.p.getLogger().info("User found, removing..."); removedPlayers++; - continue; //Skip the player + continue; // Skip the player } } else { @@ -369,7 +365,7 @@ public final class Leaderboard { } } - out = new FileWriter(usersFilePath); //Write out the new file + out = new FileWriter(usersFilePath); // Write out the new file out.write(writer.toString()); } catch (Exception e) { @@ -398,4 +394,10 @@ public final class Leaderboard { return removedPlayers; } + private static class SkillComparator implements Comparator { + @Override + public int compare(PlayerStat o1, PlayerStat o2) { + return (o2.statVal - o1.statVal); + } + } } diff --git a/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java b/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java deleted file mode 100644 index a4738d10a..000000000 --- a/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.gmail.nossr50.database.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.Database; -import com.gmail.nossr50.database.Leaderboard; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; - -public class McpurgeCommand implements CommandExecutor{ - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!Permissions.mcpurge(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - switch (args.length) { - case 0: - if (Config.getInstance().getUseMySQL()) { - Database.purgePowerlessSQL(); - - if (Config.getInstance().getOldUsersCutoff() != -1) { - Database.purgeOldSQL(); - } - } - else { - Leaderboard.purgePowerlessFlatfile(); - - if (Config.getInstance().getOldUsersCutoff() != -1) { - Leaderboard.purgeOldFlatfile(); - } - } - - sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/database/commands/McremoveCommand.java b/src/main/java/com/gmail/nossr50/database/commands/McremoveCommand.java deleted file mode 100644 index 62f7f02c4..000000000 --- a/src/main/java/com/gmail/nossr50/database/commands/McremoveCommand.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.gmail.nossr50.database.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.Database; -import com.gmail.nossr50.database.Leaderboard; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; - -public class McremoveCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!Permissions.mcremove(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - switch (args.length) { - case 1: - /* MySQL */ - if (Config.getInstance().getUseMySQL()) { - String tablePrefix = Config.getInstance().getMySQLTablePrefix(); - - if (Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) { - Database.profileCleanup(args[0]); - sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0])); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - } - } - else { - if (Leaderboard.removeFlatFileUser(args[0])) { - Database.profileCleanup(args[0]); - sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0])); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - } - } - - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/database/runnables/SQLReconnect.java b/src/main/java/com/gmail/nossr50/database/runnables/SQLReconnect.java deleted file mode 100644 index 37a289284..000000000 --- a/src/main/java/com/gmail/nossr50/database/runnables/SQLReconnect.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.gmail.nossr50.database.runnables; - -import org.bukkit.entity.Player; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.database.Database; -import com.gmail.nossr50.util.Users; - -public class SQLReconnect implements Runnable { - @Override - public void run() { - if (Database.checkConnected()) { - Users.saveAll(); //Save all profiles - Users.clearAll(); //Clear the profiles - - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { - Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL - } - } - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/database/DatabaseUpdateType.java b/src/main/java/com/gmail/nossr50/datatypes/database/DatabaseUpdateType.java new file mode 100644 index 000000000..e173443c7 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/datatypes/database/DatabaseUpdateType.java @@ -0,0 +1,8 @@ +package com.gmail.nossr50.datatypes.database; + +public enum DatabaseUpdateType { + FISHING, + BLAST_MINING, + CASCADE_DELETE, + INDEX; +} diff --git a/src/main/java/com/gmail/nossr50/database/PlayerStat.java b/src/main/java/com/gmail/nossr50/datatypes/database/PlayerStat.java similarity index 79% rename from src/main/java/com/gmail/nossr50/database/PlayerStat.java rename to src/main/java/com/gmail/nossr50/datatypes/database/PlayerStat.java index 3c6b9c324..825be52ba 100644 --- a/src/main/java/com/gmail/nossr50/database/PlayerStat.java +++ b/src/main/java/com/gmail/nossr50/datatypes/database/PlayerStat.java @@ -1,11 +1,11 @@ -package com.gmail.nossr50.database; - -public class PlayerStat { - public String name; - public int statVal = 0; - - public PlayerStat(String name, int value) { - this.name = name; - this.statVal = value; - } -} \ No newline at end of file +package com.gmail.nossr50.datatypes.database; + +public class PlayerStat { + public String name; + public int statVal = 0; + + public PlayerStat(String name, int value) { + this.name = name; + this.statVal = value; + } +} diff --git a/src/main/java/com/gmail/nossr50/mods/datatypes/CustomBlock.java b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java similarity index 93% rename from src/main/java/com/gmail/nossr50/mods/datatypes/CustomBlock.java rename to src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java index 269bf2bac..5a4f9b129 100644 --- a/src/main/java/com/gmail/nossr50/mods/datatypes/CustomBlock.java +++ b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java @@ -1,79 +1,79 @@ -package com.gmail.nossr50.mods.datatypes; - -import org.bukkit.inventory.ItemStack; - -public class CustomBlock { - private int itemID; - private byte dataValue; - private int xpGain; - private int tier; - private ItemStack itemDrop; - private int minimumDropAmount; - private int maximumDropAmount; - - public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) { - this.itemID = itemID; - this.dataValue = dataValue; - this.xpGain = xpGain; - this.tier = tier; - this.itemDrop = itemDrop; - this.minimumDropAmount = minimumDropAmount; - this.maximumDropAmount = maximumDropAmount; - } - - public int getItemID() { - return itemID; - } - - public void setItemID(int itemID) { - this.itemID = itemID; - } - - public byte getDataValue() { - return dataValue; - } - - public void setDataValue(byte dataValue) { - this.dataValue = dataValue; - } - - public int getXpGain() { - return xpGain; - } - - public void setXpGain(int xpGain) { - this.xpGain = xpGain; - } - - public int getTier() { - return tier; - } - - public void setTier(int tier) { - this.tier = tier; - } - - public ItemStack getItemDrop() { - return itemDrop; - } - - public void setItemDrop(ItemStack itemDrop) { - this.itemDrop = itemDrop; - } - - public int getMinimumDropAmount() { - return minimumDropAmount; - } - - public void setMinimumDropAmount(int minimumDropAmount) { - this.minimumDropAmount = minimumDropAmount; - } - - public int getMaximumDropAmount() { - return maximumDropAmount; - } - - public void setMaximumDropAmount(int maximumDropAmount) { - this.maximumDropAmount = maximumDropAmount; - } -} +package com.gmail.nossr50.datatypes.mods; + +import org.bukkit.inventory.ItemStack; + +public class CustomBlock { + private int itemID; + private byte dataValue; + private int xpGain; + private int tier; + private ItemStack itemDrop; + private int minimumDropAmount; + private int maximumDropAmount; + + public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) { + this.itemID = itemID; + this.dataValue = dataValue; + this.xpGain = xpGain; + this.tier = tier; + this.itemDrop = itemDrop; + this.minimumDropAmount = minimumDropAmount; + this.maximumDropAmount = maximumDropAmount; + } + + public int getItemID() { + return itemID; + } + + public void setItemID(int itemID) { + this.itemID = itemID; + } + + public byte getDataValue() { + return dataValue; + } + + public void setDataValue(byte dataValue) { + this.dataValue = dataValue; + } + + public int getXpGain() { + return xpGain; + } + + public void setXpGain(int xpGain) { + this.xpGain = xpGain; + } + + public int getTier() { + return tier; + } + + public void setTier(int tier) { + this.tier = tier; + } + + public ItemStack getItemDrop() { + return itemDrop; + } + + public void setItemDrop(ItemStack itemDrop) { + this.itemDrop = itemDrop; + } + + public int getMinimumDropAmount() { + return minimumDropAmount; + } + + public void setMinimumDropAmount(int minimumDropAmount) { + this.minimumDropAmount = minimumDropAmount; + } + + public int getMaximumDropAmount() { + return maximumDropAmount; + } + + public void setMaximumDropAmount(int maximumDropAmount) { + this.maximumDropAmount = maximumDropAmount; + } +} diff --git a/src/main/java/com/gmail/nossr50/mods/datatypes/CustomEntity.java b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomEntity.java similarity index 94% rename from src/main/java/com/gmail/nossr50/mods/datatypes/CustomEntity.java rename to src/main/java/com/gmail/nossr50/datatypes/mods/CustomEntity.java index e29698964..166449a37 100644 --- a/src/main/java/com/gmail/nossr50/mods/datatypes/CustomEntity.java +++ b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomEntity.java @@ -1,94 +1,90 @@ -package com.gmail.nossr50.mods.datatypes; - -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; - -public class CustomEntity { - private int entityID; - private EntityType entityType; - private double xpMultiplier; - - private boolean canBeTamed; - private int tamingXP; - - private boolean canBeSummoned; - private ItemStack callOfTheWildItem; - private int callOfTheWildAmount; - - public CustomEntity(int entityID, EntityType entityType, double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) { - this.entityID = entityID; - this.entityType = entityType; - this.xpMultiplier = xpMultiplier; - - this.canBeTamed = canBeTamed; - this.tamingXP = tamingXP; - - this.canBeSummoned = canBeSummoned; - this.callOfTheWildItem = callOfTheWildItem; - this.callOfTheWildAmount = callOfTheWildAmount; - } - - public int getEntityID() { - return entityID; - } - - public void setEntityID(int entityID) { - this.entityID = entityID; - } - - public EntityType getEntityType() { - return entityType; - } - - public void setEntityType(EntityType entityType) { - this.entityType = entityType; - } - - public double getXpMultiplier() { - return xpMultiplier; - } - - public void setXpMultiplier(double xpMultiplier) { - this.xpMultiplier = xpMultiplier; - } - - public boolean isCanBeTamed() { - return canBeTamed; - } - - public void setCanBeTamed(boolean canBeTamed) { - this.canBeTamed = canBeTamed; - } - - public int getTamingXP() { - return tamingXP; - } - - public void setTamingXP(int tamingXP) { - this.tamingXP = tamingXP; - } - - public boolean isCanBeSummoned() { - return canBeSummoned; - } - - public void setCanBeSummoned(boolean canBeSummoned) { - this.canBeSummoned = canBeSummoned; - } - - public ItemStack getCallOfTheWildItem() { - return callOfTheWildItem; - } - - public void setCallOfTheWildItem(ItemStack callOfTheWildItem) { - this.callOfTheWildItem = callOfTheWildItem; - } - - public int getCallOfTheWildAmount() { - return callOfTheWildAmount; - } - - public void setCallOfTheWildAmount(int callOfTheWildAmount) { - this.callOfTheWildAmount = callOfTheWildAmount; - } -} +package com.gmail.nossr50.datatypes.mods; + +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +public class CustomEntity { + private int entityID; + private EntityType entityType; + private double xpMultiplier; + private boolean canBeTamed; + private int tamingXP; + private boolean canBeSummoned; + private ItemStack callOfTheWildItem; + private int callOfTheWildAmount; + + public CustomEntity(int entityID, EntityType entityType, double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) { + this.entityID = entityID; + this.entityType = entityType; + this.xpMultiplier = xpMultiplier; + this.canBeTamed = canBeTamed; + this.tamingXP = tamingXP; + this.canBeSummoned = canBeSummoned; + this.callOfTheWildItem = callOfTheWildItem; + this.callOfTheWildAmount = callOfTheWildAmount; + } + + public int getEntityID() { + return entityID; + } + + public void setEntityID(int entityID) { + this.entityID = entityID; + } + + public EntityType getEntityType() { + return entityType; + } + + public void setEntityType(EntityType entityType) { + this.entityType = entityType; + } + + public double getXpMultiplier() { + return xpMultiplier; + } + + public void setXpMultiplier(double xpMultiplier) { + this.xpMultiplier = xpMultiplier; + } + + public boolean isCanBeTamed() { + return canBeTamed; + } + + public void setCanBeTamed(boolean canBeTamed) { + this.canBeTamed = canBeTamed; + } + + public int getTamingXP() { + return tamingXP; + } + + public void setTamingXP(int tamingXP) { + this.tamingXP = tamingXP; + } + + public boolean isCanBeSummoned() { + return canBeSummoned; + } + + public void setCanBeSummoned(boolean canBeSummoned) { + this.canBeSummoned = canBeSummoned; + } + + public ItemStack getCallOfTheWildItem() { + return callOfTheWildItem; + } + + public void setCallOfTheWildItem(ItemStack callOfTheWildItem) { + this.callOfTheWildItem = callOfTheWildItem; + } + + public int getCallOfTheWildAmount() { + return callOfTheWildAmount; + } + + public void setCallOfTheWildAmount(int callOfTheWildAmount) { + this.callOfTheWildAmount = callOfTheWildAmount; + } +} diff --git a/src/main/java/com/gmail/nossr50/mods/datatypes/CustomItem.java b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomItem.java similarity index 88% rename from src/main/java/com/gmail/nossr50/mods/datatypes/CustomItem.java rename to src/main/java/com/gmail/nossr50/datatypes/mods/CustomItem.java index ae040aadb..3bd68e921 100644 --- a/src/main/java/com/gmail/nossr50/mods/datatypes/CustomItem.java +++ b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomItem.java @@ -1,27 +1,27 @@ -package com.gmail.nossr50.mods.datatypes; - -public class CustomItem { - protected int itemID; - protected short durability; - - public CustomItem(int itemID, short durability) { - this.itemID = itemID; - this.durability = durability; - } - - public int getItemID() { - return itemID; - } - - public void setItemID(int itemID) { - this.itemID = itemID; - } - - public short getDurability() { - return durability; - } - - public void setDurability(short durability) { - this.durability = durability; - } -} +package com.gmail.nossr50.datatypes.mods; + +public class CustomItem { + protected int itemID; + protected short durability; + + public CustomItem(int itemID, short durability) { + this.itemID = itemID; + this.durability = durability; + } + + public int getItemID() { + return itemID; + } + + public void setItemID(int itemID) { + this.itemID = itemID; + } + + public short getDurability() { + return durability; + } + + public void setDurability(short durability) { + this.durability = durability; + } +} diff --git a/src/main/java/com/gmail/nossr50/mods/datatypes/CustomTool.java b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomTool.java similarity index 91% rename from src/main/java/com/gmail/nossr50/mods/datatypes/CustomTool.java rename to src/main/java/com/gmail/nossr50/datatypes/mods/CustomTool.java index 3485863f1..00e9d42ae 100644 --- a/src/main/java/com/gmail/nossr50/mods/datatypes/CustomTool.java +++ b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomTool.java @@ -1,38 +1,38 @@ -package com.gmail.nossr50.mods.datatypes; - -public class CustomTool extends CustomItem { - private double xpMultiplier; - private boolean abilityEnabled; - private int tier; - - public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) { - super(itemID, durability); - this.xpMultiplier = xpMultiplier; - this.abilityEnabled = abilityEnabled; - this.tier = tier; - } - - public double getXpMultiplier() { - return xpMultiplier; - } - - public void setXpMultiplier(Double xpMultiplier) { - this.xpMultiplier = xpMultiplier; - } - - public boolean isAbilityEnabled() { - return abilityEnabled; - } - - public void setAbilityEnabled(boolean abilityEnabled) { - this.abilityEnabled = abilityEnabled; - } - - public int getTier() { - return tier; - } - - public void setTier(int tier) { - this.tier = tier; - } -} +package com.gmail.nossr50.datatypes.mods; + +public class CustomTool extends CustomItem { + private double xpMultiplier; + private boolean abilityEnabled; + private int tier; + + public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) { + super(itemID, durability); + this.xpMultiplier = xpMultiplier; + this.abilityEnabled = abilityEnabled; + this.tier = tier; + } + + public double getXpMultiplier() { + return xpMultiplier; + } + + public void setXpMultiplier(Double xpMultiplier) { + this.xpMultiplier = xpMultiplier; + } + + public boolean isAbilityEnabled() { + return abilityEnabled; + } + + public void setAbilityEnabled(boolean abilityEnabled) { + this.abilityEnabled = abilityEnabled; + } + + public int getTier() { + return tier; + } + + public void setTier(int tier) { + this.tier = tier; + } +} diff --git a/src/main/java/com/gmail/nossr50/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java similarity index 82% rename from src/main/java/com/gmail/nossr50/party/Party.java rename to src/main/java/com/gmail/nossr50/datatypes/party/Party.java index 6d7ccc7c9..d042735e8 100644 --- a/src/main/java/com/gmail/nossr50/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -1,134 +1,144 @@ -package com.gmail.nossr50.party; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - -public class Party { - private List members = new ArrayList(); - private String leader; - private String name; - private String password; - private boolean locked; - private ShareHandler.ShareMode xpShareMode = ShareHandler.ShareMode.NONE; - private ShareHandler.ShareMode itemShareMode = ShareHandler.ShareMode.NONE; - private boolean shareLootDrops = true; - private boolean shareMiningDrops = true; - private boolean shareHerbalismDrops = true; - private boolean shareWoodcuttingDrops = true; - - public List getMembers() { - return members; - } - - public List getOnlineMembers() { - List onlineMembers = new ArrayList(); - - for (OfflinePlayer member : members) { - if (member.isOnline()) { - onlineMembers.add(member.getPlayer()); - } - } - - return onlineMembers; - } - - public String getLeader() { - return leader; - } - - public String getName() { - return name; - } - - public String getPassword() { - return password; - } - - public boolean isLocked() { - return locked; - } - - public boolean sharingLootDrops() { - return shareLootDrops; - } - - public boolean sharingMiningDrops() { - return shareMiningDrops; - } - - public boolean sharingHerbalismDrops() { - return shareHerbalismDrops; - } - - public boolean sharingWoodcuttingDrops() { - return shareWoodcuttingDrops; - } - - public List getItemShareCategories() { //TODO Locale the category names! - List shareCategories = new ArrayList(); - if (sharingLootDrops()) { - shareCategories.add("Loot"); - } - if (sharingMiningDrops()) { - shareCategories.add("Mining"); - } - if (sharingHerbalismDrops()) { - shareCategories.add("Herbalism"); - } - if (sharingWoodcuttingDrops()) { - shareCategories.add("Woodcutting"); - } - return shareCategories; - } - - public void setName(String name) { - this.name = name; - } - - public void setLeader(String leader) { - this.leader = leader; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setLocked(boolean locked) { - this.locked = locked; - } - - public void setXpShareMode(ShareHandler.ShareMode xpShareMode) { - this.xpShareMode = xpShareMode; - } - - public ShareHandler.ShareMode getXpShareMode() { - return xpShareMode; - } - - public void setItemShareMode(ShareHandler.ShareMode itemShareMode) { - this.itemShareMode = itemShareMode; - } - - public ShareHandler.ShareMode getItemShareMode() { - return itemShareMode; - } - - public void setSharingLootDrops(boolean enabled) { - this.shareLootDrops = enabled; - } - - public void setSharingMiningDrops(boolean enabled) { - this.shareMiningDrops = enabled; - } - - public void setSharingHerbalismDrops(boolean enabled) { - this.shareHerbalismDrops = enabled; - } - - public void setSharingWoodcuttingDrops(boolean enabled) { - this.shareWoodcuttingDrops = enabled; - } -} +package com.gmail.nossr50.datatypes.party; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.party.ShareHandler; + +public class Party { + private List members = new ArrayList(); + private String leader; + private String name; + private String password; + private boolean locked; + + private ShareHandler.ShareMode xpShareMode = ShareHandler.ShareMode.NONE; + private ShareHandler.ShareMode itemShareMode = ShareHandler.ShareMode.NONE; + + private boolean shareLootDrops = true; + private boolean shareMiningDrops = true; + private boolean shareHerbalismDrops = true; + private boolean shareWoodcuttingDrops = true; + + public List getMembers() { + return members; + } + + public List getOnlineMembers() { + List onlineMembers = new ArrayList(); + + for (OfflinePlayer member : members) { + if (member.isOnline()) { + onlineMembers.add(member.getPlayer()); + } + } + + return onlineMembers; + } + + public String getLeader() { + return leader; + } + + public String getName() { + return name; + } + + public String getPassword() { + return password; + } + + public boolean isLocked() { + return locked; + } + + public boolean sharingLootDrops() { + return shareLootDrops; + } + + public boolean sharingMiningDrops() { + return shareMiningDrops; + } + + public boolean sharingHerbalismDrops() { + return shareHerbalismDrops; + } + + public boolean sharingWoodcuttingDrops() { + return shareWoodcuttingDrops; + } + + public List getItemShareCategories() { + List shareCategories = new ArrayList(); + + // TODO Locale the category names! + if (sharingLootDrops()) { + shareCategories.add("Loot"); + } + + if (sharingMiningDrops()) { + shareCategories.add("Mining"); + } + + if (sharingHerbalismDrops()) { + shareCategories.add("Herbalism"); + } + + if (sharingWoodcuttingDrops()) { + shareCategories.add("Woodcutting"); + } + + return shareCategories; + } + + public void setName(String name) { + this.name = name; + } + + public void setLeader(String leader) { + this.leader = leader; + } + + public void setPassword(String password) { + this.password = password; + } + + public void setLocked(boolean locked) { + this.locked = locked; + } + + public void setXpShareMode(ShareHandler.ShareMode xpShareMode) { + this.xpShareMode = xpShareMode; + } + + public ShareHandler.ShareMode getXpShareMode() { + return xpShareMode; + } + + public void setItemShareMode(ShareHandler.ShareMode itemShareMode) { + this.itemShareMode = itemShareMode; + } + + public ShareHandler.ShareMode getItemShareMode() { + return itemShareMode; + } + + public void setSharingLootDrops(boolean enabled) { + shareLootDrops = enabled; + } + + public void setSharingMiningDrops(boolean enabled) { + shareMiningDrops = enabled; + } + + public void setSharingHerbalismDrops(boolean enabled) { + shareHerbalismDrops = enabled; + } + + public void setSharingWoodcuttingDrops(boolean enabled) { + shareWoodcuttingDrops = enabled; + } +} diff --git a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java similarity index 86% rename from src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java rename to src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 4c1f56d97..54a5929e2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -1,298 +1,308 @@ -package com.gmail.nossr50.datatypes; - -import java.util.Set; - -import org.bukkit.GameMode; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.mods.datatypes.CustomTool; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.party.ShareHandler; -import com.gmail.nossr50.skills.child.FamilyTree; -import com.gmail.nossr50.skills.utilities.PerksUtils; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.spout.huds.SpoutHud; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; - -public class McMMOPlayer { - private Player player; - private PlayerProfile profile; - private Party party; - private Party invite; - private Player ptpRequest; - private boolean ptpEnabled = true; - private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired(); - private long ptpTimeout; - private int itemShareModifier; - private boolean partyChatMode; - private boolean adminChatMode; - - public McMMOPlayer (Player player) { - String playerName = player.getName(); - this.player = player; - this.profile = new PlayerProfile(playerName, true); - this.party = PartyManager.getPlayerParty(playerName); - } - - /** - * Gets the power level of this player. - * - * @return the power level of the player - */ - public int getPowerLevel() { - int powerLevel = 0; - - for (SkillType type : SkillType.values()) { - if (type.isChildSkill()) { - continue; - } - - if (Permissions.skillEnabled(player, type)) { - powerLevel += profile.getSkillLevel(type); - } - } - - return powerLevel; - } - - /** - * Begins an experience gain. The amount will be affected by skill modifiers, global rate, perks, and may be shared with the party - * - * @param skillType Skill being used - * @param xp Experience amount to process - */ - public void beginXpGain(SkillType skillType, int xp) { - if (xp == 0) { - return; - } - - if (skillType.isChildSkill()) { - Set parentSkills = FamilyTree.getParents(skillType); - - for (SkillType parentSkill : parentSkills) { - if (Permissions.skillEnabled(player, parentSkill)) { - beginXpGain(parentSkill, xp / parentSkills.size()); - } - } - - return; - } - - // Return if the experience has been shared - if (party != null && ShareHandler.handleXpShare(xp, this, skillType)) { - return; - } - - beginUnsharedXpGain(skillType, xp); - } - - /** - * Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks - * - * @param skillType Skill being used - * @param xp Experience amount to process - */ - public void beginUnsharedXpGain(SkillType skillType, int xp) { - xp = modifyXpGain(skillType, xp); - - applyXpGain(skillType, xp); - } - - /** - * Applies an experience gain - * - * @param skillType Skill being used - * @param xp Experience amount to add - */ - public void applyXpGain(SkillType skillType, int xp) { - McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - - profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + event.getXpGained()); - - SpoutHud spoutHud = profile.getSpoutHud(); - - if (spoutHud != null) { - spoutHud.setLastGained(skillType); - } - - SkillTools.xpCheckSkill(skillType, player, profile); - } - - /** - * Modifies an experience gain using skill modifiers, global rate and perks - * - * @param skillType Skill being used - * @param xp Experience amount to process - * @return Modified experience - */ - private int modifyXpGain(SkillType skillType, int xp) { - if (player.getGameMode() == GameMode.CREATIVE) { - return 0; - } - - if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1)) { - return 0; - } - - xp = (int) (xp / skillType.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()); - - if (Config.getInstance().getToolModsEnabled()) { - ItemStack item = player.getItemInHand(); - CustomTool tool = ModChecks.getToolFromItemStack(item); - - if (tool != null) { - xp *= tool.getXpMultiplier(); - } - } - - xp = PerksUtils.handleXpPerks(player, xp); - return xp; - } - - // Players & Profiles - - public Player getPlayer() { - return player; - } - - public void setPlayer(Player player) { - this.player = player; - } - - public PlayerProfile getProfile() { - return profile; - } - - // Party Stuff - - public void setPartyInvite(Party invite) { - this.invite = invite; - } - - public Party getPartyInvite() { - return invite; - } - - public boolean hasPartyInvite() { - if (invite != null) { - return true; - } - - return false; - } - - public void setParty(Party party) { - this.party = party; - } - - public Party getParty() { - return party; - } - - public boolean inParty() { - if (party != null) { - return true; - } - - return false; - } - - public void removeParty() { - party = null; - } - - public void removePartyInvite() { - invite = null; - } - - public boolean getPtpEnabled() { - return ptpEnabled; - } - - public void togglePtpUse() { - ptpEnabled = !ptpEnabled; - } - - public Player getPtpRequest() { - return ptpRequest; - } - - public void setPtpRequest(Player ptpRequest) { - this.ptpRequest = ptpRequest; - } - - public boolean hasPtpRequest() { - return (ptpRequest != null) ? true : false; - } - - public void removePtpRequest() { - ptpRequest = null; - } - - public boolean getPtpConfirmRequired() { - return ptpConfirmRequired; - } - - public void togglePtpConfirmRequired() { - ptpConfirmRequired = !ptpConfirmRequired; - } - - public long getPtpTimeout() { - return ptpTimeout; - } - - public void actualizePtpTimeout() { - ptpTimeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); - } - - public int getItemShareModifier() { - if (itemShareModifier < 10) { - setItemShareModifier(10); - } - return itemShareModifier; - } - - public void setItemShareModifier(int modifier) { - if (modifier < 10) { - modifier = 10; - } - itemShareModifier = modifier; - } - - public boolean getAdminChatMode() { - return adminChatMode; - } - - public void setAdminChat(boolean enabled) { - adminChatMode = enabled; - } - - public void toggleAdminChat() { - adminChatMode = !adminChatMode; - } - - public boolean getPartyChatMode() { - return partyChatMode; - } - - public void setPartyChat(boolean enabled) { - partyChatMode = enabled; - } - - public void togglePartyChat() { - partyChatMode = !partyChatMode; - } -} +package com.gmail.nossr50.datatypes.player; + +import java.util.Set; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.mods.CustomTool; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; +import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.party.ShareHandler; +import com.gmail.nossr50.skills.child.FamilyTree; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.ModUtils; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.PerksUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class McMMOPlayer { + private Player player; + private PlayerProfile profile; + + private Party party; + private Party invite; + + private Player ptpRequest; + private boolean ptpEnabled = true; + private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired(); + private long ptpTimeout; + + private boolean partyChatMode; + private boolean adminChatMode; + + private int itemShareModifier; + + public McMMOPlayer(Player player) { + String playerName = player.getName(); + + this.player = player; + this.profile = new PlayerProfile(playerName, true); + this.party = PartyManager.getPlayerParty(playerName); + } + + /** + * Gets the power level of this player. + * + * @return the power level of the player + */ + public int getPowerLevel() { + int powerLevel = 0; + + for (SkillType type : SkillType.values()) { + if (type.isChildSkill()) { + continue; + } + + if (Permissions.skillEnabled(player, type)) { + powerLevel += profile.getSkillLevel(type); + } + } + + return powerLevel; + } + + /** + * Begins an experience gain. The amount will be affected by skill modifiers, global rate, perks, and may be shared with the party + * + * @param skillType Skill being used + * @param xp Experience amount to process + */ + public void beginXpGain(SkillType skillType, int xp) { + if (xp == 0) { + return; + } + + if (skillType.isChildSkill()) { + Set parentSkills = FamilyTree.getParents(skillType); + + for (SkillType parentSkill : parentSkills) { + if (Permissions.skillEnabled(player, parentSkill)) { + beginXpGain(parentSkill, xp / parentSkills.size()); + } + } + + return; + } + + // Return if the experience has been shared + if (party != null && ShareHandler.handleXpShare(xp, this, skillType)) { + return; + } + + beginUnsharedXpGain(skillType, xp); + } + + /** + * Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks + * + * @param skillType Skill being used + * @param xp Experience amount to process + */ + public void beginUnsharedXpGain(SkillType skillType, int xp) { + xp = modifyXpGain(skillType, xp); + + applyXpGain(skillType, xp); + } + + /** + * Applies an experience gain + * + * @param skillType Skill being used + * @param xp Experience amount to add + */ + public void applyXpGain(SkillType skillType, int xp) { + McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp); + mcMMO.p.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + + profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + event.getXpGained()); + + McMMOHud spoutHud = profile.getSpoutHud(); + + if (spoutHud != null) { + spoutHud.setLastGained(skillType); + } + + SkillUtils.xpCheckSkill(skillType, player, profile); + } + + // Players & Profiles + + public Player getPlayer() { + return player; + } + + public void setPlayer(Player player) { + this.player = player; + } + + public PlayerProfile getProfile() { + return profile; + } + + // Party Stuff + + public void setPartyInvite(Party invite) { + this.invite = invite; + } + + public Party getPartyInvite() { + return invite; + } + + public boolean hasPartyInvite() { + if (invite != null) { + return true; + } + + return false; + } + + public void setParty(Party party) { + this.party = party; + } + + public Party getParty() { + return party; + } + + public boolean inParty() { + if (party != null) { + return true; + } + + return false; + } + + public void removeParty() { + party = null; + } + + public void removePartyInvite() { + invite = null; + } + + public boolean getPtpEnabled() { + return ptpEnabled; + } + + public void togglePtpUse() { + ptpEnabled = !ptpEnabled; + } + + public Player getPtpRequest() { + return ptpRequest; + } + + public void setPtpRequest(Player ptpRequest) { + this.ptpRequest = ptpRequest; + } + + public boolean hasPtpRequest() { + if (ptpRequest != null) { + return true; + } + + return false; + } + + public void removePtpRequest() { + ptpRequest = null; + } + + public boolean getPtpConfirmRequired() { + return ptpConfirmRequired; + } + + public void togglePtpConfirmRequired() { + ptpConfirmRequired = !ptpConfirmRequired; + } + + public long getPtpTimeout() { + return ptpTimeout; + } + + public void actualizePtpTimeout() { + ptpTimeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + + public int getItemShareModifier() { + if (itemShareModifier < 10) { + setItemShareModifier(10); + } + + return itemShareModifier; + } + + public void setItemShareModifier(int modifier) { + if (modifier < 10) { + modifier = 10; + } + + itemShareModifier = modifier; + } + + public boolean getAdminChatMode() { + return adminChatMode; + } + + public void setAdminChat(boolean enabled) { + adminChatMode = enabled; + } + + public void toggleAdminChat() { + adminChatMode = !adminChatMode; + } + + public boolean getPartyChatMode() { + return partyChatMode; + } + + public void setPartyChat(boolean enabled) { + partyChatMode = enabled; + } + + public void togglePartyChat() { + partyChatMode = !partyChatMode; + } + + /** + * Modifies an experience gain using skill modifiers, global rate and perks + * + * @param skillType Skill being used + * @param xp Experience amount to process + * @return Modified experience + */ + private int modifyXpGain(SkillType skillType, int xp) { + if (player.getGameMode() == GameMode.CREATIVE) { + return 0; + } + + if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1)) { + return 0; + } + + xp = (int) (xp / skillType.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()); + + if (Config.getInstance().getToolModsEnabled()) { + ItemStack item = player.getItemInHand(); + CustomTool tool = ModUtils.getToolFromItemStack(item); + + if (tool != null) { + xp *= tool.getXpMultiplier(); + } + } + + return PerksUtils.handleXpPerks(player, xp); + } +} diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java similarity index 71% rename from src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java rename to src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 6243d03bd..22b48e460 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -1,980 +1,1068 @@ -package com.gmail.nossr50.datatypes; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileReader; -import java.io.FileWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Set; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.Database; -import com.gmail.nossr50.skills.child.FamilyTree; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.skills.utilities.ToolType; -import com.gmail.nossr50.spout.SpoutConfig; -import com.gmail.nossr50.spout.huds.HudType; -import com.gmail.nossr50.spout.huds.SpoutHud; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.StringUtils; - -public class PlayerProfile { - private String playerName; - - // HUD - private SpoutHud spoutHud; - private HudType hudType; - - // Toggles - private boolean loaded; - private boolean placedAnvil; - private boolean placedSalvageAnvil; - private boolean godMode; - private boolean greenTerraMode, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, skullSplitterMode, berserkMode; - private boolean greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true, - superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true; - private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode, - pickaxePreparationMode, axePreparationMode; - private boolean abilityUse = true; - private boolean displaySkillNotifications = true; - - // Timestamps - private long recentlyHurt; - private int respawnATS; - - // mySQL STUFF - private int userId; - - private HashMap skills = new HashMap(); //Skills and Levels - HashMap skillsXp = new HashMap(); //Skills and Xp - HashMap skillsDATS = new HashMap(); - HashMap toolATS = new HashMap(); - - private final static String location = mcMMO.getUsersFilePath(); - - public PlayerProfile(String playerName, boolean addNew) { - this.playerName = playerName; - - if (mcMMO.spoutEnabled) { - hudType = SpoutConfig.getInstance().defaultHudType; - } - else { - hudType = HudType.DISABLED; - } - - for (AbilityType abilityType : AbilityType.values()) { - skillsDATS.put(abilityType, 0); - } - - for (SkillType skillType : SkillType.values()) { - if (!skillType.isChildSkill()) { - skills.put(skillType, 0); - skillsXp.put(skillType, 0); - } - } - - if (Config.getInstance().getUseMySQL()) { - if (!loadMySQL() && addNew) { - addMySQLPlayer(); - loaded = true; - } - } - else if (!load() && addNew) { - addPlayer(); - loaded = true; - } - } - - public String getPlayerName() { - return playerName; - } - - public boolean loadMySQL() { - String tablePrefix = Config.getInstance().getMySQLTablePrefix(); - - userId = Database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'"); - - if (userId == 0) { - return false; - } - - HashMap> huds = Database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId); - - if (huds.get(1) == null) { - Database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")"); - } - else { - for (HudType type : HudType.values()) { - if (type.toString().equals(huds.get(1).get(0))) { - hudType = type; - } - } - } - - /* - * I'm still learning MySQL, this is a fix for adding a new table - * its not pretty but it works - */ - HashMap> cooldowns = Database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId); - ArrayList cooldownValues = cooldowns.get(1); - - if (cooldownValues == null) { - Database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")"); - mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset."); - } - else { - skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldownValues.get(0))); - skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldownValues.get(1))); - skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldownValues.get(2))); - skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldownValues.get(3))); - skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldownValues.get(4))); - skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldownValues.get(5))); - skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(cooldownValues.get(6))); - skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7))); - } - - HashMap> stats = Database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId); - ArrayList statValues = stats.get(1); - - if (statValues == null) { - Database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")"); - mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset."); - } - else { - skills.put(SkillType.TAMING, Integer.valueOf(statValues.get(0))); - skills.put(SkillType.MINING, Integer.valueOf(statValues.get(1))); - skills.put(SkillType.REPAIR, Integer.valueOf(statValues.get(2))); - skills.put(SkillType.WOODCUTTING, Integer.valueOf(statValues.get(3))); - skills.put(SkillType.UNARMED, Integer.valueOf(statValues.get(4))); - skills.put(SkillType.HERBALISM, Integer.valueOf(statValues.get(5))); - skills.put(SkillType.EXCAVATION, Integer.valueOf(statValues.get(6))); - skills.put(SkillType.ARCHERY, Integer.valueOf(statValues.get(7))); - skills.put(SkillType.SWORDS, Integer.valueOf(statValues.get(8))); - skills.put(SkillType.AXES, Integer.valueOf(statValues.get(9))); - skills.put(SkillType.ACROBATICS, Integer.valueOf(statValues.get(10))); - skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11))); - } - - HashMap> experience = Database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId); - ArrayList experienceValues = experience.get(1); - - if (experienceValues == null) { - Database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")"); - mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset."); - } - else { - skillsXp.put(SkillType.TAMING, Integer.valueOf(experienceValues.get(0))); - skillsXp.put(SkillType.MINING, Integer.valueOf(experienceValues.get(1))); - skillsXp.put(SkillType.REPAIR, Integer.valueOf(experienceValues.get(2))); - skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(experienceValues.get(3))); - skillsXp.put(SkillType.UNARMED, Integer.valueOf(experienceValues.get(4))); - skillsXp.put(SkillType.HERBALISM, Integer.valueOf(experienceValues.get(5))); - skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(experienceValues.get(6))); - skillsXp.put(SkillType.ARCHERY, Integer.valueOf(experienceValues.get(7))); - skillsXp.put(SkillType.SWORDS, Integer.valueOf(experienceValues.get(8))); - skillsXp.put(SkillType.AXES, Integer.valueOf(experienceValues.get(9))); - skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experienceValues.get(10))); - skillsXp.put(SkillType.FISHING, Integer.valueOf(experienceValues.get(11))); - } - - loaded = true; - return true; - } - - public void addMySQLPlayer() { - String tablePrefix = Config.getInstance().getMySQLTablePrefix(); - - Database.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")"); - userId = Database.getInt("SELECT id FROM "+tablePrefix + "users WHERE user = '" + playerName + "'"); - Database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")"); - Database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")"); - Database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")"); - } - - public boolean load() { - try { - // Open the user file - FileReader file = new FileReader(location); - BufferedReader in = new BufferedReader(file); - String line; - - while ((line = in.readLine()) != null) { - // Find if the line contains the player we want. - String[] character = line.split(":"); - - if (!character[0].equals(playerName)) { - continue; - } - - if (character.length > 1 && StringUtils.isInt(character[1])) - skills.put(SkillType.MINING, Integer.valueOf(character[1])); - if (character.length > 4 && StringUtils.isInt(character[4])) - skillsXp.put(SkillType.MINING, Integer.valueOf(character[4])); - if (character.length > 5 && StringUtils.isInt(character[5])) - skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5])); - if (character.length > 6 && StringUtils.isInt(character[6])) - skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6])); - if (character.length > 7 && StringUtils.isInt(character[7])) - skills.put(SkillType.REPAIR, Integer.valueOf(character[7])); - if (character.length > 8 && StringUtils.isInt(character[8])) - skills.put(SkillType.UNARMED, Integer.valueOf(character[8])); - if (character.length > 9 && StringUtils.isInt(character[9])) - skills.put(SkillType.HERBALISM, Integer.valueOf(character[9])); - if (character.length > 10 && StringUtils.isInt(character[10])) - skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10])); - if (character.length > 11 && StringUtils.isInt(character[11])) - skills.put(SkillType.ARCHERY, Integer.valueOf(character[11])); - if (character.length > 12 && StringUtils.isInt(character[12])) - skills.put(SkillType.SWORDS, Integer.valueOf(character[12])); - if (character.length > 13 && StringUtils.isInt(character[13])) - skills.put(SkillType.AXES, Integer.valueOf(character[13])); - if (character.length > 14 && StringUtils.isInt(character[14])) - skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14])); - if (character.length > 15 && StringUtils.isInt(character[15])) - skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15])); - if (character.length > 16 && StringUtils.isInt(character[16])) - skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16])); - if (character.length > 17 && StringUtils.isInt(character[17])) - skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17])); - if (character.length > 18 && StringUtils.isInt(character[18])) - skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18])); - if (character.length > 19 && StringUtils.isInt(character[19])) - skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19])); - if (character.length > 20 && StringUtils.isInt(character[20])) - skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20])); - if (character.length > 21 && StringUtils.isInt(character[21])) - skillsXp.put(SkillType.AXES, Integer.valueOf(character[21])); - if (character.length > 22 && StringUtils.isInt(character[22])) - skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22])); - if (character.length > 24 && StringUtils.isInt(character[24])) - skills.put(SkillType.TAMING, Integer.valueOf(character[24])); - if (character.length > 25 && StringUtils.isInt(character[25])) - skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25])); - if (character.length > 26) - skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26])); - if (character.length > 27) - skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27])); - if (character.length > 28) - skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28])); - if (character.length > 29) - skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29])); - if (character.length > 30) - skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30])); - if (character.length > 31) - skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[31])); - if (character.length > 32) - skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32])); - if (character.length > 33) { - for (HudType type : HudType.values()) { - if (type.toString().equalsIgnoreCase(character[33])) { - hudType = type; - } - } - } - if (character.length > 34) - skills.put(SkillType.FISHING, Integer.valueOf(character[34])); - if (character.length > 35) - skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35])); - if (character.length > 36) - skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36])); - - loaded = true; - - in.close(); - return true; - } - - in.close(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - public void save() { - Long timestamp = System.currentTimeMillis(); - - // If we are using mysql save to database - if (Config.getInstance().getUseMySQL()) { - String tablePrefix = Config.getInstance().getMySQLTablePrefix(); - - Database.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId); - Database.write("UPDATE " + tablePrefix + "users SET lastlogin = " + ((int) (timestamp / Misc.TIME_CONVERSION_FACTOR)) + " WHERE id = " + userId); - Database.write("UPDATE " + tablePrefix + "cooldowns SET " - + " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER) - + ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER) - + ", unarmed = " + skillsDATS.get(AbilityType.BERSERK) - + ", herbalism = " + skillsDATS.get(AbilityType.GREEN_TERRA) - + ", excavation = " + skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER) - + ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES) - + ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLITTER) - + ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING) - + " WHERE user_id = " + userId); - Database.write("UPDATE " + tablePrefix + "skills SET " - + " taming = " + skills.get(SkillType.TAMING) - + ", mining = " + skills.get(SkillType.MINING) - + ", repair = " + skills.get(SkillType.REPAIR) - + ", woodcutting = " + skills.get(SkillType.WOODCUTTING) - + ", unarmed = " + skills.get(SkillType.UNARMED) - + ", herbalism = " + skills.get(SkillType.HERBALISM) - + ", excavation = " + skills.get(SkillType.EXCAVATION) - + ", archery = " + skills.get(SkillType.ARCHERY) - + ", swords = " + skills.get(SkillType.SWORDS) - + ", axes = " + skills.get(SkillType.AXES) - + ", acrobatics = " + skills.get(SkillType.ACROBATICS) - + ", fishing = " + skills.get(SkillType.FISHING) - + " WHERE user_id = " + userId); - Database.write("UPDATE " + tablePrefix + "experience SET " - + " taming = " + skillsXp.get(SkillType.TAMING) - + ", mining = " + skillsXp.get(SkillType.MINING) - + ", repair = " + skillsXp.get(SkillType.REPAIR) - + ", woodcutting = " + skillsXp.get(SkillType.WOODCUTTING) - + ", unarmed = " + skillsXp.get(SkillType.UNARMED) - + ", herbalism = " + skillsXp.get(SkillType.HERBALISM) - + ", excavation = " + skillsXp.get(SkillType.EXCAVATION) - + ", archery = " + skillsXp.get(SkillType.ARCHERY) - + ", swords = " + skillsXp.get(SkillType.SWORDS) - + ", axes = " + skillsXp.get(SkillType.AXES) - + ", acrobatics = " + skillsXp.get(SkillType.ACROBATICS) - + ", fishing = " + skillsXp.get(SkillType.FISHING) - + " WHERE user_id = " + userId); - } - else { - // Otherwise save to flatfile - try { - // Open the file - FileReader file = new FileReader(location); - BufferedReader in = new BufferedReader(file); - StringBuilder writer = new StringBuilder(); - String line; - - // While not at the end of the file - while ((line = in.readLine()) != null) { - // Read the line in and copy it to the output it's not the player - // we want to edit - if (!line.split(":")[0].equals(playerName)) { - writer.append(line).append("\r\n"); - } - else { - // Otherwise write the new player information - writer.append(playerName).append(":"); - writer.append(skills.get(SkillType.MINING)).append(":"); - writer.append(":"); - writer.append(":"); - writer.append(skillsXp.get(SkillType.MINING)).append(":"); - writer.append(skills.get(SkillType.WOODCUTTING)).append(":"); - writer.append(skillsXp.get(SkillType.WOODCUTTING)).append(":"); - writer.append(skills.get(SkillType.REPAIR)).append(":"); - writer.append(skills.get(SkillType.UNARMED)).append(":"); - writer.append(skills.get(SkillType.HERBALISM)).append(":"); - writer.append(skills.get(SkillType.EXCAVATION)).append(":"); - writer.append(skills.get(SkillType.ARCHERY)).append(":"); - writer.append(skills.get(SkillType.SWORDS)).append(":"); - writer.append(skills.get(SkillType.AXES)).append(":"); - writer.append(skills.get(SkillType.ACROBATICS)).append(":"); - writer.append(skillsXp.get(SkillType.REPAIR)).append(":"); - writer.append(skillsXp.get(SkillType.UNARMED)).append(":"); - writer.append(skillsXp.get(SkillType.HERBALISM)).append(":"); - writer.append(skillsXp.get(SkillType.EXCAVATION)).append(":"); - writer.append(skillsXp.get(SkillType.ARCHERY)).append(":"); - writer.append(skillsXp.get(SkillType.SWORDS)).append(":"); - writer.append(skillsXp.get(SkillType.AXES)).append(":"); - writer.append(skillsXp.get(SkillType.ACROBATICS)).append(":"); - writer.append(":"); - writer.append(skills.get(SkillType.TAMING)).append(":"); - writer.append(skillsXp.get(SkillType.TAMING)).append(":"); - // Need to store the DATS of abilities nao - // Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker - writer.append(skillsDATS.get(AbilityType.BERSERK)).append(":"); - writer.append(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)).append(":"); - writer.append(skillsDATS.get(AbilityType.TREE_FELLER)).append(":"); - writer.append(skillsDATS.get(AbilityType.GREEN_TERRA)).append(":"); - writer.append(skillsDATS.get(AbilityType.SERRATED_STRIKES)).append(":"); - writer.append(skillsDATS.get(AbilityType.SKULL_SPLITTER)).append(":"); - writer.append(skillsDATS.get(AbilityType.SUPER_BREAKER)).append(":"); - writer.append(hudType.toString()).append(":"); - writer.append(skills.get(SkillType.FISHING)).append(":"); - writer.append(skillsXp.get(SkillType.FISHING)).append(":"); - writer.append(skillsDATS.get(AbilityType.BLAST_MINING)).append(":"); - writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":"); - writer.append("\r\n"); - } - } - - in.close(); - // Write the new file - FileWriter out = new FileWriter(location); - out.write(writer.toString()); - out.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - } - - public void addPlayer() { - try { - // Open the file to write the player - FileWriter file = new FileWriter(location, true); - BufferedWriter out = new BufferedWriter(file); - - // Add the player to the end - out.append(playerName).append(":"); - out.append("0:"); // mining - out.append(":"); - out.append(":"); - out.append("0:"); // Xp - out.append("0:"); // woodcutting - out.append("0:"); // woodCuttingXp - out.append("0:"); // repair - out.append("0:"); // unarmed - out.append("0:"); // herbalism - out.append("0:"); // excavation - out.append("0:"); // archery - out.append("0:"); // swords - out.append("0:"); // axes - out.append("0:"); // acrobatics - out.append("0:"); // repairXp - out.append("0:"); // unarmedXp - out.append("0:"); // herbalismXp - out.append("0:"); // excavationXp - out.append("0:"); // archeryXp - out.append("0:"); // swordsXp - out.append("0:"); // axesXp - out.append("0:"); // acrobaticsXp - out.append(":"); - out.append("0:"); // taming - out.append("0:"); // tamingXp - out.append("0:"); // DATS - out.append("0:"); // DATS - out.append("0:"); // DATS - out.append("0:"); // DATS - out.append("0:"); // DATS - out.append("0:"); // DATS - out.append("0:"); // DATS - out.append(hudType.toString()).append(":"); // HUD - out.append("0:"); // Fishing - out.append("0:"); // FishingXp - out.append("0:"); // Blast Mining - out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); //LastLogin - - // Add more in the same format as the line above - - out.newLine(); - out.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /* - * mySQL Stuff - */ - - public int getMySQLuserId() { - return userId; - } - - public boolean isLoaded() { - return loaded; - } - - /* - * God Mode - */ - - public boolean getGodMode() { - return godMode; - } - - public void toggleGodMode() { - godMode = !godMode; - } - - /* - * Repair Anvil Placement - */ - - public void togglePlacedAnvil() { - placedAnvil = !placedAnvil; - } - - public Boolean getPlacedAnvil() { - return placedAnvil; - } - /* - * Salvage Anvil Placement - */ - public void togglePlacedSalvageAnvil() { - placedSalvageAnvil = !placedSalvageAnvil; - } - - public Boolean getPlacedSalvageAnvil() { - return placedSalvageAnvil; - } - - /* - * HUD Stuff - */ - - public HudType getHudType() { - return hudType; - } - - public SpoutHud getSpoutHud() { - return spoutHud; - } - - public void setSpoutHud(SpoutHud spoutHud) { - this.spoutHud = spoutHud; - } - - public void setHudType(HudType hudType) { - this.hudType = hudType; - } - - /* - * Tools - */ - - /** - * Reset the prep modes of all tools. - */ - public void resetToolPrepMode() { - for (ToolType tool : ToolType.values()) { - setToolPreparationMode(tool, false); - } - } - - /** - * Get the current prep mode of a tool. - * - * @param tool Tool to get the mode for - * @return true if the tool is prepped, false otherwise - */ - public boolean getToolPreparationMode(ToolType tool) { - switch (tool) { - case AXE: - return axePreparationMode; - - case FISTS: - return fistsPreparationMode; - - case HOE: - return hoePreparationMode; - - case PICKAXE: - return pickaxePreparationMode; - - case SHOVEL: - return shovelPreparationMode; - - case SWORD: - return swordsPreparationMode; - - default: - return false; - } - } - - /** - * Set the current prep mode of a tool. - * - * @param tool Tool to set the mode for - * @param bool true if the tool should be prepped, false otherwise - */ - public void setToolPreparationMode(ToolType tool, boolean bool) { - switch (tool) { - case AXE: - axePreparationMode = bool; - break; - - case FISTS: - fistsPreparationMode = bool; - break; - - case HOE: - hoePreparationMode = bool; - break; - - case PICKAXE: - pickaxePreparationMode = bool; - break; - - case SHOVEL: - shovelPreparationMode = bool; - break; - - case SWORD: - swordsPreparationMode = bool; - break; - - default: - break; - } - } - - /** - * Get the current prep ATS of a tool. - * - * @param tool Tool to get the ATS for - * @return the ATS for the tool - */ - public long getToolPreparationATS(ToolType tool) { - return toolATS.get(tool); - } - - /** - * Set the current prep ATS of a tool. - * - * @param tool Tool to set the ATS for - * @param ATS the ATS of the tool - */ - public void setToolPreparationATS(ToolType tool, long ATS) { - int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR); - toolATS.put(tool, startTime); - } - - /* - * Abilities - */ - - /** - * Reset the prep modes of all tools. - */ - public void resetAbilityMode() { - for (AbilityType ability : AbilityType.values()) { - setAbilityMode(ability, false); - } - } - - /** - * Get the mode of an ability. - * - * @param ability The ability to check - * @return true if the ability is enabled, false otherwise - */ - public boolean getAbilityMode(AbilityType ability) { - switch (ability) { - case BERSERK: - return berserkMode; - - case SUPER_BREAKER: - return superBreakerMode; - - case GIGA_DRILL_BREAKER: - return gigaDrillBreakerMode; - - case GREEN_TERRA: - return greenTerraMode; - - case SKULL_SPLITTER: - return skullSplitterMode; - - case TREE_FELLER: - return treeFellerMode; - - case SERRATED_STRIKES: - return serratedStrikesMode; - - default: - return false; - } - } - - /** - * Set the mode of an ability. - * - * @param ability The ability to check - * @param bool True if the ability is active, false otherwise - */ - public void setAbilityMode(AbilityType ability, boolean bool) { - switch (ability) { - case BERSERK: - berserkMode = bool; - break; - - case SUPER_BREAKER: - superBreakerMode = bool; - break; - - case GIGA_DRILL_BREAKER: - gigaDrillBreakerMode = bool; - break; - - case GREEN_TERRA: - greenTerraMode = bool; - break; - - case SKULL_SPLITTER: - skullSplitterMode = bool; - break; - - case TREE_FELLER: - treeFellerMode = bool; - break; - - case SERRATED_STRIKES: - serratedStrikesMode = bool; - break; - - default: - break; - } - } - - /** - * Get the informed state of an ability - * - * @param ability The ability to check - * @return true if the ability is informed, false otherwise - */ - public boolean getAbilityInformed(AbilityType ability) { - switch (ability) { - case BERSERK: - return berserkInformed; - - case BLAST_MINING: - return blastMiningInformed; - - case SUPER_BREAKER: - return superBreakerInformed; - - case GIGA_DRILL_BREAKER: - return gigaDrillBreakerInformed; - - case GREEN_TERRA: - return greenTerraInformed; - - case SKULL_SPLITTER: - return skullSplitterInformed; - - case TREE_FELLER: - return treeFellerInformed; - - case SERRATED_STRIKES: - return serratedStrikesInformed; - - default: - return false; - } - } - - /** - * Set the informed state of an ability. - * - * @param ability The ability to check - * @param bool True if the ability is informed, false otherwise - */ - public void setAbilityInformed(AbilityType ability, boolean bool) { - switch (ability) { - case BERSERK: - berserkInformed = bool; - break; - - case BLAST_MINING: - blastMiningInformed = bool; - break; - - case SUPER_BREAKER: - superBreakerInformed = bool; - break; - - case GIGA_DRILL_BREAKER: - gigaDrillBreakerInformed = bool; - break; - - case GREEN_TERRA: - greenTerraInformed = bool; - break; - - case SKULL_SPLITTER: - skullSplitterInformed = bool; - break; - - case TREE_FELLER: - treeFellerInformed = bool; - break; - - case SERRATED_STRIKES: - serratedStrikesInformed = bool; - break; - - default: - break; - } - } - - public boolean getAbilityUse() { - return abilityUse; - } - - public void toggleAbilityUse() { - abilityUse = !abilityUse; - } - - /* - * Recently Hurt - */ - - public long getRecentlyHurt() { - return recentlyHurt; - } - - public void setRecentlyHurt(long value) { - recentlyHurt = value; - } - - public void actualizeRecentlyHurt() { - respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); - } - - /* - * Ability Notifications - */ - - public boolean useChatNotifications() { - return displaySkillNotifications; - } - - public void toggleChatNotifications() { - displaySkillNotifications = !displaySkillNotifications; - } - - /* - * Cooldowns - */ - - /** - * Get the current DATS of a skill. - * - * @param abilityType Ability to get the DATS for - * @return the DATS for the ability - */ - public long getSkillDATS(AbilityType abilityType) { - return skillsDATS.get(abilityType); - } - - /** - * Set the current DATS of a skill. - * - * @param abilityType Ability to set the DATS for - * @param DATS the DATS of the ability - */ - public void setSkillDATS(AbilityType abilityType, long DATS) { - int wearsOff = (int) (DATS * .001D); - skillsDATS.put(abilityType, wearsOff); - } - - /** - * Reset all skill cooldowns. - */ - public void resetCooldowns() { - for (AbilityType x : skillsDATS.keySet()) { - skillsDATS.put(x, 0); - } - } - - /* - * Exploit Prevention - */ - - public int getRespawnATS() { - return respawnATS; - } - - public void actualizeRespawnATS() { - respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); - } - - /* - * Xp Functions - */ - - public int getSkillLevel(SkillType skillType) { - if (skillType.isChildSkill()) { - return getChildSkillLevel(skillType); - } - - return skills.get(skillType); - } - - public int getChildSkillLevel(SkillType skillType) { - Set parents = FamilyTree.getParents(skillType); - int sum = 0; - for (SkillType parent : parents) { - sum += Math.min(getSkillLevel(parent), 1000); - } - return sum / parents.size(); - } - - public int getSkillXpLevel(SkillType skillType) { - return skillsXp.get(skillType); - } - - public void setSkillXpLevel(SkillType skillType, int newValue) { - skillsXp.put(skillType, newValue); - } - - public void skillUp(SkillType skillType, int newValue) { - skills.put(skillType, skills.get(skillType) + newValue); - } - - /** - * Remove Xp from a skill. - * - * @param skillType Type of skill to modify - * @param xp Amount of xp to remove - */ - public void removeXp(SkillType skillType, int xp) { - if (skillType.isChildSkill()) { - return; - } - - skillsXp.put(skillType, skillsXp.get(skillType) - xp); - } - - /** - * Modify a skill level. - * - * @param skillType Type of skill to modify - * @param newValue New level value for the skill - */ - public void modifySkill(SkillType skillType, int newValue) { - if (skillType.isChildSkill()) { - return; - } - - skills.put(skillType, newValue); - skillsXp.put(skillType, 0); - } - - /** - * Add levels to a skill. - * - * @param skillType Type of skill to add levels to - * @param levels Number of levels to add - */ - public void addLevels(SkillType skillType, int levels) { - if (skillType.isChildSkill()) { - return; - } - - skills.put(skillType, skills.get(skillType) + levels); - skillsXp.put(skillType, 0); - } - - /** - * Get the amount of Xp remaining before the next level. - * - * @param skillType Type of skill to check - * @return the Xp remaining until next level - */ - public int getXpToLevel(SkillType skillType) { - return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve()); - } -} +package com.gmail.nossr50.datatypes.player; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Set; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.spout.SpoutConfig; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.skills.ToolType; +import com.gmail.nossr50.datatypes.spout.huds.HudType; +import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; +import com.gmail.nossr50.skills.child.FamilyTree; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; + +public class PlayerProfile { + private String playerName; + + // HUD + private McMMOHud spoutHud; + private HudType hudType; + + // Toggles + private boolean loaded; + private boolean godMode; + + private boolean placedAnvil; + private boolean placedSalvageAnvil; + + private boolean hoePreparationMode; + private boolean shovelPreparationMode; + private boolean swordsPreparationMode; + private boolean fistsPreparationMode; + private boolean pickaxePreparationMode; + private boolean axePreparationMode; + + private boolean greenTerraMode; + private boolean treeFellerMode; + private boolean superBreakerMode; + private boolean gigaDrillBreakerMode; + private boolean serratedStrikesMode; + private boolean skullSplitterMode; + private boolean berserkMode; + + private boolean greenTerraInformed = true; + private boolean berserkInformed = true; + private boolean skullSplitterInformed = true; + private boolean gigaDrillBreakerInformed = true; + private boolean superBreakerInformed = true; + private boolean blastMiningInformed = true; + private boolean serratedStrikesInformed = true; + private boolean treeFellerInformed = true; + + private boolean abilityUse = true; + private boolean displaySkillNotifications = true; + + // Timestamps + private long recentlyHurt; + private int respawnATS; + + // mySQL Stuff + private int userId; + + private HashMap skills = new HashMap(); // Skills and Levels + private HashMap skillsXp = new HashMap(); // Skills and Xp + private HashMap skillsDATS = new HashMap(); + private HashMap toolATS = new HashMap(); + + private final static String location = mcMMO.getUsersFilePath(); + + public PlayerProfile(String playerName, boolean addNew) { + this.playerName = playerName; + + if (mcMMO.spoutEnabled) { + hudType = SpoutConfig.getInstance().defaultHudType; + } + else { + hudType = HudType.DISABLED; + } + + for (AbilityType abilityType : AbilityType.values()) { + skillsDATS.put(abilityType, 0); + } + + for (SkillType skillType : SkillType.values()) { + if (!skillType.isChildSkill()) { + skills.put(skillType, 0); + skillsXp.put(skillType, 0); + } + } + + if (Config.getInstance().getUseMySQL()) { + if (!loadMySQL() && addNew) { + addMySQLPlayer(); + loaded = true; + } + } + else if (!load() && addNew) { + addPlayer(); + loaded = true; + } + } + + public String getPlayerName() { + return playerName; + } + + public boolean loadMySQL() { + String tablePrefix = Config.getInstance().getMySQLTablePrefix(); + + userId = DatabaseManager.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'"); + + if (userId == 0) { + return false; + } + + HashMap> huds = DatabaseManager.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId); + + if (huds.get(1) == null) { + DatabaseManager.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")"); + } + else { + for (HudType type : HudType.values()) { + if (type.toString().equals(huds.get(1).get(0))) { + hudType = type; + } + } + } + + HashMap> cooldowns = DatabaseManager.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId); + ArrayList cooldownValues = cooldowns.get(1); + + if (cooldownValues == null) { + DatabaseManager.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")"); + mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset."); + } + else { + skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldownValues.get(0))); + skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldownValues.get(1))); + skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldownValues.get(2))); + skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldownValues.get(3))); + skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldownValues.get(4))); + skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldownValues.get(5))); + skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(cooldownValues.get(6))); + skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7))); + } + + HashMap> stats = DatabaseManager.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId); + ArrayList statValues = stats.get(1); + + if (statValues == null) { + DatabaseManager.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")"); + mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset."); + } + else { + skills.put(SkillType.TAMING, Integer.valueOf(statValues.get(0))); + skills.put(SkillType.MINING, Integer.valueOf(statValues.get(1))); + skills.put(SkillType.REPAIR, Integer.valueOf(statValues.get(2))); + skills.put(SkillType.WOODCUTTING, Integer.valueOf(statValues.get(3))); + skills.put(SkillType.UNARMED, Integer.valueOf(statValues.get(4))); + skills.put(SkillType.HERBALISM, Integer.valueOf(statValues.get(5))); + skills.put(SkillType.EXCAVATION, Integer.valueOf(statValues.get(6))); + skills.put(SkillType.ARCHERY, Integer.valueOf(statValues.get(7))); + skills.put(SkillType.SWORDS, Integer.valueOf(statValues.get(8))); + skills.put(SkillType.AXES, Integer.valueOf(statValues.get(9))); + skills.put(SkillType.ACROBATICS, Integer.valueOf(statValues.get(10))); + skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11))); + } + + HashMap> experience = DatabaseManager.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId); + ArrayList experienceValues = experience.get(1); + + if (experienceValues == null) { + DatabaseManager.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")"); + mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset."); + } + else { + skillsXp.put(SkillType.TAMING, Integer.valueOf(experienceValues.get(0))); + skillsXp.put(SkillType.MINING, Integer.valueOf(experienceValues.get(1))); + skillsXp.put(SkillType.REPAIR, Integer.valueOf(experienceValues.get(2))); + skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(experienceValues.get(3))); + skillsXp.put(SkillType.UNARMED, Integer.valueOf(experienceValues.get(4))); + skillsXp.put(SkillType.HERBALISM, Integer.valueOf(experienceValues.get(5))); + skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(experienceValues.get(6))); + skillsXp.put(SkillType.ARCHERY, Integer.valueOf(experienceValues.get(7))); + skillsXp.put(SkillType.SWORDS, Integer.valueOf(experienceValues.get(8))); + skillsXp.put(SkillType.AXES, Integer.valueOf(experienceValues.get(9))); + skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experienceValues.get(10))); + skillsXp.put(SkillType.FISHING, Integer.valueOf(experienceValues.get(11))); + } + + loaded = true; + return true; + } + + public void addMySQLPlayer() { + String tablePrefix = Config.getInstance().getMySQLTablePrefix(); + + DatabaseManager.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")"); + userId = DatabaseManager.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'"); + + DatabaseManager.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")"); + DatabaseManager.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")"); + DatabaseManager.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")"); + } + + public boolean load() { + try { + // Open the user file + FileReader file = new FileReader(location); + BufferedReader in = new BufferedReader(file); + String line; + + while ((line = in.readLine()) != null) { + // Find if the line contains the player we want. + String[] character = line.split(":"); + + if (!character[0].equals(playerName)) { + continue; + } + + if (character.length > 1 && StringUtils.isInt(character[1])) { + skills.put(SkillType.MINING, Integer.valueOf(character[1])); + } + + if (character.length > 4 && StringUtils.isInt(character[4])) { + skillsXp.put(SkillType.MINING, Integer.valueOf(character[4])); + } + + if (character.length > 5 && StringUtils.isInt(character[5])) { + skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5])); + } + + if (character.length > 6 && StringUtils.isInt(character[6])) { + skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6])); + } + + if (character.length > 7 && StringUtils.isInt(character[7])) { + skills.put(SkillType.REPAIR, Integer.valueOf(character[7])); + } + + if (character.length > 8 && StringUtils.isInt(character[8])) { + skills.put(SkillType.UNARMED, Integer.valueOf(character[8])); + } + + if (character.length > 9 && StringUtils.isInt(character[9])) { + skills.put(SkillType.HERBALISM, Integer.valueOf(character[9])); + } + + if (character.length > 10 && StringUtils.isInt(character[10])) { + skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10])); + } + + if (character.length > 11 && StringUtils.isInt(character[11])) { + skills.put(SkillType.ARCHERY, Integer.valueOf(character[11])); + } + + if (character.length > 12 && StringUtils.isInt(character[12])) { + skills.put(SkillType.SWORDS, Integer.valueOf(character[12])); + } + + if (character.length > 13 && StringUtils.isInt(character[13])) { + skills.put(SkillType.AXES, Integer.valueOf(character[13])); + } + + if (character.length > 14 && StringUtils.isInt(character[14])) { + skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14])); + } + + if (character.length > 15 && StringUtils.isInt(character[15])) { + skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15])); + } + + if (character.length > 16 && StringUtils.isInt(character[16])) { + skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16])); + } + + if (character.length > 17 && StringUtils.isInt(character[17])) { + skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17])); + } + + if (character.length > 18 && StringUtils.isInt(character[18])) { + skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18])); + } + + if (character.length > 19 && StringUtils.isInt(character[19])) { + skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19])); + } + + if (character.length > 20 && StringUtils.isInt(character[20])) { + skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20])); + } + + if (character.length > 21 && StringUtils.isInt(character[21])) { + skillsXp.put(SkillType.AXES, Integer.valueOf(character[21])); + } + + if (character.length > 22 && StringUtils.isInt(character[22])) { + skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22])); + } + + if (character.length > 24 && StringUtils.isInt(character[24])) { + skills.put(SkillType.TAMING, Integer.valueOf(character[24])); + } + + if (character.length > 25 && StringUtils.isInt(character[25])) { + skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25])); + } + + if (character.length > 26) { + skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26])); + } + + if (character.length > 27) { + skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27])); + } + + if (character.length > 28) { + skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28])); + } + + if (character.length > 29) { + skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29])); + } + + if (character.length > 30) { + skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30])); + } + + if (character.length > 31) { + skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[31])); + } + + if (character.length > 32) { + skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32])); + } + + if (character.length > 33) { + for (HudType type : HudType.values()) { + if (type.toString().equalsIgnoreCase(character[33])) { + hudType = type; + } + } + } + + if (character.length > 34) { + skills.put(SkillType.FISHING, Integer.valueOf(character[34])); + } + + if (character.length > 35) { + skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35])); + } + + if (character.length > 36) { + skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36])); + } + + loaded = true; + + in.close(); + return true; + } + + in.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + public void save() { + Long timestamp = System.currentTimeMillis(); + + // If we are using mysql save to database + if (Config.getInstance().getUseMySQL()) { + String tablePrefix = Config.getInstance().getMySQLTablePrefix(); + + DatabaseManager.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId); + DatabaseManager.write("UPDATE " + tablePrefix + "users SET lastlogin = " + ((int) (timestamp / Misc.TIME_CONVERSION_FACTOR)) + " WHERE id = " + userId); + DatabaseManager.write("UPDATE " + tablePrefix + "cooldowns SET " + + " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER) + + ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER) + + ", unarmed = " + skillsDATS.get(AbilityType.BERSERK) + + ", herbalism = " + skillsDATS.get(AbilityType.GREEN_TERRA) + + ", excavation = " + skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER) + + ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES) + + ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLITTER) + + ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING) + + " WHERE user_id = " + userId); + DatabaseManager.write("UPDATE " + tablePrefix + "skills SET " + + " taming = " + skills.get(SkillType.TAMING) + + ", mining = " + skills.get(SkillType.MINING) + + ", repair = " + skills.get(SkillType.REPAIR) + + ", woodcutting = " + skills.get(SkillType.WOODCUTTING) + + ", unarmed = " + skills.get(SkillType.UNARMED) + + ", herbalism = " + skills.get(SkillType.HERBALISM) + + ", excavation = " + skills.get(SkillType.EXCAVATION) + + ", archery = " + skills.get(SkillType.ARCHERY) + + ", swords = " + skills.get(SkillType.SWORDS) + + ", axes = " + skills.get(SkillType.AXES) + + ", acrobatics = " + skills.get(SkillType.ACROBATICS) + + ", fishing = " + skills.get(SkillType.FISHING) + + " WHERE user_id = " + userId); + DatabaseManager.write("UPDATE " + tablePrefix + "experience SET " + + " taming = " + skillsXp.get(SkillType.TAMING) + + ", mining = " + skillsXp.get(SkillType.MINING) + + ", repair = " + skillsXp.get(SkillType.REPAIR) + + ", woodcutting = " + skillsXp.get(SkillType.WOODCUTTING) + + ", unarmed = " + skillsXp.get(SkillType.UNARMED) + + ", herbalism = " + skillsXp.get(SkillType.HERBALISM) + + ", excavation = " + skillsXp.get(SkillType.EXCAVATION) + + ", archery = " + skillsXp.get(SkillType.ARCHERY) + + ", swords = " + skillsXp.get(SkillType.SWORDS) + + ", axes = " + skillsXp.get(SkillType.AXES) + + ", acrobatics = " + skillsXp.get(SkillType.ACROBATICS) + + ", fishing = " + skillsXp.get(SkillType.FISHING) + + " WHERE user_id = " + userId); + } + else { + // Otherwise save to flatfile + try { + // Open the file + FileReader file = new FileReader(location); + BufferedReader in = new BufferedReader(file); + StringBuilder writer = new StringBuilder(); + String line; + + // While not at the end of the file + while ((line = in.readLine()) != null) { + // Read the line in and copy it to the output it's not the player we want to edit + if (!line.split(":")[0].equals(playerName)) { + writer.append(line).append("\r\n"); + } + else { + // Otherwise write the new player information + writer.append(playerName).append(":"); + writer.append(skills.get(SkillType.MINING)).append(":"); + writer.append(":"); + writer.append(":"); + writer.append(skillsXp.get(SkillType.MINING)).append(":"); + writer.append(skills.get(SkillType.WOODCUTTING)).append(":"); + writer.append(skillsXp.get(SkillType.WOODCUTTING)).append(":"); + writer.append(skills.get(SkillType.REPAIR)).append(":"); + writer.append(skills.get(SkillType.UNARMED)).append(":"); + writer.append(skills.get(SkillType.HERBALISM)).append(":"); + writer.append(skills.get(SkillType.EXCAVATION)).append(":"); + writer.append(skills.get(SkillType.ARCHERY)).append(":"); + writer.append(skills.get(SkillType.SWORDS)).append(":"); + writer.append(skills.get(SkillType.AXES)).append(":"); + writer.append(skills.get(SkillType.ACROBATICS)).append(":"); + writer.append(skillsXp.get(SkillType.REPAIR)).append(":"); + writer.append(skillsXp.get(SkillType.UNARMED)).append(":"); + writer.append(skillsXp.get(SkillType.HERBALISM)).append(":"); + writer.append(skillsXp.get(SkillType.EXCAVATION)).append(":"); + writer.append(skillsXp.get(SkillType.ARCHERY)).append(":"); + writer.append(skillsXp.get(SkillType.SWORDS)).append(":"); + writer.append(skillsXp.get(SkillType.AXES)).append(":"); + writer.append(skillsXp.get(SkillType.ACROBATICS)).append(":"); + writer.append(":"); + writer.append(skills.get(SkillType.TAMING)).append(":"); + writer.append(skillsXp.get(SkillType.TAMING)).append(":"); + writer.append(skillsDATS.get(AbilityType.BERSERK)).append(":"); + writer.append(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)).append(":"); + writer.append(skillsDATS.get(AbilityType.TREE_FELLER)).append(":"); + writer.append(skillsDATS.get(AbilityType.GREEN_TERRA)).append(":"); + writer.append(skillsDATS.get(AbilityType.SERRATED_STRIKES)).append(":"); + writer.append(skillsDATS.get(AbilityType.SKULL_SPLITTER)).append(":"); + writer.append(skillsDATS.get(AbilityType.SUPER_BREAKER)).append(":"); + writer.append(hudType.toString()).append(":"); + writer.append(skills.get(SkillType.FISHING)).append(":"); + writer.append(skillsXp.get(SkillType.FISHING)).append(":"); + writer.append(skillsDATS.get(AbilityType.BLAST_MINING)).append(":"); + writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":"); + writer.append("\r\n"); + } + } + + in.close(); + + // Write the new file + FileWriter out = new FileWriter(location); + out.write(writer.toString()); + out.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + } + + public void addPlayer() { + try { + // Open the file to write the player + FileWriter file = new FileWriter(location, true); + BufferedWriter out = new BufferedWriter(file); + + // Add the player to the end + out.append(playerName).append(":"); + out.append("0:"); // Mining + out.append(":"); + out.append(":"); + out.append("0:"); // Xp + out.append("0:"); // Woodcutting + out.append("0:"); // WoodCuttingXp + out.append("0:"); // Repair + out.append("0:"); // Unarmed + out.append("0:"); // Herbalism + out.append("0:"); // Excavation + out.append("0:"); // Archery + out.append("0:"); // Swords + out.append("0:"); // Axes + out.append("0:"); // Acrobatics + out.append("0:"); // RepairXp + out.append("0:"); // UnarmedXp + out.append("0:"); // HerbalismXp + out.append("0:"); // ExcavationXp + out.append("0:"); // ArcheryXp + out.append("0:"); // SwordsXp + out.append("0:"); // AxesXp + out.append("0:"); // AcrobaticsXp + out.append(":"); + out.append("0:"); // Taming + out.append("0:"); // TamingXp + out.append("0:"); // DATS + out.append("0:"); // DATS + out.append("0:"); // DATS + out.append("0:"); // DATS + out.append("0:"); // DATS + out.append("0:"); // DATS + out.append("0:"); // DATS + out.append(hudType.toString()).append(":"); // HUD + out.append("0:"); // Fishing + out.append("0:"); // FishingXp + out.append("0:"); // Blast Mining + out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); // LastLogin + + // Add more in the same format as the line above + + out.newLine(); + out.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /* + * mySQL Stuff + */ + + public int getMySQLuserId() { + return userId; + } + + public boolean isLoaded() { + return loaded; + } + + /* + * God Mode + */ + + public boolean getGodMode() { + return godMode; + } + + public void toggleGodMode() { + godMode = !godMode; + } + + /* + * Repair Anvil Placement + */ + + public void togglePlacedAnvil() { + placedAnvil = !placedAnvil; + } + + public Boolean getPlacedAnvil() { + return placedAnvil; + } + + /* + * Salvage Anvil Placement + */ + + public void togglePlacedSalvageAnvil() { + placedSalvageAnvil = !placedSalvageAnvil; + } + + public Boolean getPlacedSalvageAnvil() { + return placedSalvageAnvil; + } + + /* + * HUD Stuff + */ + + public HudType getHudType() { + return hudType; + } + + public McMMOHud getSpoutHud() { + return spoutHud; + } + + public void setSpoutHud(McMMOHud spoutHud) { + this.spoutHud = spoutHud; + } + + public void setHudType(HudType hudType) { + this.hudType = hudType; + } + + /* + * Tools + */ + + /** + * Reset the prep modes of all tools. + */ + public void resetToolPrepMode() { + for (ToolType tool : ToolType.values()) { + setToolPreparationMode(tool, false); + } + } + + /** + * Get the current prep mode of a tool. + * + * @param tool Tool to get the mode for + * @return true if the tool is prepped, false otherwise + */ + public boolean getToolPreparationMode(ToolType tool) { + switch (tool) { + case AXE: + return axePreparationMode; + + case FISTS: + return fistsPreparationMode; + + case HOE: + return hoePreparationMode; + + case PICKAXE: + return pickaxePreparationMode; + + case SHOVEL: + return shovelPreparationMode; + + case SWORD: + return swordsPreparationMode; + + default: + return false; + } + } + + /** + * Set the current prep mode of a tool. + * + * @param tool Tool to set the mode for + * @param bool true if the tool should be prepped, false otherwise + */ + public void setToolPreparationMode(ToolType tool, boolean bool) { + switch (tool) { + case AXE: + axePreparationMode = bool; + break; + + case FISTS: + fistsPreparationMode = bool; + break; + + case HOE: + hoePreparationMode = bool; + break; + + case PICKAXE: + pickaxePreparationMode = bool; + break; + + case SHOVEL: + shovelPreparationMode = bool; + break; + + case SWORD: + swordsPreparationMode = bool; + break; + + default: + break; + } + } + + /** + * Get the current prep ATS of a tool. + * + * @param tool Tool to get the ATS for + * @return the ATS for the tool + */ + public long getToolPreparationATS(ToolType tool) { + return toolATS.get(tool); + } + + /** + * Set the current prep ATS of a tool. + * + * @param tool Tool to set the ATS for + * @param ATS the ATS of the tool + */ + public void setToolPreparationATS(ToolType tool, long ATS) { + int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR); + + toolATS.put(tool, startTime); + } + + /* + * Abilities + */ + + /** + * Reset the prep modes of all tools. + */ + public void resetAbilityMode() { + for (AbilityType ability : AbilityType.values()) { + setAbilityMode(ability, false); + } + } + + /** + * Get the mode of an ability. + * + * @param ability The ability to check + * @return true if the ability is enabled, false otherwise + */ + public boolean getAbilityMode(AbilityType ability) { + switch (ability) { + case BERSERK: + return berserkMode; + + case SUPER_BREAKER: + return superBreakerMode; + + case GIGA_DRILL_BREAKER: + return gigaDrillBreakerMode; + + case GREEN_TERRA: + return greenTerraMode; + + case SKULL_SPLITTER: + return skullSplitterMode; + + case TREE_FELLER: + return treeFellerMode; + + case SERRATED_STRIKES: + return serratedStrikesMode; + + default: + return false; + } + } + + /** + * Set the mode of an ability. + * + * @param ability The ability to check + * @param bool True if the ability is active, false otherwise + */ + public void setAbilityMode(AbilityType ability, boolean bool) { + switch (ability) { + case BERSERK: + berserkMode = bool; + break; + + case SUPER_BREAKER: + superBreakerMode = bool; + break; + + case GIGA_DRILL_BREAKER: + gigaDrillBreakerMode = bool; + break; + + case GREEN_TERRA: + greenTerraMode = bool; + break; + + case SKULL_SPLITTER: + skullSplitterMode = bool; + break; + + case TREE_FELLER: + treeFellerMode = bool; + break; + + case SERRATED_STRIKES: + serratedStrikesMode = bool; + break; + + default: + break; + } + } + + /** + * Get the informed state of an ability + * + * @param ability The ability to check + * @return true if the ability is informed, false otherwise + */ + public boolean getAbilityInformed(AbilityType ability) { + switch (ability) { + case BERSERK: + return berserkInformed; + + case BLAST_MINING: + return blastMiningInformed; + + case SUPER_BREAKER: + return superBreakerInformed; + + case GIGA_DRILL_BREAKER: + return gigaDrillBreakerInformed; + + case GREEN_TERRA: + return greenTerraInformed; + + case SKULL_SPLITTER: + return skullSplitterInformed; + + case TREE_FELLER: + return treeFellerInformed; + + case SERRATED_STRIKES: + return serratedStrikesInformed; + + default: + return false; + } + } + + /** + * Set the informed state of an ability. + * + * @param ability The ability to check + * @param bool True if the ability is informed, false otherwise + */ + public void setAbilityInformed(AbilityType ability, boolean bool) { + switch (ability) { + case BERSERK: + berserkInformed = bool; + break; + + case BLAST_MINING: + blastMiningInformed = bool; + break; + + case SUPER_BREAKER: + superBreakerInformed = bool; + break; + + case GIGA_DRILL_BREAKER: + gigaDrillBreakerInformed = bool; + break; + + case GREEN_TERRA: + greenTerraInformed = bool; + break; + + case SKULL_SPLITTER: + skullSplitterInformed = bool; + break; + + case TREE_FELLER: + treeFellerInformed = bool; + break; + + case SERRATED_STRIKES: + serratedStrikesInformed = bool; + break; + + default: + break; + } + } + + public boolean getAbilityUse() { + return abilityUse; + } + + public void toggleAbilityUse() { + abilityUse = !abilityUse; + } + + /* + * Recently Hurt + */ + + public long getRecentlyHurt() { + return recentlyHurt; + } + + public void setRecentlyHurt(long value) { + recentlyHurt = value; + } + + public void actualizeRecentlyHurt() { + respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + + /* + * Ability Notifications + */ + + public boolean useChatNotifications() { + return displaySkillNotifications; + } + + public void toggleChatNotifications() { + displaySkillNotifications = !displaySkillNotifications; + } + + /* + * Cooldowns + */ + + /** + * Get the current DATS of a skill. + * + * @param abilityType Ability to get the DATS for + * @return the DATS for the ability + */ + public long getSkillDATS(AbilityType abilityType) { + return skillsDATS.get(abilityType); + } + + /** + * Set the current DATS of a skill. + * + * @param abilityType Ability to set the DATS for + * @param DATS the DATS of the ability + */ + public void setSkillDATS(AbilityType abilityType, long DATS) { + int wearsOff = (int) (DATS * .001D); + + skillsDATS.put(abilityType, wearsOff); + } + + /** + * Reset all skill cooldowns. + */ + public void resetCooldowns() { + for (AbilityType x : skillsDATS.keySet()) { + skillsDATS.put(x, 0); + } + } + + /* + * Exploit Prevention + */ + + public int getRespawnATS() { + return respawnATS; + } + + public void actualizeRespawnATS() { + respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + + /* + * Xp Functions + */ + + public int getSkillLevel(SkillType skillType) { + if (skillType.isChildSkill()) { + return getChildSkillLevel(skillType); + } + + return skills.get(skillType); + } + + public int getChildSkillLevel(SkillType skillType) { + Set parents = FamilyTree.getParents(skillType); + int sum = 0; + + for (SkillType parent : parents) { + sum += Math.min(getSkillLevel(parent), 1000); + } + + return sum / parents.size(); + } + + public int getSkillXpLevel(SkillType skillType) { + return skillsXp.get(skillType); + } + + public void setSkillXpLevel(SkillType skillType, int newValue) { + skillsXp.put(skillType, newValue); + } + + public void skillUp(SkillType skillType, int newValue) { + skills.put(skillType, skills.get(skillType) + newValue); + } + + /** + * Remove Xp from a skill. + * + * @param skillType Type of skill to modify + * @param xp Amount of xp to remove + */ + public void removeXp(SkillType skillType, int xp) { + if (skillType.isChildSkill()) { + return; + } + + skillsXp.put(skillType, skillsXp.get(skillType) - xp); + } + + /** + * Modify a skill level. + * + * @param skillType Type of skill to modify + * @param newValue New level value for the skill + */ + public void modifySkill(SkillType skillType, int newValue) { + if (skillType.isChildSkill()) { + return; + } + + skills.put(skillType, newValue); + skillsXp.put(skillType, 0); + } + + /** + * Add levels to a skill. + * + * @param skillType Type of skill to add levels to + * @param levels Number of levels to add + */ + public void addLevels(SkillType skillType, int levels) { + if (skillType.isChildSkill()) { + return; + } + + skills.put(skillType, skills.get(skillType) + levels); + skillsXp.put(skillType, 0); + } + + /** + * Get the amount of Xp remaining before the next level. + * + * @param skillType Type of skill to check + * @return the Xp remaining until next level + */ + public int getXpToLevel(SkillType skillType) { + return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve()); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/AbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/AbilityType.java similarity index 73% rename from src/main/java/com/gmail/nossr50/skills/utilities/AbilityType.java rename to src/main/java/com/gmail/nossr50/datatypes/skills/AbilityType.java index 25ae18b9e..a8632772e 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/AbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/AbilityType.java @@ -1,211 +1,211 @@ -package com.gmail.nossr50.skills.utilities; - -import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.BlockChecks; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; - -public enum AbilityType { - BERSERK( - "Unarmed.Skills.Berserk.On", - "Unarmed.Skills.Berserk.Off", - "Unarmed.Skills.Berserk.Other.On", - "Unarmed.Skills.Berserk.Refresh", - "Unarmed.Skills.Berserk.Other.Off"), - - SUPER_BREAKER( - "Mining.Skills.SuperBreaker.On", - "Mining.Skills.SuperBreaker.Off", - "Mining.Skills.SuperBreaker.Other.On", - "Mining.Skills.SuperBreaker.Refresh", - "Mining.Skills.SuperBreaker.Other.Off"), - - GIGA_DRILL_BREAKER( - "Excavation.Skills.GigaDrillBreaker.On", - "Excavation.Skills.GigaDrillBreaker.Off", - "Excavation.Skills.GigaDrillBreaker.Other.On", - "Excavation.Skills.GigaDrillBreaker.Refresh", - "Excavation.Skills.GigaDrillBreaker.Other.Off"), - - GREEN_TERRA( - "Herbalism.Skills.GTe.On", - "Herbalism.Skills.GTe.Off", - "Herbalism.Skills.GTe.Other.On", - "Herbalism.Skills.GTe.Refresh", - "Herbalism.Skills.GTe.Other.Off"), - - SKULL_SPLITTER( - "Axes.Skills.SS.On", - "Axes.Skills.SS.Off", - "Axes.Skills.SS.Other.On", - "Axes.Skills.SS.Refresh", - "Axes.Skills.SS.Other.Off"), - - TREE_FELLER( - "Woodcutting.Skills.TreeFeller.On", - "Woodcutting.Skills.TreeFeller.Off", - "Woodcutting.Skills.TreeFeller.Other.On", - "Woodcutting.Skills.TreeFeller.Refresh", - "Woodcutting.Skills.TreeFeller.Other.Off"), - - SERRATED_STRIKES( - "Swords.Skills.SS.On", - "Swords.Skills.SS.Off", - "Swords.Skills.SS.Other.On", - "Swords.Skills.SS.Refresh", - "Swords.Skills.SS.Other.Off"), - - BLAST_MINING( - null, - null, - "Mining.Blast.Other.On", - "Mining.Blast.Refresh", - null), - - LEAF_BLOWER( - null, - null, - null, - null, - null); - - private String abilityOn; - private String abilityOff; - private String abilityPlayer; - private String abilityRefresh; - private String abilityPlayerOff; - - private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { - this.abilityOn = abilityOn; - this.abilityOff = abilityOff; - this.abilityPlayer = abilityPlayer; - this.abilityRefresh = abilityRefresh; - this.abilityPlayerOff = abilityPlayerOff; - } - - public int getCooldown() { - return Config.getInstance().getCooldown(this); - } - - public int getMaxTicks() { - return Config.getInstance().getMaxTicks(this); - } - - public String getAbilityOn() { - return LocaleLoader.getString(this.abilityOn); - } - - public String getAbilityOff() { - return LocaleLoader.getString(this.abilityOff); - } - - public String getAbilityPlayer(Player player) { - return LocaleLoader.getString(this.abilityPlayer, player.getName()); - } - - public String getAbilityPlayerOff(Player player) { - return LocaleLoader.getString(this.abilityPlayerOff, player.getName()); - } - - public String getAbilityRefresh() { - return LocaleLoader.getString(this.abilityRefresh); - } - - @Override - public String toString() { - String baseString = name(); - String[] substrings = baseString.split("_"); - String formattedString = ""; - - int size = 1; - - for (String string : substrings) { - formattedString = formattedString.concat(StringUtils.getCapitalized(string)); - - if (size < substrings.length) { - formattedString = formattedString.concat("_"); - } - - size++; - } - - return formattedString; - } - - /** - * Get the permissions for this ability. - * - * @param player Player to check permissions for - * @return true if the player has permissions, false otherwise - */ - public boolean getPermissions(Player player) { - - switch (this) { - case BERSERK: - return Permissions.berserk(player); - - case BLAST_MINING: - return Permissions.remoteDetonation(player); - - case GIGA_DRILL_BREAKER: - return Permissions.gigaDrillBreaker(player); - - case GREEN_TERRA: - return Permissions.greenTerra(player); - - case LEAF_BLOWER: - return Permissions.leafBlower(player); - - case SERRATED_STRIKES: - return Permissions.serratedStrikes(player); - - case SKULL_SPLITTER: - return Permissions.skullSplitter(player); - - case SUPER_BREAKER: - return Permissions.superBreaker(player); - - case TREE_FELLER: - return Permissions.treeFeller(player); - - default: - return false; - } - } - - /** - * Check if a block is affected by this ability. - * - * @param blockState the block to check - * @return true if the block is affected by this ability, false otherwise - */ - public boolean blockCheck(BlockState blockState) { - switch (this) { - case BERSERK: - return (BlockChecks.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW); - - case GIGA_DRILL_BREAKER: - return BlockChecks.affectedByGigaDrillBreaker(blockState); - - case GREEN_TERRA: - return BlockChecks.canMakeMossy(blockState); - - case LEAF_BLOWER: - return BlockChecks.isLeaves(blockState); - - case SUPER_BREAKER: - return BlockChecks.affectedBySuperBreaker(blockState); - - case TREE_FELLER: - return BlockChecks.isLog(blockState); - - default: - return false; - } - } -} +package com.gmail.nossr50.datatypes.skills; + +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.BlockUtils; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; + +public enum AbilityType { + BERSERK( + "Unarmed.Skills.Berserk.On", + "Unarmed.Skills.Berserk.Off", + "Unarmed.Skills.Berserk.Other.On", + "Unarmed.Skills.Berserk.Refresh", + "Unarmed.Skills.Berserk.Other.Off"), + + SUPER_BREAKER( + "Mining.Skills.SuperBreaker.On", + "Mining.Skills.SuperBreaker.Off", + "Mining.Skills.SuperBreaker.Other.On", + "Mining.Skills.SuperBreaker.Refresh", + "Mining.Skills.SuperBreaker.Other.Off"), + + GIGA_DRILL_BREAKER( + "Excavation.Skills.GigaDrillBreaker.On", + "Excavation.Skills.GigaDrillBreaker.Off", + "Excavation.Skills.GigaDrillBreaker.Other.On", + "Excavation.Skills.GigaDrillBreaker.Refresh", + "Excavation.Skills.GigaDrillBreaker.Other.Off"), + + GREEN_TERRA( + "Herbalism.Skills.GTe.On", + "Herbalism.Skills.GTe.Off", + "Herbalism.Skills.GTe.Other.On", + "Herbalism.Skills.GTe.Refresh", + "Herbalism.Skills.GTe.Other.Off"), + + SKULL_SPLITTER( + "Axes.Skills.SS.On", + "Axes.Skills.SS.Off", + "Axes.Skills.SS.Other.On", + "Axes.Skills.SS.Refresh", + "Axes.Skills.SS.Other.Off"), + + TREE_FELLER( + "Woodcutting.Skills.TreeFeller.On", + "Woodcutting.Skills.TreeFeller.Off", + "Woodcutting.Skills.TreeFeller.Other.On", + "Woodcutting.Skills.TreeFeller.Refresh", + "Woodcutting.Skills.TreeFeller.Other.Off"), + + SERRATED_STRIKES( + "Swords.Skills.SS.On", + "Swords.Skills.SS.Off", + "Swords.Skills.SS.Other.On", + "Swords.Skills.SS.Refresh", + "Swords.Skills.SS.Other.Off"), + + BLAST_MINING( + null, + null, + "Mining.Blast.Other.On", + "Mining.Blast.Refresh", + null), + + LEAF_BLOWER( + null, + null, + null, + null, + null); + + private String abilityOn; + private String abilityOff; + private String abilityPlayer; + private String abilityRefresh; + private String abilityPlayerOff; + + private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { + this.abilityOn = abilityOn; + this.abilityOff = abilityOff; + this.abilityPlayer = abilityPlayer; + this.abilityRefresh = abilityRefresh; + this.abilityPlayerOff = abilityPlayerOff; + } + + public int getCooldown() { + return Config.getInstance().getCooldown(this); + } + + public int getMaxTicks() { + return Config.getInstance().getMaxTicks(this); + } + + public String getAbilityOn() { + return LocaleLoader.getString(this.abilityOn); + } + + public String getAbilityOff() { + return LocaleLoader.getString(this.abilityOff); + } + + public String getAbilityPlayer(Player player) { + return LocaleLoader.getString(this.abilityPlayer, player.getName()); + } + + public String getAbilityPlayerOff(Player player) { + return LocaleLoader.getString(this.abilityPlayerOff, player.getName()); + } + + public String getAbilityRefresh() { + return LocaleLoader.getString(this.abilityRefresh); + } + + @Override + public String toString() { + String baseString = name(); + String[] substrings = baseString.split("_"); + String formattedString = ""; + + int size = 1; + + for (String string : substrings) { + formattedString = formattedString.concat(StringUtils.getCapitalized(string)); + + if (size < substrings.length) { + formattedString = formattedString.concat("_"); + } + + size++; + } + + return formattedString; + } + + /** + * Get the permissions for this ability. + * + * @param player Player to check permissions for + * @return true if the player has permissions, false otherwise + */ + public boolean getPermissions(Player player) { + + switch (this) { + case BERSERK: + return Permissions.berserk(player); + + case BLAST_MINING: + return Permissions.remoteDetonation(player); + + case GIGA_DRILL_BREAKER: + return Permissions.gigaDrillBreaker(player); + + case GREEN_TERRA: + return Permissions.greenTerra(player); + + case LEAF_BLOWER: + return Permissions.leafBlower(player); + + case SERRATED_STRIKES: + return Permissions.serratedStrikes(player); + + case SKULL_SPLITTER: + return Permissions.skullSplitter(player); + + case SUPER_BREAKER: + return Permissions.superBreaker(player); + + case TREE_FELLER: + return Permissions.treeFeller(player); + + default: + return false; + } + } + + /** + * Check if a block is affected by this ability. + * + * @param blockState the block to check + * @return true if the block is affected by this ability, false otherwise + */ + public boolean blockCheck(BlockState blockState) { + switch (this) { + case BERSERK: + return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW); + + case GIGA_DRILL_BREAKER: + return BlockUtils.affectedByGigaDrillBreaker(blockState); + + case GREEN_TERRA: + return BlockUtils.canMakeMossy(blockState); + + case LEAF_BLOWER: + return BlockUtils.isLeaves(blockState); + + case SUPER_BREAKER: + return BlockUtils.affectedBySuperBreaker(blockState); + + case TREE_FELLER: + return BlockUtils.isLog(blockState); + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java similarity index 94% rename from src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java rename to src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java index af677f2cc..ecc9b55f1 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java @@ -1,98 +1,98 @@ -package com.gmail.nossr50.skills.utilities; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.StringUtils; - -public enum SkillType { - ACROBATICS, - ARCHERY, - AXES(AbilityType.SKULL_SPLITTER, ToolType.AXE), - EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL), - FISHING, - HERBALISM(AbilityType.GREEN_TERRA, ToolType.HOE), - MINING(AbilityType.SUPER_BREAKER, ToolType.PICKAXE), - REPAIR, - SMELTING, - SWORDS(AbilityType.SERRATED_STRIKES, ToolType.SWORD), - TAMING, - UNARMED(AbilityType.BERSERK, ToolType.FISTS), - WOODCUTTING(AbilityType.TREE_FELLER, ToolType.AXE); - - private AbilityType ability; - private ToolType tool; - - private SkillType() { - this.ability = null; - this.tool = null; - } - - private SkillType(AbilityType ability, ToolType tool) { - this.ability = ability; - this.tool = tool; - } - - public AbilityType getAbility() { - return ability; - } - - /** - * Get the max level of this skill. - * - * @return the max level of this skill - */ - public int getMaxLevel() { - return Config.getInstance().getLevelCap(this); - } - - public boolean getPVPEnabled() { - return Config.getInstance().getPVPEnabled(this); - } - - public boolean getPVEEnabled() { - return Config.getInstance().getPVEEnabled(this); - } - - public boolean getDoubleDropsDisabled() { - return Config.getInstance().getDoubleDropsDisabled(this); - } - - public ToolType getTool() { - return tool; - } - - public double getXpModifier() { - return Config.getInstance().getForumulaMultiplier(this); - } - - public static SkillType getSkill(String skillName) { - if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) { - for (SkillType type : values()) { - if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(type.name()) + ".SkillName"))) { - return type; - } - } - } - - for (SkillType type : values()) { - if (type.name().equalsIgnoreCase(skillName)) { - return type; - } - } - - mcMMO.p.getLogger().warning("[Debug] Invalid mcMMO skill (" + skillName + ")"); - return null; - } - - // TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them - public boolean isChildSkill() { - switch (this) { - case SMELTING: - return true; - - default: - return false; - } - } -} +package com.gmail.nossr50.datatypes.skills; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.StringUtils; + +public enum SkillType { + ACROBATICS, + ARCHERY, + AXES(AbilityType.SKULL_SPLITTER, ToolType.AXE), + EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL), + FISHING, + HERBALISM(AbilityType.GREEN_TERRA, ToolType.HOE), + MINING(AbilityType.SUPER_BREAKER, ToolType.PICKAXE), + REPAIR, + SMELTING, + SWORDS(AbilityType.SERRATED_STRIKES, ToolType.SWORD), + TAMING, + UNARMED(AbilityType.BERSERK, ToolType.FISTS), + WOODCUTTING(AbilityType.TREE_FELLER, ToolType.AXE); + + private AbilityType ability; + private ToolType tool; + + private SkillType() { + this.ability = null; + this.tool = null; + } + + private SkillType(AbilityType ability, ToolType tool) { + this.ability = ability; + this.tool = tool; + } + + public AbilityType getAbility() { + return ability; + } + + /** + * Get the max level of this skill. + * + * @return the max level of this skill + */ + public int getMaxLevel() { + return Config.getInstance().getLevelCap(this); + } + + public boolean getPVPEnabled() { + return Config.getInstance().getPVPEnabled(this); + } + + public boolean getPVEEnabled() { + return Config.getInstance().getPVEEnabled(this); + } + + public boolean getDoubleDropsDisabled() { + return Config.getInstance().getDoubleDropsDisabled(this); + } + + public ToolType getTool() { + return tool; + } + + public double getXpModifier() { + return Config.getInstance().getForumulaMultiplier(this); + } + + public static SkillType getSkill(String skillName) { + if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) { + for (SkillType type : values()) { + if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(type.name()) + ".SkillName"))) { + return type; + } + } + } + + for (SkillType type : values()) { + if (type.name().equalsIgnoreCase(skillName)) { + return type; + } + } + + mcMMO.p.getLogger().warning("[Debug] Invalid mcMMO skill (" + skillName + ")"); + return null; + } + + // TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them + public boolean isChildSkill() { + switch (this) { + case SMELTING: + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/ToolType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java similarity index 65% rename from src/main/java/com/gmail/nossr50/skills/utilities/ToolType.java rename to src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java index 2940d0142..666acae32 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/ToolType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java @@ -1,63 +1,63 @@ -package com.gmail.nossr50.skills.utilities; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.ItemChecks; - -public enum ToolType { - AXE(LocaleLoader.getString("Axes.Ability.Lower"), LocaleLoader.getString("Axes.Ability.Ready")), - FISTS(LocaleLoader.getString("Unarmed.Ability.Lower"), LocaleLoader.getString("Unarmed.Ability.Ready")), - HOE(LocaleLoader.getString("Herbalism.Ability.Lower"), LocaleLoader.getString("Herbalism.Ability.Ready")), - PICKAXE(LocaleLoader.getString("Mining.Ability.Lower"), LocaleLoader.getString("Mining.Ability.Ready")), - SHOVEL(LocaleLoader.getString("Excavation.Ability.Lower"), LocaleLoader.getString("Excavation.Ability.Ready")), - SWORD(LocaleLoader.getString("Swords.Ability.Lower"), LocaleLoader.getString("Swords.Ability.Ready")); - - private String lowerTool; - private String raiseTool; - - private ToolType(String lowerTool, String raiseTool) { - this.lowerTool = lowerTool; - this.raiseTool = raiseTool; - } - - public String getLowerTool() { - return lowerTool; - } - - public String getRaiseTool() { - return raiseTool; - } - - /** - * Check to see if the item is of the appropriate type. - * - * @param is The item to check - * @return true if the item is the right type, false otherwise - */ - public boolean inHand(ItemStack is) { - switch (this) { - case AXE: - return ItemChecks.isAxe(is); - - case FISTS: - return is.getType() == Material.AIR; - - case HOE: - return ItemChecks.isHoe(is); - - case PICKAXE: - return ItemChecks.isPickaxe(is); - - case SHOVEL: - return ItemChecks.isShovel(is); - - case SWORD: - return ItemChecks.isSword(is); - - default: - return false; - } - } -} +package com.gmail.nossr50.datatypes.skills; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.ItemUtils; + +public enum ToolType { + AXE(LocaleLoader.getString("Axes.Ability.Lower"), LocaleLoader.getString("Axes.Ability.Ready")), + FISTS(LocaleLoader.getString("Unarmed.Ability.Lower"), LocaleLoader.getString("Unarmed.Ability.Ready")), + HOE(LocaleLoader.getString("Herbalism.Ability.Lower"), LocaleLoader.getString("Herbalism.Ability.Ready")), + PICKAXE(LocaleLoader.getString("Mining.Ability.Lower"), LocaleLoader.getString("Mining.Ability.Ready")), + SHOVEL(LocaleLoader.getString("Excavation.Ability.Lower"), LocaleLoader.getString("Excavation.Ability.Ready")), + SWORD(LocaleLoader.getString("Swords.Ability.Lower"), LocaleLoader.getString("Swords.Ability.Ready")); + + private String lowerTool; + private String raiseTool; + + private ToolType(String lowerTool, String raiseTool) { + this.lowerTool = lowerTool; + this.raiseTool = raiseTool; + } + + public String getLowerTool() { + return lowerTool; + } + + public String getRaiseTool() { + return raiseTool; + } + + /** + * Check to see if the item is of the appropriate type. + * + * @param itemStack The item to check + * @return true if the item is the right type, false otherwise + */ + public boolean inHand(ItemStack itemStack) { + switch (this) { + case AXE: + return ItemUtils.isAxe(itemStack); + + case FISTS: + return itemStack.getType() == Material.AIR; + + case HOE: + return ItemUtils.isHoe(itemStack); + + case PICKAXE: + return ItemUtils.isPickaxe(itemStack); + + case SHOVEL: + return ItemUtils.isShovel(itemStack); + + case SWORD: + return ItemUtils.isSword(itemStack); + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/spout/buttons/McmmoButton.java b/src/main/java/com/gmail/nossr50/datatypes/spout/buttons/McMMOButton.java similarity index 68% rename from src/main/java/com/gmail/nossr50/spout/buttons/McmmoButton.java rename to src/main/java/com/gmail/nossr50/datatypes/spout/buttons/McMMOButton.java index b9002cfbc..72748eb6f 100644 --- a/src/main/java/com/gmail/nossr50/spout/buttons/McmmoButton.java +++ b/src/main/java/com/gmail/nossr50/datatypes/spout/buttons/McMMOButton.java @@ -1,11 +1,11 @@ -package com.gmail.nossr50.spout.buttons; +package com.gmail.nossr50.datatypes.spout.buttons; import org.getspout.spoutapi.gui.GenericButton; -public class McmmoButton extends GenericButton { +public class McMMOButton extends GenericButton { private Slot slot; - public McmmoButton(String text, String toolTip) { + public McMMOButton(String text, String toolTip) { this.setText(text); this.setTooltip(toolTip); } diff --git a/src/main/java/com/gmail/nossr50/spout/huds/HudType.java b/src/main/java/com/gmail/nossr50/datatypes/spout/huds/HudType.java similarity index 78% rename from src/main/java/com/gmail/nossr50/spout/huds/HudType.java rename to src/main/java/com/gmail/nossr50/datatypes/spout/huds/HudType.java index d70f24f05..5095755b9 100644 --- a/src/main/java/com/gmail/nossr50/spout/huds/HudType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/spout/huds/HudType.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.spout.huds; +package com.gmail.nossr50.datatypes.spout.huds; public enum HudType { DISABLED, diff --git a/src/main/java/com/gmail/nossr50/spout/huds/SpoutHud.java b/src/main/java/com/gmail/nossr50/datatypes/spout/huds/McMMOHud.java similarity index 67% rename from src/main/java/com/gmail/nossr50/spout/huds/SpoutHud.java rename to src/main/java/com/gmail/nossr50/datatypes/spout/huds/McMMOHud.java index a69219985..b841b7f4f 100644 --- a/src/main/java/com/gmail/nossr50/spout/huds/SpoutHud.java +++ b/src/main/java/com/gmail/nossr50/datatypes/spout/huds/McMMOHud.java @@ -1,103 +1,109 @@ -package com.gmail.nossr50.spout.huds; - -import org.bukkit.entity.Player; -import org.getspout.spoutapi.SpoutManager; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.spout.SpoutConfig; -import com.gmail.nossr50.spout.popups.Menu; -import com.gmail.nossr50.spout.popups.XpBar; - -public class SpoutHud { - private Player player; - private PlayerProfile profile; - private SkillType lastGained; - private SkillType skillLock; - private boolean xpBarLocked; - private Menu menu; - private XpBar xpBar; - - public SpoutHud(McMMOPlayer mcMMOPlayer) { - this.player = mcMMOPlayer.getPlayer(); - this.profile = mcMMOPlayer.getProfile(); - - initializeXpBar(); - } - - /** - * Initialize the HUD. - */ - public void initializeXpBar() { - if (SpoutConfig.getInstance().getXPBarEnabled()) { - if (xpBar != null) { - xpBar.removeWidgets(); - } - - xpBar = new XpBar(SpoutManager.getPlayer(player), profile.getHudType()); - } - } - - /** - * Update the XP bar. - */ - public void updateXpBar() { - SkillType skillType = xpBarLocked ? skillLock : lastGained; - - if (skillType == null) { - return; - } - - xpBar.update(skillType, profile); - } - - public boolean isMenuOpened() { - return (menu != null) ? true : false; - } - - public void openMenu() { - menu = new Menu(SpoutManager.getPlayer(player), profile); - } - - public void onMenuClose() { - menu = null; - } - - public void removeWidgets() { - if (menu != null) { - menu.close(); - } - - SpoutManager.getPlayer(player).getMainScreen().removeWidgets(mcMMO.p); - } - - public SkillType getLastGained() { - return lastGained; - } - - public void setLastGained(SkillType type) { - this.lastGained = type; - } - - public boolean getXpBarLocked() { - return xpBarLocked; - } - - public void setXpBarLocked(boolean locked) { - this.xpBarLocked = locked; - } - - public void toggleXpBarLocked() { - xpBarLocked = !xpBarLocked; - } - - public SkillType getSkillLock() { - return skillLock; - } - - public void setSkillLock(SkillType type) { - this.skillLock = type; - } -} \ No newline at end of file +package com.gmail.nossr50.datatypes.spout.huds; + +import org.bukkit.entity.Player; +import org.getspout.spoutapi.SpoutManager; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.spout.SpoutConfig; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu; +import com.gmail.nossr50.datatypes.spout.popups.McMMOXpBar; + +public class McMMOHud { + private Player player; + private PlayerProfile profile; + + private SkillType lastGained; + private SkillType skillLock; + private boolean xpBarLocked; + + private McMMOMenu menu; + private McMMOXpBar xpBar; + + public McMMOHud(McMMOPlayer mcMMOPlayer) { + this.player = mcMMOPlayer.getPlayer(); + this.profile = mcMMOPlayer.getProfile(); + + initializeXpBar(); + } + + /** + * Initialize the HUD. + */ + public void initializeXpBar() { + if (SpoutConfig.getInstance().getXPBarEnabled()) { + if (xpBar != null) { + xpBar.removeWidgets(); + } + + xpBar = new McMMOXpBar(SpoutManager.getPlayer(player), profile.getHudType()); + } + } + + /** + * Update the XP bar. + */ + public void updateXpBar() { + SkillType skillType = xpBarLocked ? skillLock : lastGained; + + if (skillType == null) { + return; + } + + xpBar.update(skillType, profile); + } + + public boolean isMenuOpened() { + if (menu != null) { + return true; + } + + return false; + } + + public void openMenu() { + menu = new McMMOMenu(SpoutManager.getPlayer(player), profile); + } + + public void onMenuClose() { + menu = null; + } + + public void removeWidgets() { + if (menu != null) { + menu.close(); + } + + SpoutManager.getPlayer(player).getMainScreen().removeWidgets(mcMMO.p); + } + + public SkillType getLastGained() { + return lastGained; + } + + public void setLastGained(SkillType type) { + this.lastGained = type; + } + + public boolean getXpBarLocked() { + return xpBarLocked; + } + + public void setXpBarLocked(boolean locked) { + this.xpBarLocked = locked; + } + + public void toggleXpBarLocked() { + xpBarLocked = !xpBarLocked; + } + + public SkillType getSkillLock() { + return skillLock; + } + + public void setSkillLock(SkillType type) { + this.skillLock = type; + } +} diff --git a/src/main/java/com/gmail/nossr50/spout/popups/Menu.java b/src/main/java/com/gmail/nossr50/datatypes/spout/popups/McMMOMenu.java similarity index 71% rename from src/main/java/com/gmail/nossr50/spout/popups/Menu.java rename to src/main/java/com/gmail/nossr50/datatypes/spout/popups/McMMOMenu.java index 86f98784b..5fc4a7f23 100644 --- a/src/main/java/com/gmail/nossr50/spout/popups/Menu.java +++ b/src/main/java/com/gmail/nossr50/datatypes/spout/popups/McMMOMenu.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.spout.popups; +package com.gmail.nossr50.datatypes.spout.popups; import org.getspout.spoutapi.gui.GenericLabel; import org.getspout.spoutapi.gui.GenericPopup; @@ -6,23 +6,25 @@ import org.getspout.spoutapi.gui.InGameHUD; import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton; +import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton.Slot; +import com.gmail.nossr50.datatypes.spout.huds.HudType; +import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.spout.buttons.McmmoButton; -import com.gmail.nossr50.spout.buttons.McmmoButton.Slot; -import com.gmail.nossr50.spout.huds.HudType; -import com.gmail.nossr50.spout.huds.SpoutHud; -public class Menu extends GenericPopup { - private McmmoButton hudButton; - private McmmoButton escapeButton; - private GenericLabel titleLabel = new GenericLabel(); +public class McMMOMenu extends GenericPopup { + private McMMOButton hudButton; + private McMMOButton escapeButton; + + private GenericLabel titleLabel = new GenericLabel(); private GenericLabel escapeLabel = new GenericLabel(); + private static int centerX = 427 / 2; private static int centerY = 240 / 2; - public Menu(final SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) { - //240, 427 are the bottom right + public McMMOMenu(final SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) { + // 240, 427 are the bottom right titleLabel.setText(LocaleLoader.getString("Spout.Menu.Title")); titleLabel.setWidth(100); titleLabel.setHeight(100); @@ -35,7 +37,7 @@ public class Menu extends GenericPopup { escapeLabel.setX(titleLabel.getX() - 15); escapeLabel.setY(titleLabel.getY() + 10); - hudButton = new McmmoButton(LocaleLoader.getString("Spout.Menu.HudButton.1", playerProfile.getHudType().toString()), LocaleLoader.getString("Spout.Menu.HudButton.2")); + hudButton = new McMMOButton(LocaleLoader.getString("Spout.Menu.HudButton.1", playerProfile.getHudType().toString()), LocaleLoader.getString("Spout.Menu.HudButton.2")); hudButton.setWidth(120); hudButton.setHeight(20); hudButton.setX(centerX - (hudButton.getWidth() / 2)); @@ -43,18 +45,19 @@ public class Menu extends GenericPopup { hudButton.connect(new Slot() { @Override public void activate() { - HudType nextHudType = playerProfile.getHudType().getNext(); - SpoutHud spoutHud = playerProfile.getSpoutHud(); + HudType nextHudType = playerProfile.getHudType().getNext(); + McMMOHud spoutHud = playerProfile.getSpoutHud(); playerProfile.setHudType(nextHudType); spoutHud.initializeXpBar(); spoutHud.updateXpBar(); + hudButton.setText("HUD Type: " + nextHudType.toString()); hudButton.setDirty(true); } }); - escapeButton = new McmmoButton(LocaleLoader.getString("Spout.Menu.ExitButton"), null); + escapeButton = new McMMOButton(LocaleLoader.getString("Spout.Menu.ExitButton"), null); escapeButton.setWidth(60); escapeButton.setHeight(20); escapeButton.setX(centerX - (escapeButton.getWidth() / 2)); diff --git a/src/main/java/com/gmail/nossr50/spout/popups/XpBar.java b/src/main/java/com/gmail/nossr50/datatypes/spout/popups/McMMOXpBar.java similarity index 58% rename from src/main/java/com/gmail/nossr50/spout/popups/XpBar.java rename to src/main/java/com/gmail/nossr50/datatypes/spout/popups/McMMOXpBar.java index ec5708e89..c4526c7bf 100644 --- a/src/main/java/com/gmail/nossr50/spout/popups/XpBar.java +++ b/src/main/java/com/gmail/nossr50/datatypes/spout/popups/McMMOXpBar.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.spout.popups; +package com.gmail.nossr50.datatypes.spout.popups; import org.getspout.spoutapi.gui.Color; import org.getspout.spoutapi.gui.GenericGradient; @@ -9,57 +9,86 @@ import org.getspout.spoutapi.gui.Widget; import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.spout.SpoutConfig; -import com.gmail.nossr50.spout.huds.HudType; +import com.gmail.nossr50.config.spout.SpoutConfig; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.spout.huds.HudType; import com.gmail.nossr50.util.StringUtils; -public class XpBar { +public class McMMOXpBar { private SpoutPlayer spoutPlayer; private Widget xpBar; + private GenericGradient xpFill; private GenericGradient xpBackground; private GenericGradient xpIconBackground; private GenericGradient xpIconBorder; - private GenericTexture xpIcon; + private GenericTexture xpIcon; - public XpBar(SpoutPlayer spoutPlayer, HudType hudType) { + public McMMOXpBar(SpoutPlayer spoutPlayer, HudType hudType) { this.spoutPlayer = spoutPlayer; switch (hudType) { - case RETRO: - initializeXpBarRetro(); - break; + case RETRO: + initializeXpBarRetro(); + break; - case STANDARD: - initializeXpBarStandard(); - break; + case STANDARD: + initializeXpBarStandard(); + break; - case SMALL: - initializeXpBarSmall(); - break; + case SMALL: + initializeXpBarSmall(); + break; - case DISABLED: - break; + case DISABLED: + break; - default: - break; + default: + break; } spoutPlayer.getMainScreen().setDirty(true); } + public void removeWidgets() { + InGameHUD inGameHud = spoutPlayer.getMainScreen(); + + if (xpBar != null) { + inGameHud.removeWidget(xpBar); + } + + if (xpFill != null) { + inGameHud.removeWidget(xpFill); + } + + if (xpBackground != null) { + inGameHud.removeWidget(xpBackground); + } + + if (xpIconBackground != null) { + inGameHud.removeWidget(xpIconBackground); + } + + if (xpIconBorder != null) { + inGameHud.removeWidget(xpIconBorder); + } + + if (xpIcon != null) { + inGameHud.removeWidget(xpIcon); + } + } + /** * Initialize Retro XP bar. */ private void initializeXpBarRetro() { - Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f); - Color green = new Color(0f, 1f, 0f, 1f); + Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f); + Color green = new Color(0f, 1f, 0f, 1f); Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f); - xpBar = new GenericGradient(); - xpFill = new GenericGradient(); + xpBar = new GenericGradient(); + xpFill = new GenericGradient(); xpBackground = new GenericGradient(); xpBar.setWidth(128); @@ -93,8 +122,8 @@ public class XpBar { Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f); xpIconBackground = new GenericGradient(); - xpIconBorder = new GenericGradient(); - xpIcon = new GenericTexture(); + xpIconBorder = new GenericGradient(); + xpIcon = new GenericTexture(); xpIconBackground.setBottomColor(darkbg); xpIconBackground.setTopColor(darkbg); @@ -157,7 +186,7 @@ public class XpBar { private void initializeXpBarSmall() { xpBar = new GenericTexture(); - ((GenericTexture)xpBar).setUrl("xpbar_inc000.png"); + ((GenericTexture) xpBar).setUrl("xpbar_inc000.png"); xpBar.setX(427 / 2 - 64); xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition()); xpBar.setHeight(4); @@ -180,26 +209,26 @@ public class XpBar { /** * Update the XP bar. - * + * * @param skillType The skill last used * @param playerProfile The profile of the player whose XP bar should be updated */ public void update(SkillType skillType, PlayerProfile playerProfile) { switch (playerProfile.getHudType()) { - case RETRO: - updateXpBarRetro(skillType, playerProfile); - break; + case RETRO: + updateXpBarRetro(skillType, playerProfile); + break; - case STANDARD: - case SMALL: - updateXpBarStandard(skillType, playerProfile); - break; + case STANDARD: + case SMALL: + updateXpBarStandard(skillType, playerProfile); + break; - case DISABLED: - break; + case DISABLED: + break; - default: - break; + default: + break; } } @@ -236,60 +265,21 @@ public class XpBar { } private static Color getRetroColor(SkillType type) { - switch (type) { - case ACROBATICS: - return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f); - - case ARCHERY: - return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f); - - case AXES: - return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f); - - case EXCAVATION: - return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f); - - case HERBALISM: - return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f); - - case MINING: - return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f); - - case REPAIR: - return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f); - - case SWORDS: - return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f); - - case TAMING: - return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f); - - case UNARMED: - return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f); - - case WOODCUTTING: - return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f); - - case FISHING: - return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f); - - default: - return new Color(0.3f, 0.3f, 0.75f, 1f); - } + return new Color((float) SpoutConfig.getInstance().getRetroHUDRed(type), (float) SpoutConfig.getInstance().getRetroHUDGreen(type), (float) SpoutConfig.getInstance().getRetroHUDBlue(type), 1f); } private static String getUrlBar(Integer number) { char[] num = number.toString().toCharArray(); switch (num.length) { - case 1: - return "xpbar_inc00" + number + ".png"; + case 1: + return "xpbar_inc00" + number + ".png"; - case 2: - return "xpbar_inc0" + number + ".png"; + case 2: + return "xpbar_inc0" + number + ".png"; - default: - return "xpbar_inc" + number + ".png"; + default: + return "xpbar_inc" + number + ".png"; } } @@ -298,29 +288,18 @@ public class XpBar { double inc; switch (hudType) { - case RETRO: - inc = 0.0079365079365079; - break; + case RETRO: + inc = 0.0079365079365079; + break; - case STANDARD: - inc = 0.0039370078740157; - break; + case STANDARD: + inc = 0.0039370078740157; + break; - default: - return 1; + default: + return 1; } return (int) (percentage / inc); } - - public void removeWidgets() { - InGameHUD inGameHud = spoutPlayer.getMainScreen(); - - if (xpBar != null) inGameHud.removeWidget(xpBar); - if (xpFill != null) inGameHud.removeWidget(xpFill); - if (xpBackground != null) inGameHud.removeWidget(xpBackground); - if (xpIconBackground != null) inGameHud.removeWidget(xpIconBackground); - if (xpIconBorder != null) inGameHud.removeWidget(xpIconBorder); - if (xpIcon != null) inGameHud.removeWidget(xpIcon); - } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java index 7483b0473..efe495aaa 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java +++ b/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java @@ -13,7 +13,7 @@ public class ExcavationTreasure extends Treasure { // 01000000 - soulsand 64 private byte dropsFrom = 0x0; - public ExcavationTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel) { + public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { super(drop, xp, dropChance, dropLevel); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/HylianTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/HylianTreasure.java index 8c0351acb..d43c944c9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/HylianTreasure.java +++ b/src/main/java/com/gmail/nossr50/datatypes/treasure/HylianTreasure.java @@ -1,76 +1,75 @@ -package com.gmail.nossr50.datatypes.treasure; - -import org.bukkit.inventory.ItemStack; - -public class HylianTreasure extends Treasure { - // bushes | flowers | pots - // 00000001 - bushes 1 - // 00000010 - flowers 2 - // 00000100 - pots 4 - private byte dropsFrom = 0x0; - - public HylianTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel) { - super(drop, xp, dropChance, dropLevel); - } - - // Raw getters and setters - public byte getDropsFrom() { - return dropsFrom; - } - - public void setDropsFrom(byte dropsFrom) { - this.dropsFrom = dropsFrom; - } - - // Getters - public boolean getDropsFromBushes() { - return getDropFromMask(1); - } - - public boolean getDropsFromFlowers() { - return getDropFromMask(2); - } - - public boolean getDropsFromPots() { - return getDropFromMask(4); - } - - private boolean getDropFromMask(int mask) { - return ((dropsFrom & mask) > 0) ? true : false; - } - - // Setters - public void setDropsFromBushes() { - setDropFromMask(1); - } - - public void setDropsFromFlowers() { - setDropFromMask(2); - } - - public void setDropsFromPots() { - setDropFromMask(4); - } - - private void setDropFromMask(int mask) { - dropsFrom |= mask; - } - - // Un-setters - public void unsetDropsFromBushes() { - unsetDropFromMask(1); - } - - public void unsetDropsFromFlowers() { - unsetDropFromMask(2); - } - - public void unsetDropsFromPots() { - unsetDropFromMask(4); - } - - private void unsetDropFromMask(int mask) { - dropsFrom &= ~mask; - } - -} +package com.gmail.nossr50.datatypes.treasure; + +import org.bukkit.inventory.ItemStack; + +public class HylianTreasure extends Treasure { + // bushes | flowers | pots + // 00000001 - bushes 1 + // 00000010 - flowers 2 + // 00000100 - pots 4 + private byte dropsFrom = 0x0; + + public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { + super(drop, xp, dropChance, dropLevel); + } + + // Raw getters and setters + public byte getDropsFrom() { + return dropsFrom; + } + + public void setDropsFrom(byte dropsFrom) { + this.dropsFrom = dropsFrom; + } + + // Getters + public boolean getDropsFromBushes() { + return getDropFromMask(1); + } + + public boolean getDropsFromFlowers() { + return getDropFromMask(2); + } + + public boolean getDropsFromPots() { + return getDropFromMask(4); + } + + private boolean getDropFromMask(int mask) { + return ((dropsFrom & mask) > 0) ? true : false; + } + + // Setters + public void setDropsFromBushes() { + setDropFromMask(1); + } + + public void setDropsFromFlowers() { + setDropFromMask(2); + } + + public void setDropsFromPots() { + setDropFromMask(4); + } + + private void setDropFromMask(int mask) { + dropsFrom |= mask; + } + + // Un-setters + public void unsetDropsFromBushes() { + unsetDropFromMask(1); + } + + public void unsetDropsFromFlowers() { + unsetDropFromMask(2); + } + + public void unsetDropsFromPots() { + unsetDropFromMask(4); + } + + private void unsetDropFromMask(int mask) { + dropsFrom &= ~mask; + } +} diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java index 29aedbe90..013849de2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java +++ b/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java @@ -8,7 +8,7 @@ public abstract class Treasure { private int dropLevel; private ItemStack drop; - public Treasure(ItemStack drop, int xp, Double dropChance, int dropLevel) { + public Treasure(ItemStack drop, int xp, double dropChance, int dropLevel) { this.drop = drop; this.xp = xp; this.dropChance = dropChance; diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java index d0a94f22f..9c4f3ae68 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java @@ -1,94 +1,94 @@ -package com.gmail.nossr50.events.chat; - -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.plugin.Plugin; - -public abstract class McMMOChatEvent extends Event implements Cancellable { - private boolean cancelled; - private Plugin plugin; - private String sender; - private String displayName; - private String message; - - protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) { - this.plugin = plugin; - this.sender = sender; - this.displayName = displayName; - this.message = message; - } - - protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { - super(isAsync); - this.plugin = plugin; - this.sender = sender; - this.displayName = displayName; - this.message = message; - } - - /** - * @return The plugin responsible for this event, note this can be null - */ - public Plugin getPlugin() { - return plugin; - } - - /** - * @return String name of the player who sent the chat, or "Console" - */ - public String getSender() { - return sender; - } - - /** - * @return String display name of the player who sent the chat, or "Console" - */ - public String getDisplayName() { - return displayName; - } - - /** - * @return String message that will be sent - */ - public String getMessage() { - return message; - } - - /** - * @param displayName String display name of the player who sent the chat - */ - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - /** - * @param message String message to be sent in chat - */ - public void setMessage(String message) { - this.message = message; - } - - /** Rest of file is required boilerplate for custom events **/ - private static final HandlerList handlers = new HandlerList(); - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - /** Following are required for Cancellable **/ - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } -} +package com.gmail.nossr50.events.chat; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.plugin.Plugin; + +public abstract class McMMOChatEvent extends Event implements Cancellable { + private boolean cancelled; + private Plugin plugin; + private String sender; + private String displayName; + private String message; + + protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) { + this.plugin = plugin; + this.sender = sender; + this.displayName = displayName; + this.message = message; + } + + protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { + super(isAsync); + this.plugin = plugin; + this.sender = sender; + this.displayName = displayName; + this.message = message; + } + + /** + * @return The plugin responsible for this event, note this can be null + */ + public Plugin getPlugin() { + return plugin; + } + + /** + * @return String name of the player who sent the chat, or "Console" + */ + public String getSender() { + return sender; + } + + /** + * @return String display name of the player who sent the chat, or "Console" + */ + public String getDisplayName() { + return displayName; + } + + /** + * @return String message that will be sent + */ + public String getMessage() { + return message; + } + + /** + * @param displayName String display name of the player who sent the chat + */ + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * @param message String message to be sent in chat + */ + public void setMessage(String message) { + this.message = message; + } + + /** Following are required for Cancellable **/ + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + /** Rest of file is required boilerplate for custom events **/ + private static final HandlerList handlers = new HandlerList(); + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerExperienceEvent.java b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerExperienceEvent.java index 28ecb575d..8868db109 100644 --- a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerExperienceEvent.java +++ b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerExperienceEvent.java @@ -1,61 +1,61 @@ -package com.gmail.nossr50.events.experience; - -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerEvent; - -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Users; - -/** - * Generic event for mcMMO experience events. - */ -public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements Cancellable { - private boolean cancelled; - protected SkillType skill; - protected int skillLevel; - - protected McMMOPlayerExperienceEvent(Player player, SkillType skill) { - super(player); - this.skill = skill; - this.skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill); - } - - /** - * @return The skill involved in this event - */ - public SkillType getSkill() { - return skill; - } - - /** - * @return The skill level of the skill involved in this event - */ - public int getSkillLevel() { - return skillLevel; - } - - /** Rest of file is required boilerplate for custom events **/ - private static final HandlerList handlers = new HandlerList(); - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - /** Following are required for Cancellable **/ - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } -} +package com.gmail.nossr50.events.experience; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.util.player.UserManager; + +/** + * Generic event for mcMMO experience events. + */ +public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements Cancellable { + private boolean cancelled; + protected SkillType skill; + protected int skillLevel; + + protected McMMOPlayerExperienceEvent(Player player, SkillType skill) { + super(player); + this.skill = skill; + this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill); + } + + /** + * @return The skill involved in this event + */ + public SkillType getSkill() { + return skill; + } + + /** + * @return The skill level of the skill involved in this event + */ + public int getSkillLevel() { + return skillLevel; + } + + /** Following are required for Cancellable **/ + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + /** Rest of file is required boilerplate for custom events **/ + private static final HandlerList handlers = new HandlerList(); + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelUpEvent.java b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelUpEvent.java index b46307bac..3179ff2ab 100644 --- a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelUpEvent.java +++ b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelUpEvent.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.events.experience; import org.bukkit.entity.Player; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.datatypes.skills.SkillType; /** * Called when a user levels up in a skill diff --git a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerXpGainEvent.java b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerXpGainEvent.java index 3278d3772..31d982b8a 100644 --- a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerXpGainEvent.java +++ b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerXpGainEvent.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.events.experience; import org.bukkit.entity.Player; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.datatypes.skills.SkillType; /** * Called when a player gains XP in a skill diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeBlockBreakEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeBlockBreakEvent.java index 14d7f09b3..7a2f7ab08 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeBlockBreakEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeBlockBreakEvent.java @@ -11,4 +11,4 @@ public class FakeBlockBreakEvent extends BlockBreakEvent { public FakeBlockBreakEvent(Block theBlock, Player player) { super(theBlock, player); } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeBlockDamageEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeBlockDamageEvent.java index 82b2f947d..31dbb7a53 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeBlockDamageEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeBlockDamageEvent.java @@ -12,4 +12,4 @@ public class FakeBlockDamageEvent extends BlockDamageEvent { public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) { super(player, block, itemInHand, instaBreak); } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakePlayerAnimationEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakePlayerAnimationEvent.java index d338fbb6d..c6e2cbaab 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakePlayerAnimationEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakePlayerAnimationEvent.java @@ -1,13 +1,13 @@ -package com.gmail.nossr50.events.fake; - -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerAnimationEvent; - -/** - * Called when handling extra drops to avoid issues with NoCheat. - */ -public class FakePlayerAnimationEvent extends PlayerAnimationEvent { - public FakePlayerAnimationEvent(Player player) { - super(player); - } -} +package com.gmail.nossr50.events.fake; + +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerAnimationEvent; + +/** + * Called when handling extra drops to avoid issues with NoCheat. + */ +public class FakePlayerAnimationEvent extends PlayerAnimationEvent { + public FakePlayerAnimationEvent(Player player) { + super(player); + } +} diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java index a5af26ba0..f2d3f537e 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java @@ -1,103 +1,103 @@ -package com.gmail.nossr50.events.party; - -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerEvent; - -/** - * Called when a player attempts to join, leave, or change parties. - */ -public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable { - private String oldParty; - private String newParty; - private EventReason reason; - private boolean cancelled; - - public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) { - super(player); - - if (newParty != null) { - newParty = newParty.replace(":", "."); - } - - this.oldParty = oldParty; - this.newParty = newParty; - this.reason = reason; - this.cancelled = false; - } - - /** - * @return The party being left, or null if the player was not in a party - */ - public String getOldParty() { - return oldParty; - } - - /** - * @return The party being joined, or null if the player is not joining a new party - */ - public String getNewParty() { - return newParty; - } - - /** - * @return The reason for the event being fired - */ - public EventReason getReason() { - return reason; - } - - /** - * A list of reasons why the event may have been fired - */ - public enum EventReason{ - /** - * Joined a party for the first time. - */ - JOINED_PARTY, - - /** - * Left a party and did not join a new one. - */ - LEFT_PARTY, - - /** - * Was kicked from a party. - */ - KICKED_FROM_PARTY, - - /** - * Left one party to join another. - */ - CHANGED_PARTIES, - - /** - * Any reason that doesn't fit elsewhere. - */ - CUSTOM; - } - - /** Rest of file is required boilerplate for custom events **/ - private static final HandlerList handlers = new HandlerList(); - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - /** Following are required for Cancellable **/ - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } -} +package com.gmail.nossr50.events.party; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +/** + * Called when a player attempts to join, leave, or change parties. + */ +public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable { + private String oldParty; + private String newParty; + private EventReason reason; + private boolean cancelled; + + public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) { + super(player); + + if (newParty != null) { + newParty = newParty.replace(":", "."); + } + + this.oldParty = oldParty; + this.newParty = newParty; + this.reason = reason; + this.cancelled = false; + } + + /** + * @return The party being left, or null if the player was not in a party + */ + public String getOldParty() { + return oldParty; + } + + /** + * @return The party being joined, or null if the player is not joining a new party + */ + public String getNewParty() { + return newParty; + } + + /** + * @return The reason for the event being fired + */ + public EventReason getReason() { + return reason; + } + + /** + * A list of reasons why the event may have been fired + */ + public enum EventReason { + /** + * Joined a party for the first time. + */ + JOINED_PARTY, + + /** + * Left a party and did not join a new one. + */ + LEFT_PARTY, + + /** + * Was kicked from a party. + */ + KICKED_FROM_PARTY, + + /** + * Left one party to join another. + */ + CHANGED_PARTIES, + + /** + * Any reason that doesn't fit elsewhere. + */ + CUSTOM; + } + + /** Following are required for Cancellable **/ + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + /** Rest of file is required boilerplate for custom events **/ + private static final HandlerList handlers = new HandlerList(); + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java index 54254ee4d..9bc1fe1ee 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java @@ -1,45 +1,45 @@ -package com.gmail.nossr50.events.party; - -import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerTeleportEvent; - -/** - * Called just before a player teleports using the /ptp command. - */ -public class McMMOPartyTeleportEvent extends PlayerTeleportEvent { - private String party; - private Player target; - - public McMMOPartyTeleportEvent(Player player, Player target, String party) { - super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND); - this.party = party; - this.target = target; - } - - /** - * @return The party the teleporting player is in - */ - public String getParty() { - return party; - } - - /** - * @return The player being teleported to - */ - public Player getTarget() { - return target; - } - - /** Rest of file is required boilerplate for custom events **/ - private static final HandlerList handlers = new HandlerList(); - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } -} +package com.gmail.nossr50.events.party; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerTeleportEvent; + +/** + * Called just before a player teleports using the /ptp command. + */ +public class McMMOPartyTeleportEvent extends PlayerTeleportEvent { + private String party; + private Player target; + + public McMMOPartyTeleportEvent(Player player, Player target, String party) { + super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND); + this.party = party; + this.target = target; + } + + /** + * @return The party the teleporting player is in + */ + public String getParty() { + return party; + } + + /** + * @return The player being teleported to + */ + public Player getTarget() { + return target; + } + + /** Rest of file is required boilerplate for custom events **/ + private static final HandlerList handlers = new HandlerList(); + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerSkillEvent.java b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerSkillEvent.java index 925cbe98a..743d4b46a 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerSkillEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerSkillEvent.java @@ -1,48 +1,48 @@ -package com.gmail.nossr50.events.skills; - -import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerEvent; - -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Users; - -/** - * Generic event for mcMMO skill handling. - */ -public abstract class McMMOPlayerSkillEvent extends PlayerEvent { - protected SkillType skill; - protected int skillLevel; - - protected McMMOPlayerSkillEvent(Player player, SkillType skill) { - super(player); - this.skill = skill; - this.skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill); - } - - /** - * @return The skill involved in this event - */ - public SkillType getSkill() { - return skill; - } - - /** - * @return The level of the skill involved in this event - */ - public int getSkillLevel() { - return skillLevel; - } - - /** Rest of file is required boilerplate for custom events **/ - private static final HandlerList handlers = new HandlerList(); - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } -} +package com.gmail.nossr50.events.skills; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.util.player.UserManager; + +/** + * Generic event for mcMMO skill handling. + */ +public abstract class McMMOPlayerSkillEvent extends PlayerEvent { + protected SkillType skill; + protected int skillLevel; + + protected McMMOPlayerSkillEvent(Player player, SkillType skill) { + super(player); + this.skill = skill; + this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill); + } + + /** + * @return The skill involved in this event + */ + public SkillType getSkill() { + return skill; + } + + /** + * @return The level of the skill involved in this event + */ + public int getSkillLevel() { + return skillLevel; + } + + /** Rest of file is required boilerplate for custom events **/ + private static final HandlerList handlers = new HandlerList(); + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerRepairCheckEvent.java b/src/main/java/com/gmail/nossr50/events/skills/repair/McMMOPlayerRepairCheckEvent.java similarity index 87% rename from src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerRepairCheckEvent.java rename to src/main/java/com/gmail/nossr50/events/skills/repair/McMMOPlayerRepairCheckEvent.java index d6eb70be7..e2f2eb009 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerRepairCheckEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/repair/McMMOPlayerRepairCheckEvent.java @@ -1,57 +1,58 @@ -package com.gmail.nossr50.events.skills; - -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.skills.utilities.SkillType; - -/** - * Called just before a player repairs an object with mcMMO. - */ -public class McMMOPlayerRepairCheckEvent extends McMMOPlayerSkillEvent implements Cancellable{ - private short repairAmount; - private ItemStack repairMaterial; - private ItemStack repairedObject; - private boolean cancelled; - - public McMMOPlayerRepairCheckEvent(Player player, short repairAmount, ItemStack repairMaterial, ItemStack repairedObject) { - super(player, SkillType.REPAIR); - this.repairAmount = repairAmount; - this.repairMaterial = repairMaterial; - this.repairedObject = repairedObject; - this.cancelled = false; - } - - /** - * @return The amount this item will be repaired. - */ - public short getRepairAmount() { - return repairAmount; - } - - /** - * @return The material used to repair this item - */ - public ItemStack getRepairMaterial() { - return repairMaterial; - } - - /** - * @return The item that was repaired - */ - public ItemStack getRepairedObject() { - return repairedObject; - } - - /** Following are required for Cancellable **/ - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } -} +package com.gmail.nossr50.events.skills.repair; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent; + +/** + * Called just before a player repairs an object with mcMMO. + */ +public class McMMOPlayerRepairCheckEvent extends McMMOPlayerSkillEvent implements Cancellable { + private short repairAmount; + private ItemStack repairMaterial; + private ItemStack repairedObject; + private boolean cancelled; + + public McMMOPlayerRepairCheckEvent(Player player, short repairAmount, ItemStack repairMaterial, ItemStack repairedObject) { + super(player, SkillType.REPAIR); + this.repairAmount = repairAmount; + this.repairMaterial = repairMaterial; + this.repairedObject = repairedObject; + this.cancelled = false; + } + + /** + * @return The amount this item will be repaired. + */ + public short getRepairAmount() { + return repairAmount; + } + + /** + * @return The material used to repair this item + */ + public ItemStack getRepairMaterial() { + return repairMaterial; + } + + /** + * @return The item that was repaired + */ + public ItemStack getRepairedObject() { + return repairedObject; + } + + /** Following are required for Cancellable **/ + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } +} diff --git a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerDisarmEvent.java b/src/main/java/com/gmail/nossr50/events/skills/unarmed/McMMOPlayerDisarmEvent.java similarity index 80% rename from src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerDisarmEvent.java rename to src/main/java/com/gmail/nossr50/events/skills/unarmed/McMMOPlayerDisarmEvent.java index dcaccbb63..defc5edde 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerDisarmEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/unarmed/McMMOPlayerDisarmEvent.java @@ -1,9 +1,10 @@ -package com.gmail.nossr50.events.skills; +package com.gmail.nossr50.events.skills.unarmed; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent; public class McMMOPlayerDisarmEvent extends McMMOPlayerSkillEvent implements Cancellable { private boolean cancelled; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index bc62854f8..940ccc24e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -22,12 +22,15 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.HiddenConfig; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; -import com.gmail.nossr50.runnables.StickyPistonTracker; +import com.gmail.nossr50.runnables.StickyPistonTrackerTask; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; @@ -35,16 +38,13 @@ import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.unarmed.Unarmed; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.skills.utilities.ToolType; import com.gmail.nossr50.skills.woodcutting.Woodcutting; -import com.gmail.nossr50.util.BlockChecks; -import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.BlockUtils; +import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; public class BlockListener implements Listener { private final mcMMO plugin; @@ -90,8 +90,8 @@ public class BlockListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onBlockPistonRetract(BlockPistonRetractEvent event) { if (event.isSticky()) { - //Needed only because under some circumstances Minecraft doesn't move the block - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTracker(event), 2); + // Needed only because under some circumstances Minecraft doesn't move the block + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTrackerTask(event), 2); } } @@ -111,7 +111,7 @@ public class BlockListener implements Listener { BlockState blockState = event.getBlock().getState(); /* Check if the blocks placed should be monitored so they do not give out XP in the future */ - if (BlockChecks.shouldBeWatched(blockState)) { + if (BlockUtils.shouldBeWatched(blockState)) { mcMMO.placeStore.setTrue(blockState); } @@ -144,19 +144,19 @@ public class BlockListener implements Listener { return; } - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); BlockState blockState = event.getBlock().getState(); ItemStack heldItem = player.getItemInHand(); /* HERBALISM */ - if (BlockChecks.affectedByGreenTerra(blockState)) { + if (BlockUtils.affectedByGreenTerra(blockState)) { HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName()); /* Green Terra */ if (herbalismManager.canActivateAbility()) { - SkillTools.abilityCheck(player, SkillType.HERBALISM); + SkillUtils.abilityCheck(player, SkillType.HERBALISM); } /* @@ -165,10 +165,10 @@ public class BlockListener implements Listener { */ if (Permissions.skillEnabled(player, SkillType.HERBALISM)) { - //Double drops + // Double drops herbalismManager.herbalismBlockCheck(blockState); - //Triple drops + // Triple drops if (herbalismManager.canGreenTerraPlant()) { herbalismManager.herbalismBlockCheck(blockState); } @@ -176,7 +176,7 @@ public class BlockListener implements Listener { } /* MINING */ - else if (BlockChecks.affectedBySuperBreaker(blockState) && ItemChecks.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) { + else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) { MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); miningManager.miningBlockCheck(blockState); @@ -186,13 +186,13 @@ public class BlockListener implements Listener { } /* WOOD CUTTING */ - else if (BlockChecks.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) { - if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemChecks.isAxe(heldItem)) { + else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) { + if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) { Woodcutting.beginTreeFeller(blockState, player); } else { if (Config.getInstance().getWoodcuttingRequiresTool()) { - if (ItemChecks.isAxe(heldItem)) { + if (ItemUtils.isAxe(heldItem)) { Woodcutting.beginWoodcutting(player, blockState); } } @@ -203,7 +203,7 @@ public class BlockListener implements Listener { } /* EXCAVATION */ - else if (BlockChecks.affectedByGigaDrillBreaker(blockState) && ItemChecks.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) { + else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) { ExcavationManager excavationManager = SkillManagerStore.getInstance().getExcavationManager(player.getName()); excavationManager.excavationBlockCheck(blockState); @@ -213,7 +213,7 @@ public class BlockListener implements Listener { } /* Remove metadata from placed watched blocks */ - if (BlockChecks.shouldBeWatched(blockState) && mcMMO.placeStore.isTrue(blockState)) { + if (BlockUtils.shouldBeWatched(blockState) && mcMMO.placeStore.isTrue(blockState)) { mcMMO.placeStore.setFalse(blockState); } } @@ -269,7 +269,7 @@ public class BlockListener implements Listener { return; } - PlayerProfile profile = Users.getPlayer(player).getProfile(); + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); BlockState blockState = event.getBlock().getState(); /* @@ -277,34 +277,34 @@ public class BlockListener implements Listener { * * We check permissions here before processing activation. */ - if (BlockChecks.canActivateAbilities(blockState)) { + if (BlockUtils.canActivateAbilities(blockState)) { ItemStack heldItem = player.getItemInHand(); if (HiddenConfig.getInstance().useEnchantmentBuffs()) { - if ((ItemChecks.isPickaxe(heldItem) && !profile.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemChecks.isShovel(heldItem) && !profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) { - SkillTools.removeAbilityBuff(heldItem); + if ((ItemUtils.isPickaxe(heldItem) && !profile.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) { + SkillUtils.removeAbilityBuff(heldItem); } } else { - if ((profile.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockChecks.affectedBySuperBreaker(blockState)) || (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockChecks.affectedByGigaDrillBreaker(blockState))) { - SkillTools.handleAbilitySpeedDecrease(player); + if ((profile.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) { + SkillUtils.handleAbilitySpeedDecrease(player); } } - if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.affectedByGreenTerra(blockState) || BlockChecks.canMakeMossy(blockState)) && Permissions.greenTerra(player)) { - SkillTools.abilityCheck(player, SkillType.HERBALISM); + if (profile.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) { + SkillUtils.abilityCheck(player, SkillType.HERBALISM); } - else if (profile.getToolPreparationMode(ToolType.AXE) && ItemChecks.isAxe(heldItem) && BlockChecks.isLog(blockState) && Permissions.treeFeller(player)) { - SkillTools.abilityCheck(player, SkillType.WOODCUTTING); + else if (profile.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) { + SkillUtils.abilityCheck(player, SkillType.WOODCUTTING); } - else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemChecks.isPickaxe(heldItem) && BlockChecks.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) { - SkillTools.abilityCheck(player, SkillType.MINING); + else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) { + SkillUtils.abilityCheck(player, SkillType.MINING); } - else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) { - SkillTools.abilityCheck(player, SkillType.EXCAVATION); + else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) { + SkillUtils.abilityCheck(player, SkillType.EXCAVATION); } - else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockChecks.affectedByBlockCracker(blockState) && Permissions.berserk(player))) { - SkillTools.abilityCheck(player, SkillType.UNARMED); + else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) { + SkillUtils.abilityCheck(player, SkillType.UNARMED); } } @@ -313,7 +313,7 @@ public class BlockListener implements Listener { * * We don't need to check permissions here because they've already been checked for the ability to even activate. */ - if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockChecks.isLog(blockState)) { + if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState)) { player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH); } } @@ -336,7 +336,7 @@ public class BlockListener implements Listener { } String playerName = player.getName(); - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); ItemStack heldItem = player.getItemInHand(); Block block = event.getBlock(); @@ -353,7 +353,7 @@ public class BlockListener implements Listener { } } else if (profile.getAbilityMode(AbilityType.BERSERK)) { - if (SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) { + if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) { if (heldItem.getType() == Material.AIR) { plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player)); @@ -362,16 +362,16 @@ public class BlockListener implements Listener { } } // Another perm check for the cracked blocks activation - else if (BlockChecks.affectedByBlockCracker(blockState) && Permissions.blockCracker(player)) { + else if (BlockUtils.affectedByBlockCracker(blockState) && Permissions.blockCracker(player)) { if (Unarmed.blockCracker(player, blockState)) { blockState.update(); } } } - else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(blockState)) { - if (SkillTools.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) { + else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockUtils.isLeaves(blockState)) { + if (SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) { if (Config.getInstance().getWoodcuttingRequiresTool()) { - if (ItemChecks.isAxe(heldItem)) { + if (ItemUtils.isAxe(heldItem)) { event.setInstaBreak(true); Woodcutting.beginLeafBlower(player, blockState); } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 991cb6bb0..5d486368e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -27,22 +27,22 @@ import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.mining.MiningManager; -import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.taming.Taming; -import com.gmail.nossr50.skills.utilities.CombatTools; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.CombatUtils; public class EntityListener implements Listener { private final mcMMO plugin; @@ -80,8 +80,9 @@ public class EntityListener implements Listener { */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - if (event instanceof FakeEntityDamageByEntityEvent || event.getDamage() <= 0) + if (event instanceof FakeEntityDamageByEntityEvent || event.getDamage() <= 0) { return; + } Entity defender = event.getEntity(); @@ -129,8 +130,8 @@ public class EntityListener implements Listener { if (defender instanceof LivingEntity) { LivingEntity livingDefender = (LivingEntity) defender; - if (!CombatTools.isInvincible(livingDefender, event.getDamage())) { - CombatTools.combatChecks(event, attacker, livingDefender); + if (!CombatUtils.isInvincible(livingDefender, event.getDamage())) { + CombatUtils.combatChecks(event, attacker, livingDefender); } } } @@ -155,7 +156,7 @@ public class EntityListener implements Listener { DamageCause cause = event.getCause(); LivingEntity livingEntity = (LivingEntity) entity; - if (CombatTools.isInvincible(livingEntity, event.getDamage())) { + if (CombatUtils.isInvincible(livingEntity, event.getDamage())) { return; } @@ -167,7 +168,7 @@ public class EntityListener implements Listener { return; } - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); /* Check for invincibility */ @@ -177,32 +178,32 @@ public class EntityListener implements Listener { } switch (cause) { - case FALL: - if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canRoll()) { - event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).rollCheck(event.getDamage())); + case FALL: + if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canRoll()) { + event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).rollCheck(event.getDamage())); - if (event.getDamage() == 0) { - event.setCancelled(true); - return; + if (event.getDamage() == 0) { + event.setCancelled(true); + return; + } } - } - break; + break; - case BLOCK_EXPLOSION: - MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); + case BLOCK_EXPLOSION: + MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); - if (miningManager.canUseDemolitionsExpertise()) { - event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage())); + if (miningManager.canUseDemolitionsExpertise()) { + event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage())); - if (event.getDamage() == 0) { - event.setCancelled(true); - return; + if (event.getDamage() == 0) { + event.setCancelled(true); + return; + } } - } - break; + break; - default: - break; + default: + break; } if (event.getDamage() >= 1) { @@ -218,59 +219,59 @@ public class EntityListener implements Listener { Wolf wolf = (Wolf) pet; switch (cause) { - case CONTACT: - case FIRE: - case LAVA: - if (Taming.canUseEnvironmentallyAware(player)) { - Taming.processEnvironmentallyAware(player, wolf, event.getDamage()); - } - return; + case CONTACT: + case FIRE: + case LAVA: + if (Taming.canUseEnvironmentallyAware(player)) { + Taming.processEnvironmentallyAware(player, wolf, event.getDamage()); + } + return; - case FALL: - if (Taming.canUseEnvironmentallyAware(player)) { - event.setCancelled(true); - } - return; - - case ENTITY_ATTACK: - case PROJECTILE: - if (Taming.canUseThickFur(player)) { - event.setDamage(Taming.processThickFur(wolf, event.getDamage())); - - if (event.getDamage() == 0) { + case FALL: + if (Taming.canUseEnvironmentallyAware(player)) { event.setCancelled(true); } - } - return; + return; - case FIRE_TICK: - if (Taming.canUseThickFur(player)) { - Taming.processThickFurFire(wolf); - } - return; + case ENTITY_ATTACK: + case PROJECTILE: + if (Taming.canUseThickFur(player)) { + event.setDamage(Taming.processThickFur(wolf, event.getDamage())); - case MAGIC: - case POISON: - case WITHER: - if (Taming.canUseHolyHound(player)) { - Taming.processHolyHound(wolf, event.getDamage()); - } - return; - - case BLOCK_EXPLOSION: - case ENTITY_EXPLOSION: - case LIGHTNING: - if (Taming.canUseShockProof(player)) { - event.setDamage(Taming.processShockProof(wolf, event.getDamage())); - - if (event.getDamage() == 0) { - event.setCancelled(true); + if (event.getDamage() == 0) { + event.setCancelled(true); + } } - } - return; + return; - default: - return; + case FIRE_TICK: + if (Taming.canUseThickFur(player)) { + Taming.processThickFurFire(wolf); + } + return; + + case MAGIC: + case POISON: + case WITHER: + if (Taming.canUseHolyHound(player)) { + Taming.processHolyHound(wolf, event.getDamage()); + } + return; + + case BLOCK_EXPLOSION: + case ENTITY_EXPLOSION: + case LIGHTNING: + if (Taming.canUseShockProof(player)) { + event.setDamage(Taming.processShockProof(wolf, event.getDamage())); + + if (event.getDamage() == 0) { + event.setCancelled(true); + } + } + return; + + default: + return; } } } @@ -281,7 +282,7 @@ public class EntityListener implements Listener { * * @param event The event to watch */ - @EventHandler (priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onEntityDeath(EntityDeathEvent event) { LivingEntity entity = event.getEntity(); @@ -290,7 +291,7 @@ public class EntityListener implements Listener { } entity.setFireTicks(0); - BleedTimer.remove(entity); + BleedTimerTask.remove(entity); Archery.arrowRetrievalCheck(entity); } @@ -299,7 +300,7 @@ public class EntityListener implements Listener { * * @param event The event to watch */ - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { if (Misc.isSpawnerXPEnabled || event.getEntity() == null) { return; @@ -317,7 +318,7 @@ public class EntityListener implements Listener { * * @param event The event to modify */ - @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onExplosionPrime(ExplosionPrimeEvent event) { Entity entity = event.getEntity(); @@ -339,7 +340,7 @@ public class EntityListener implements Listener { * * @param event The event to modify */ - @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEnitityExplode(EntityExplodeEvent event) { Entity entity = event.getEntity(); @@ -364,7 +365,7 @@ public class EntityListener implements Listener { * * @param event The event to modify */ - @EventHandler (priority = EventPriority.LOW, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onFoodLevelChange(FoodLevelChangeEvent event) { Entity entity = event.getEntity(); @@ -387,40 +388,40 @@ public class EntityListener implements Listener { */ if (foodChange > 0) { switch (player.getItemInHand().getType()) { - case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ - case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ - case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */ - case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ - case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ - case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ - if (Permissions.farmersDiet(player)) { - event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel)); - } - return; + case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ + case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ + case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */ + case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ + case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ + case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ + if (Permissions.farmersDiet(player)) { + event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel)); + } + return; - case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ - case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ - case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ - case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ - if (Permissions.farmersDiet(player)) { - event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel)); - } - return; + case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ + case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ + case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ + case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ + if (Permissions.farmersDiet(player)) { + event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel)); + } + return; - case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ - if (Permissions.fishermansDiet(player)) { - event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel)); - } - return; + case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ + if (Permissions.fishermansDiet(player)) { + event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel)); + } + return; - case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ - if (Permissions.fishermansDiet(player)) { - event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel)); - } - return; + case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ + if (Permissions.fishermansDiet(player)) { + event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel)); + } + return; - default: - return; + default: + return; } } } @@ -431,7 +432,7 @@ public class EntityListener implements Listener { * * @param event The event to watch */ - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityTame(EntityTameEvent event) { Player player = (Player) event.getOwner(); @@ -446,13 +447,13 @@ public class EntityListener implements Listener { } } - @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityTarget(EntityTargetEvent event) { if (event.getEntity() instanceof Tameable && event.getTarget() instanceof Player) { Player player = (Player) event.getTarget(); Tameable tameable = (Tameable) event.getEntity(); - if (CombatTools.isFriendlyPet(player, tameable)) { + if (CombatUtils.isFriendlyPet(player, tameable)) { // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party // So we can make some assumptions here, about our casting and our check Player owner = (Player) tameable.getOwner(); diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index c49485bdb..73573bb5e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -1,150 +1,150 @@ -package com.gmail.nossr50.listeners; - -import org.bukkit.block.BlockState; -import org.bukkit.block.Furnace; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.FurnaceBurnEvent; -import org.bukkit.event.inventory.FurnaceExtractEvent; -import org.bukkit.event.inventory.FurnaceSmeltEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.inventory.FurnaceInventory; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.skills.SkillManagerStore; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.ItemChecks; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class InventoryListener implements Listener{ - private final mcMMO plugin; - - public InventoryListener(final mcMMO plugin) { - this.plugin = plugin; - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onInventoryOpen(InventoryOpenEvent event) { - HumanEntity player = event.getPlayer(); - - if (Misc.isNPCEntity(player)) { - return; - } - - Inventory inventory = event.getInventory(); - - if (inventory instanceof FurnaceInventory) { - Furnace furnace = (Furnace) inventory.getHolder(); - - if (furnace == null) { - return; - } - - BlockState furnaceBlock = furnace.getBlock().getState(); - - if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) { - plugin.addToOpenFurnaceTracker(furnaceBlock, player.getName()); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onInventoryClose(InventoryCloseEvent event) { - HumanEntity player = event.getPlayer(); - - if (Misc.isNPCEntity(player)) { - return; - } - - Inventory inventory = event.getInventory(); - - if (inventory instanceof FurnaceInventory) { - Furnace furnace = (Furnace) inventory.getHolder(); - - if (furnace == null) { - return; - } - - BlockState furnaceBlock = furnace.getBlock().getState(); - - if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) { - plugin.removeFromFurnaceTracker(furnaceBlock); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onFurnaceBurnEvent(FurnaceBurnEvent event) { - BlockState furnaceBlock = event.getBlock().getState(); - - if (furnaceBlock instanceof Furnace) { - ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); - - if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) { - Player player = plugin.getFurnacePlayer(furnaceBlock); - - if (!Misc.isNPCEntity(player)) { - return; - } - - if (Permissions.fuelEfficiency(player)) { - event.setBurnTime(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event.getBurnTime())); - } - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) { - BlockState furnaceBlock = event.getBlock().getState(); - - if (furnaceBlock instanceof Furnace) { - ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); - - if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) { - Player player = plugin.getFurnacePlayer(furnaceBlock); - - if (!Misc.isNPCEntity(player)) { - return; - } - - if (Permissions.skillEnabled(player, SkillType.SMELTING)) { - event.setResult(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event.getSource().getType(), event.getResult())); - } - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onFurnaceExtractEvent(FurnaceExtractEvent event) { - BlockState furnaceBlock = event.getBlock().getState(); - - if (furnaceBlock instanceof Furnace) { - ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult(); - - if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemChecks.isSmelted(result)) { - McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer()); - - if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) { - event.setExpToDrop(SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event.getExpToDrop())); - } - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onInventoryClickEvent(InventoryClickEvent event) { - SkillTools.removeAbilityBuff(event.getCurrentItem()); - } -} +package com.gmail.nossr50.listeners; + +import org.bukkit.block.BlockState; +import org.bukkit.block.Furnace; +import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.FurnaceBurnEvent; +import org.bukkit.event.inventory.FurnaceExtractEvent; +import org.bukkit.event.inventory.FurnaceSmeltEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.inventory.FurnaceInventory; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.skills.SkillManagerStore; +import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class InventoryListener implements Listener { + private final mcMMO plugin; + + public InventoryListener(final mcMMO plugin) { + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onInventoryOpen(InventoryOpenEvent event) { + HumanEntity player = event.getPlayer(); + + if (Misc.isNPCEntity(player)) { + return; + } + + Inventory inventory = event.getInventory(); + + if (inventory instanceof FurnaceInventory) { + Furnace furnace = (Furnace) inventory.getHolder(); + + if (furnace == null) { + return; + } + + BlockState furnaceBlock = furnace.getBlock().getState(); + + if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) { + plugin.addToOpenFurnaceTracker(furnaceBlock, player.getName()); + } + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onInventoryClose(InventoryCloseEvent event) { + HumanEntity player = event.getPlayer(); + + if (Misc.isNPCEntity(player)) { + return; + } + + Inventory inventory = event.getInventory(); + + if (inventory instanceof FurnaceInventory) { + Furnace furnace = (Furnace) inventory.getHolder(); + + if (furnace == null) { + return; + } + + BlockState furnaceBlock = furnace.getBlock().getState(); + + if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) { + plugin.removeFromFurnaceTracker(furnaceBlock); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onFurnaceBurnEvent(FurnaceBurnEvent event) { + BlockState furnaceBlock = event.getBlock().getState(); + + if (furnaceBlock instanceof Furnace) { + ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); + + if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) { + Player player = plugin.getFurnacePlayer(furnaceBlock); + + if (!Misc.isNPCEntity(player)) { + return; + } + + if (Permissions.fuelEfficiency(player)) { + event.setBurnTime(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event.getBurnTime())); + } + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) { + BlockState furnaceBlock = event.getBlock().getState(); + + if (furnaceBlock instanceof Furnace) { + ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); + + if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) { + Player player = plugin.getFurnacePlayer(furnaceBlock); + + if (!Misc.isNPCEntity(player)) { + return; + } + + if (Permissions.skillEnabled(player, SkillType.SMELTING)) { + event.setResult(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event.getSource().getType(), event.getResult())); + } + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onFurnaceExtractEvent(FurnaceExtractEvent event) { + BlockState furnaceBlock = event.getBlock().getState(); + + if (furnaceBlock instanceof Furnace) { + ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult(); + + if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemUtils.isSmelted(result)) { + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(event.getPlayer()); + + if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) { + event.setExpToDrop(SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event.getExpToDrop())); + } + } + } + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onInventoryClickEvent(InventoryClickEvent event) { + SkillUtils.removeAbilityBuff(event.getCurrentItem()); + } +} diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 757177950..30858a1a9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -28,28 +28,28 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; +import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; -import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.BlockChecks; +import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.ChimaeraWing; -import com.gmail.nossr50.util.Hardcore; -import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.HardcoreManager; +import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Motd; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; public class PlayerListener implements Listener { private final mcMMO plugin; @@ -79,10 +79,10 @@ public class PlayerListener implements Listener { Player killer = player.getKiller(); if (killer != null && Config.getInstance().getHardcoreVampirismEnabled()) { - Hardcore.invokeVampirism(killer, player); + HardcoreManager.invokeVampirism(killer, player); } - Hardcore.invokeStatPenalty(player); + HardcoreManager.invokeStatPenalty(player); } } @@ -99,7 +99,7 @@ public class PlayerListener implements Listener { return; } - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); if (profile.getGodMode() && !Permissions.mcgod(player)) { @@ -127,7 +127,7 @@ public class PlayerListener implements Listener { return; } - Users.addUser(player).getProfile().actualizeRespawnATS(); + UserManager.addUser(player).getProfile().actualizeRespawnATS(); } } @@ -139,14 +139,14 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerDropItemEvent(PlayerDropItemEvent event) { Player player = event.getPlayer(); - PlayerProfile playerProfile = Users.getPlayer(player).getProfile(); + PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) { event.setCancelled(true); return; } - SkillTools.removeAbilityBuff(event.getItemDrop().getItemStack()); + SkillUtils.removeAbilityBuff(event.getItemDrop().getItemStack()); } /** @@ -165,24 +165,24 @@ public class PlayerListener implements Listener { FishingManager fishingManager = SkillManagerStore.getInstance().getFishingManager(player.getName()); switch (event.getState()) { - case CAUGHT_FISH: - fishingManager.handleFishing((Item) event.getCaught()); + case CAUGHT_FISH: + fishingManager.handleFishing((Item) event.getCaught()); - if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) { - event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop())); - } - break; + if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) { + event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop())); + } + break; - case CAUGHT_ENTITY: - Entity entity = event.getCaught(); + case CAUGHT_ENTITY: + Entity entity = event.getCaught(); - if (fishingManager.canShake(entity)) { - fishingManager.shakeCheck((LivingEntity) entity); - } + if (fishingManager.canShake(entity)) { + fishingManager.shakeCheck((LivingEntity) entity); + } - break; - default: - break; + break; + default: + break; } } @@ -200,9 +200,9 @@ public class PlayerListener implements Listener { return; } - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - if (mcMMOPlayer.inParty() && ItemChecks.isShareable(item.getItemStack())) { + if (mcMMOPlayer.inParty() && ItemUtils.isShareable(item.getItemStack())) { ShareHandler.handleItemShare(event, mcMMOPlayer); } } @@ -221,7 +221,7 @@ public class PlayerListener implements Listener { } /* GARBAGE COLLECTION */ - BleedTimer.bleedOut(player); //Bleed it out + BleedTimerTask.bleedOut(player); // Bleed it out } /** @@ -249,6 +249,7 @@ public class PlayerListener implements Listener { /** * Monitor PlayerRespawn events. + * * @param event The event to watch */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -259,7 +260,7 @@ public class PlayerListener implements Listener { return; } - Users.getPlayer(player).getProfile().actualizeRespawnATS(); + UserManager.getPlayer(player).getProfile().actualizeRespawnATS(); } /** @@ -279,43 +280,43 @@ public class PlayerListener implements Listener { ItemStack heldItem = player.getItemInHand(); switch (event.getAction()) { - case RIGHT_CLICK_BLOCK: - int blockID = block.getTypeId(); + case RIGHT_CLICK_BLOCK: + int blockID = block.getTypeId(); - /* REPAIR CHECKS */ - if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairManager.isRepairable(heldItem)) { - mcMMO.repairManager.handleRepair(Users.getPlayer(player), heldItem); - event.setCancelled(true); - player.updateInventory(); - } - /* SALVAGE CHECKS */ - else if (blockID == Salvage.anvilID && Permissions.salvage(player) && Salvage.isSalvageable(heldItem)) { - Salvage.handleSalvage(player, block.getLocation(), heldItem); - event.setCancelled(true); - player.updateInventory(); - } - /* BLAST MINING CHECK */ - else if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) { - if (blockID == Material.TNT.getId()) { - event.setCancelled(true); // Don't detonate the TNT if they're too close + /* REPAIR CHECKS */ + if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairManager.isRepairable(heldItem)) { + mcMMO.repairManager.handleRepair(UserManager.getPlayer(player), heldItem); + event.setCancelled(true); + player.updateInventory(); } - else { + /* SALVAGE CHECKS */ + else if (blockID == Salvage.anvilID && Permissions.salvage(player) && Salvage.isSalvageable(heldItem)) { + Salvage.handleSalvage(player, block.getLocation(), heldItem); + event.setCancelled(true); + player.updateInventory(); + } + /* BLAST MINING CHECK */ + else if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) { + if (blockID == Material.TNT.getId()) { + event.setCancelled(true); // Don't detonate the TNT if they're too close + } + else { + SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation(); + } + } + + break; + + case RIGHT_CLICK_AIR: + /* BLAST MINING CHECK */ + if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) { SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation(); } - } - break; + break; - case RIGHT_CLICK_AIR: - /* BLAST MINING CHECK */ - if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) { - SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation(); - } - - break; - - default: - break; + default: + break; } } @@ -335,84 +336,84 @@ public class PlayerListener implements Listener { ItemStack heldItem = player.getItemInHand(); switch (event.getAction()) { - case RIGHT_CLICK_BLOCK: - Block block = event.getClickedBlock(); - BlockState blockState = block.getState(); + case RIGHT_CLICK_BLOCK: + Block block = event.getClickedBlock(); + BlockState blockState = block.getState(); - /* ACTIVATION & ITEM CHECKS */ - if (BlockChecks.canActivateAbilities(blockState)) { - if (Config.getInstance().getAbilitiesEnabled()) { - if (BlockChecks.canActivateHerbalism(blockState)) { - SkillTools.activationCheck(player, SkillType.HERBALISM); + /* ACTIVATION & ITEM CHECKS */ + if (BlockUtils.canActivateAbilities(blockState)) { + if (Config.getInstance().getAbilitiesEnabled()) { + if (BlockUtils.canActivateHerbalism(blockState)) { + SkillUtils.activationCheck(player, SkillType.HERBALISM); + } + + SkillUtils.activationCheck(player, SkillType.AXES); + SkillUtils.activationCheck(player, SkillType.EXCAVATION); + SkillUtils.activationCheck(player, SkillType.MINING); + SkillUtils.activationCheck(player, SkillType.SWORDS); + SkillUtils.activationCheck(player, SkillType.UNARMED); + SkillUtils.activationCheck(player, SkillType.WOODCUTTING); } - SkillTools.activationCheck(player, SkillType.AXES); - SkillTools.activationCheck(player, SkillType.EXCAVATION); - SkillTools.activationCheck(player, SkillType.MINING); - SkillTools.activationCheck(player, SkillType.SWORDS); - SkillTools.activationCheck(player, SkillType.UNARMED); - SkillTools.activationCheck(player, SkillType.WOODCUTTING); + ChimaeraWing.activationCheck(player); } + /* GREEN THUMB CHECK */ + HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName()); + + if (herbalismManager.canGreenThumbBlock(blockState)) { + player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1)); + + if (herbalismManager.processGreenThumbBlocks(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) { + blockState.update(true); + } + } + + /* SHROOM THUMB CHECK */ + else if (herbalismManager.canUseShroomThumb(blockState)) { + if (herbalismManager.processShroomThumb(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) { + blockState.update(true); + } + } + break; + + case RIGHT_CLICK_AIR: + + /* ACTIVATION CHECKS */ + if (Config.getInstance().getAbilitiesEnabled()) { + SkillUtils.activationCheck(player, SkillType.AXES); + SkillUtils.activationCheck(player, SkillType.EXCAVATION); + SkillUtils.activationCheck(player, SkillType.HERBALISM); + SkillUtils.activationCheck(player, SkillType.MINING); + SkillUtils.activationCheck(player, SkillType.SWORDS); + SkillUtils.activationCheck(player, SkillType.UNARMED); + SkillUtils.activationCheck(player, SkillType.WOODCUTTING); + } + + /* ITEM CHECKS */ ChimaeraWing.activationCheck(player); - } - /* GREEN THUMB CHECK */ - HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName()); + break; - if (herbalismManager.canGreenThumbBlock(blockState)) { - player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1)); + case LEFT_CLICK_AIR: + case LEFT_CLICK_BLOCK: - if (herbalismManager.processGreenThumbBlocks(blockState) && SkillTools.blockBreakSimulate(block, player, false)) { - blockState.update(true); + /* CALL OF THE WILD CHECKS */ + if (player.isSneaking()) { + Material type = heldItem.getType(); + + if (type == Material.RAW_FISH) { + SkillManagerStore.getInstance().getTamingManager(player.getName()).summonOcelot(); + } + else if (type == Material.BONE) { + SkillManagerStore.getInstance().getTamingManager(player.getName()).summonWolf(); + } } - } - /* SHROOM THUMB CHECK */ - else if (herbalismManager.canUseShroomThumb(blockState)) { - if (herbalismManager.processShroomThumb(blockState) && SkillTools.blockBreakSimulate(block, player, false)) { - blockState.update(true); - } - } - break; + break; - case RIGHT_CLICK_AIR: - - /* ACTIVATION CHECKS */ - if (Config.getInstance().getAbilitiesEnabled()) { - SkillTools.activationCheck(player, SkillType.AXES); - SkillTools.activationCheck(player, SkillType.EXCAVATION); - SkillTools.activationCheck(player, SkillType.HERBALISM); - SkillTools.activationCheck(player, SkillType.MINING); - SkillTools.activationCheck(player, SkillType.SWORDS); - SkillTools.activationCheck(player, SkillType.UNARMED); - SkillTools.activationCheck(player, SkillType.WOODCUTTING); - } - - /* ITEM CHECKS */ - ChimaeraWing.activationCheck(player); - - break; - - case LEFT_CLICK_AIR: - case LEFT_CLICK_BLOCK: - - /* CALL OF THE WILD CHECKS */ - if (player.isSneaking()) { - Material type = heldItem.getType(); - - if (type == Material.RAW_FISH) { - SkillManagerStore.getInstance().getTamingManager(player.getName()).summonOcelot(); - } - else if (type == Material.BONE) { - SkillManagerStore.getInstance().getTamingManager(player.getName()).summonWolf(); - } - } - - break; - - default: - break; + default: + break; } } @@ -429,7 +430,7 @@ public class PlayerListener implements Listener { return; } - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); if (mcMMOPlayer.getPartyChatMode()) { Party party = mcMMOPlayer.getParty(); @@ -463,7 +464,7 @@ public class PlayerListener implements Listener { // Do these ACTUALLY have to be lower case to work properly? for (SkillType skill : SkillType.values()) { String skillName = skill.toString().toLowerCase(); - String localizedName = SkillTools.getSkillName(skill).toLowerCase(); + String localizedName = SkillUtils.getSkillName(skill).toLowerCase(); if (lowerCaseCommand.equals(localizedName)) { event.setMessage(message.replace(command, skillName)); diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java deleted file mode 100644 index 98db0a589..000000000 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gmail.nossr50.listeners; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; - -/** - * Listener for listening to our own events, only really useful for catching errors - */ -public class SelfListener implements Listener { - /** - * Monitor internal XP gain events. - * - * @param event The event to watch - */ - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerXpGain(McMMOPlayerXpGainEvent event) { - int xp = event.getXpGained(); - - if (xp < 0) { - try { - throw new Exception("Gained negative XP!"); - } - catch (Exception e) { - mcMMO.p.getLogger().severe(e.getMessage()); - e.printStackTrace(); - } - } - } -} diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java b/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java similarity index 68% rename from src/main/java/com/gmail/nossr50/spout/SpoutListener.java rename to src/main/java/com/gmail/nossr50/listeners/SpoutListener.java index f2ccaa4e9..efe0c2638 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.spout; +package com.gmail.nossr50.listeners; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -11,12 +11,13 @@ import org.getspout.spoutapi.gui.Button; import org.getspout.spoutapi.gui.ScreenType; import org.getspout.spoutapi.player.SpoutPlayer; -import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton; +import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; +import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.spout.buttons.McmmoButton; -import com.gmail.nossr50.spout.huds.SpoutHud; -import com.gmail.nossr50.spout.popups.Menu; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.spout.SpoutUtils; public class SpoutListener implements Listener { @@ -28,14 +29,14 @@ public class SpoutListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSpoutCraftEnable(SpoutCraftEnableEvent event) { SpoutPlayer spoutPlayer = event.getPlayer(); - McMMOPlayer mcMMOPlayer = Users.getPlayer(spoutPlayer); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(spoutPlayer); - //TODO: Add custom titles based on skills - if (SpoutTools.showPowerLevel) { + // TODO: Add custom titles based on skills + if (SpoutUtils.showPowerLevel) { spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getName(), mcMMOPlayer.getPowerLevel())); } - mcMMOPlayer.getProfile().setSpoutHud(new SpoutHud(mcMMOPlayer)); //Setup Party HUD stuff + mcMMOPlayer.getProfile().setSpoutHud(new McMMOHud(mcMMOPlayer)); // Setup Party HUD stuff } /** @@ -47,8 +48,8 @@ public class SpoutListener implements Listener { public void onButtonClick(ButtonClickEvent event) { Button button = event.getButton(); - if (button instanceof McmmoButton) { - ((McmmoButton) button).activate(); + if (button instanceof McMMOButton) { + ((McMMOButton) button).activate(); } } @@ -59,10 +60,10 @@ public class SpoutListener implements Listener { */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onScreenClose(ScreenCloseEvent event) { - if (event.getScreen() instanceof Menu) { + if (event.getScreen() instanceof McMMOMenu) { SpoutPlayer spoutPlayer = event.getPlayer(); - Users.getPlayer(spoutPlayer).getProfile().getSpoutHud().onMenuClose(); + UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud().onMenuClose(); spoutPlayer.getMainScreen().setDirty(true); } } @@ -80,8 +81,8 @@ public class SpoutListener implements Listener { return; } - if (event.getKey() == SpoutTools.menuKey) { - SpoutHud spoutHud = Users.getPlayer(spoutPlayer).getProfile().getSpoutHud(); + if (event.getKey() == SpoutUtils.menuKey) { + McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud(); if (!spoutHud.isMenuOpened()) { spoutHud.openMenu(); diff --git a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java index b4eef1ffb..8780c9e93 100644 --- a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java @@ -26,7 +26,7 @@ public class WorldListener implements Listener { * * @param event The event to watch */ - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onStructureGrow(StructureGrowEvent event) { Location location = event.getLocation(); diff --git a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java index 707fd006d..e52f7e175 100644 --- a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java +++ b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java @@ -27,7 +27,7 @@ public final class LocaleLoader { * @param messageArguments Any arguments to be added to the string * @return The properly formatted locale string */ - public static String getString(String key, Object ... messageArguments) { + public static String getString(String key, Object... messageArguments) { if (bundle == null) { initialize(); } @@ -45,7 +45,7 @@ public final class LocaleLoader { } } - private static String getString(String key, ResourceBundle bundle, Object ... messageArguments) throws MissingResourceException { + private static String getString(String key, ResourceBundle bundle, Object... messageArguments) throws MissingResourceException { String output = bundle.getString(key); if (messageArguments != null) { diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 935625587..17b43990c 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -1,492 +1,492 @@ -package com.gmail.nossr50; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import net.shatteredlands.shatt.backup.ZipLibrary; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.plugin.PluginManager; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitScheduler; - -import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; -import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory; -import com.gmail.nossr50.util.metrics.MetricsManager; -import com.gmail.nossr50.commands.CommandRegistrationHelper; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.HiddenConfig; -import com.gmail.nossr50.config.TreasuresConfig; -import com.gmail.nossr50.database.Database; -import com.gmail.nossr50.database.Leaderboard; -import com.gmail.nossr50.database.runnables.UserPurgeTask; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.listeners.BlockListener; -import com.gmail.nossr50.listeners.EntityListener; -import com.gmail.nossr50.listeners.InventoryListener; -import com.gmail.nossr50.listeners.PlayerListener; -import com.gmail.nossr50.listeners.WorldListener; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mods.config.CustomArmorConfig; -import com.gmail.nossr50.mods.config.CustomBlocksConfig; -import com.gmail.nossr50.mods.config.CustomEntityConfig; -import com.gmail.nossr50.mods.config.CustomToolsConfig; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.party.runnables.PartiesLoader; -import com.gmail.nossr50.party.runnables.PartyAutoKick; -import com.gmail.nossr50.runnables.SaveTimer; -import com.gmail.nossr50.skills.child.ChildConfig; -import com.gmail.nossr50.skills.repair.RepairManager; -import com.gmail.nossr50.skills.repair.RepairManagerFactory; -import com.gmail.nossr50.skills.repair.Repairable; -import com.gmail.nossr50.skills.repair.config.RepairConfigManager; -import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.runnables.SkillMonitor; -import com.gmail.nossr50.spout.SpoutConfig; -import com.gmail.nossr50.spout.SpoutTools; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.LogFilter; -import com.gmail.nossr50.util.UpdateCheck; -import com.gmail.nossr50.util.Users; - -public class mcMMO extends JavaPlugin { - private final PlayerListener playerListener = new PlayerListener(this); - private final BlockListener blockListener = new BlockListener(this); - private final EntityListener entityListener = new EntityListener(this); - private final InventoryListener inventoryListener = new InventoryListener(this); - private final WorldListener worldListener = new WorldListener(); - - private HashMap tntTracker = new HashMap(); - private HashMap furnaceTracker = new HashMap(); - - public static mcMMO p; - - public static ChunkManager placeStore; - public static RepairManager repairManager; - - // Jar Stuff - public static File mcmmo; - - // File Paths - private static String mainDirectory; - private static String flatFileDirectory; - private static String usersFile; - private static String modDirectory; - - // Update Check - public boolean updateAvailable; - - // Spout Check - public static boolean spoutEnabled = false; - - // XP Event Check - private boolean xpEventEnabled = false; - - // Metadata Values - public static FixedMetadataValue metadataValue; - public final static String entityMetadataKey = "mcMMO: Spawned Entity"; - public final static String blockMetadataKey = "mcMMO: Piston Tracking"; - - /** - * Things to be run when the plugin is enabled. - */ - @Override - public void onEnable() { - try { - p = this; - getLogger().setFilter(new LogFilter(this)); - metadataValue = new FixedMetadataValue(this, true); - - setupFilePaths(); - setupSpout(); - loadConfigFiles(); - - if (!Config.getInstance().getUseMySQL()) { - Users.loadUsers(); - } - - registerEvents(); - - // Setup the leader boards - if (Config.getInstance().getUseMySQL()) { - // TODO: Why do we have to check for a connection that hasn't be made yet? - Database.checkConnected(); - Database.createStructure(); - } - else { - Leaderboard.updateLeaderboards(); - } - - for (Player player : getServer().getOnlinePlayers()) { - Users.addUser(player); // In case of reload add all users back into PlayerProfile - } - - getLogger().info("Version " + getDescription().getVersion() + " is enabled!"); - - scheduleTasks(); - registerCommands(); - - MetricsManager.setup(); - - placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager - - checkForUpdates(); - - if (Config.getInstance().getPTPCommandWorldPermissions()) { - Permissions.generateWorldTeleportPermissions(); - } - } - catch (Throwable t) { - getLogger().severe("There was an error while enabling mcMMO!"); - - if (!(t instanceof ExceptionInInitializerError)) { - t.printStackTrace(); - } - else { - getLogger().info("Please do not replace the mcMMO jar while the server is running."); - } - - Bukkit.getPluginManager().disablePlugin(this); - } - } - - /** - * Setup the various storage file paths - */ - private void setupFilePaths() { - mcmmo = getFile(); - mainDirectory = getDataFolder().getPath() + File.separator; - flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator; - usersFile = flatFileDirectory + "mcmmo.users"; - modDirectory = mainDirectory + "ModConfigs" + File.separator; - } - - private void checkForUpdates() { - if (Config.getInstance().getUpdateCheckEnabled()) { - try { - updateAvailable = UpdateCheck.updateAvailable(); - } - catch (Exception e) { - updateAvailable = false; - } - - if (updateAvailable) { - getLogger().info(LocaleLoader.getString("UpdateChecker.outdated")); - getLogger().info(LocaleLoader.getString("UpdateChecker.newavailable")); - } - } - } - - /** - * Get profile of the player by name. - *
- * This function is designed for API usage. - * - * @param playerName Name of player whose profile to get - * @return the PlayerProfile object - */ - public PlayerProfile getPlayerProfile(String playerName) { - return Users.getPlayer(playerName).getProfile(); - } - - /** - * Get profile of the player. - *
- * This function is designed for API usage. - * - * @param player player whose profile to get - * @return the PlayerProfile object - */ - public PlayerProfile getPlayerProfile(OfflinePlayer player) { - return Users.getPlayer(player.getName()).getProfile(); - } - - /** - * Get profile of the player. - *
- * This function is designed for API usage. - * - * @param player player whose profile to get - * @return the PlayerProfile object - */ - @Deprecated - public PlayerProfile getPlayerProfile(Player player) { - return Users.getProfile(player); - } - - /** - * Things to be run when the plugin is disabled. - */ - @Override - public void onDisable() { - try { - Users.saveAll(); // Make sure to save player information if the server shuts down - PartyManager.saveParties(); - placeStore.saveAll(); // Save our metadata - placeStore.cleanUp(); // Cleanup empty metadata stores - } - catch (NullPointerException e) {} - - getServer().getScheduler().cancelTasks(this); // This removes our tasks - HandlerList.unregisterAll(this); // Cancel event registrations - - if (Config.getInstance().getBackupsEnabled()) { - // Remove other tasks BEFORE starting the Backup, or we just cancel it straight away. - try { - ZipLibrary.mcMMObackup(); - } - catch (IOException e) { - getLogger().severe(e.toString()); - } - catch (Throwable e) { - if (e instanceof NoClassDefFoundError) { - getLogger().severe("Backup class not found!"); - getLogger().info("Please do not replace the mcMMO jar while the server is running."); - } - else { - getLogger().severe(e.toString()); - } - } - } - - getLogger().info("Was disabled."); //How informative! - } - - private void loadConfigFiles() { - // Force the loading of config files - Config configInstance = Config.getInstance(); - TreasuresConfig.getInstance(); - HiddenConfig.getInstance(); - AdvancedConfig.getInstance(); - new ChildConfig(); - - List repairables = new ArrayList(); - - if (configInstance.getToolModsEnabled()) { - repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables()); - } - - if (configInstance.getArmorModsEnabled()) { - repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables()); - } - - if (configInstance.getBlockModsEnabled()) { - CustomBlocksConfig.getInstance(); - } - - if (configInstance.getEntityModsEnabled()) { - CustomEntityConfig.getInstance(); - } - - // Load repair configs, make manager, and register them at this time - RepairConfigManager rManager = new RepairConfigManager(this); - repairables.addAll(rManager.getLoadedRepairables()); - repairManager = RepairManagerFactory.getRepairManager(repairables.size()); - repairManager.registerRepairables(repairables); - - // Check if Repair Anvil and Salvage Anvil have different itemID's - if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) { - getLogger().warning("Can't use the same itemID for Repair/Salvage Anvils!"); - } - } - - private void setupSpout() { - // Check for Spout - if (getServer().getPluginManager().isPluginEnabled("Spout")) { - spoutEnabled = true; - - SpoutConfig.getInstance(); - SpoutTools.setupSpoutConfigs(); - SpoutTools.registerCustomEvent(); - SpoutTools.preCacheFiles(); - SpoutTools.reloadSpoutPlayers(); // Handle spout players after a /reload - } - } - - private void registerEvents() { - PluginManager pluginManager = getServer().getPluginManager(); - - // Register events - pluginManager.registerEvents(playerListener, this); - pluginManager.registerEvents(blockListener, this); - pluginManager.registerEvents(entityListener, this); - pluginManager.registerEvents(inventoryListener, this); - pluginManager.registerEvents(worldListener, this); - } - - /** - * Register the commands. - */ - private void registerCommands() { - CommandRegistrationHelper.registerSkillCommands(); - - // mc* commands - CommandRegistrationHelper.registerMcpurgeCommand(); - CommandRegistrationHelper.registerMcremoveCommand(); - CommandRegistrationHelper.registerMcabilityCommand(); - CommandRegistrationHelper.registerMcgodCommand(); - CommandRegistrationHelper.registerMcmmoCommand(); - CommandRegistrationHelper.registerMcrefreshCommand(); - CommandRegistrationHelper.registerMctopCommand(); - CommandRegistrationHelper.registerMcrankCommand(); - CommandRegistrationHelper.registerMcstatsCommand(); - - // Party commands - CommandRegistrationHelper.registerAdminChatCommand(); - CommandRegistrationHelper.registerPartyCommand(); - CommandRegistrationHelper.registerPartyChatCommand(); - CommandRegistrationHelper.registerPtpCommand(); - - // Other commands - CommandRegistrationHelper.registerAddxpCommand(); - CommandRegistrationHelper.registerAddlevelsCommand(); - CommandRegistrationHelper.registerMmoeditCommand(); - CommandRegistrationHelper.registerInspectCommand(); - CommandRegistrationHelper.registerXprateCommand(); - CommandRegistrationHelper.registerMmoupdateCommand(); - CommandRegistrationHelper.registerSkillresetCommand(); - CommandRegistrationHelper.registerHardcoreCommand(); - CommandRegistrationHelper.registerVampirismCommand(); - CommandRegistrationHelper.registerMcnotifyCommand(); - - // Spout commands - CommandRegistrationHelper.registerXplockCommand(); - CommandRegistrationHelper.registerMchudCommand(); - } - - private void scheduleTasks() { - BukkitScheduler scheduler = getServer().getScheduler(); - - // Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException - scheduler.scheduleSyncDelayedTask(this, new PartiesLoader(), 0); - - // Periodic save timer (Saves every 10 minutes by default) - long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200; - - scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(), saveIntervalTicks, saveIntervalTicks); - // Regen & Cooldown timer (Runs every second) - scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(), 20, 20); - // Bleed timer (Runs every two seconds) - scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 40, 40); - - // Old & Powerless User remover - int purgeInterval = Config.getInstance().getPurgeInterval(); - - if (purgeInterval == 0) { - scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); // Start 2 seconds after startup. - } - else if (purgeInterval > 0) { - long purgeIntervalTicks = purgeInterval * 60 * 60 * 20; - - scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks); - } - - // Automatically remove old members from parties - long kickInterval = Config.getInstance().getAutoPartyKickInterval(); - - if (kickInterval == 0) { - scheduler.scheduleSyncDelayedTask(this, new PartyAutoKick(), 40); // Start 2 seconds after startup. - } - else if (kickInterval > 0) { - long kickIntervalTicks = kickInterval * 60 * 60 * 20; - - scheduler.scheduleSyncRepeatingTask(this, new PartyAutoKick(), kickIntervalTicks, kickIntervalTicks); - } - } - - /** - * Add a set of values to the TNT tracker. - * - * @param tntID The EntityID of the TNT - * @param playerName The name of the detonating player - */ - public void addToTNTTracker(int tntID, String playerName) { - tntTracker.put(tntID, playerName); - } - - /** - * Check to see if a given TNT Entity is tracked. - * - * @param tntID The EntityID of the TNT - * @return true if the TNT is being tracked, false otherwise - */ - public boolean tntIsTracked(int tntID) { - return tntTracker.containsKey(tntID); - } - - /** - * Get the player who detonated the TNT. - * - * @param tntID The EntityID of the TNT - * @return the Player who detonated it - */ - public Player getTNTPlayer(int tntID) { - return getServer().getPlayer(tntTracker.get(tntID)); - } - - /** - * Remove TNT from the tracker after it explodes. - * - * @param tntID The EntityID of the TNT - */ - public void removeFromTNTTracker(int tntID) { - tntTracker.remove(tntID); - } - - public void addToOpenFurnaceTracker(BlockState furnace, String playerName) { - furnaceTracker.put(furnace, playerName); - } - - public boolean furnaceIsTracked(BlockState furnace) { - return furnaceTracker.containsKey(furnace); - } - - public void removeFromFurnaceTracker(BlockState furnace) { - furnaceTracker.remove(furnace); - } - - public Player getFurnacePlayer(BlockState furnace) { - return getServer().getPlayer(furnaceTracker.get(furnace)); - } - - public static String getMainDirectory() { - return mainDirectory; - } - - public static String getFlatFileDirectory() { - return flatFileDirectory; - } - - public static String getUsersFilePath() { - return usersFile; - } - - public static String getModDirectory() { - return modDirectory; - } - - public boolean isXPEventEnabled() { - return xpEventEnabled; - } - - public void setXPEventEnabled(boolean enabled) { - this.xpEventEnabled = enabled; - } - - public void toggleXpEventEnabled() { - xpEventEnabled = !xpEventEnabled; - } - - public void debug(String message) { - getLogger().info("[Debug] " + message); - } -} +package com.gmail.nossr50; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.shatteredlands.shatt.backup.ZipLibrary; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitScheduler; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.HiddenConfig; +import com.gmail.nossr50.config.mods.CustomArmorConfig; +import com.gmail.nossr50.config.mods.CustomBlockConfig; +import com.gmail.nossr50.config.mods.CustomEntityConfig; +import com.gmail.nossr50.config.mods.CustomToolConfig; +import com.gmail.nossr50.config.spout.SpoutConfig; +import com.gmail.nossr50.config.treasure.TreasureConfig; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.database.LeaderboardManager; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.listeners.BlockListener; +import com.gmail.nossr50.listeners.EntityListener; +import com.gmail.nossr50.listeners.InventoryListener; +import com.gmail.nossr50.listeners.PlayerListener; +import com.gmail.nossr50.listeners.WorldListener; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.metrics.MetricsManager; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.runnables.SaveTimerTask; +import com.gmail.nossr50.runnables.database.UserPurgeTask; +import com.gmail.nossr50.runnables.party.PartyAutoKickTask; +import com.gmail.nossr50.runnables.party.PartyLoaderTask; +import com.gmail.nossr50.runnables.skills.BleedTimerTask; +import com.gmail.nossr50.runnables.skills.SkillMonitorTask; +import com.gmail.nossr50.skills.child.ChildConfig; +import com.gmail.nossr50.skills.repair.RepairManager; +import com.gmail.nossr50.skills.repair.RepairManagerFactory; +import com.gmail.nossr50.skills.repair.Repairable; +import com.gmail.nossr50.skills.repair.config.RepairConfigManager; +import com.gmail.nossr50.util.LogFilter; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.UpdateChecker; +import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; +import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory; +import com.gmail.nossr50.util.commands.CommandRegistrationManager; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.spout.SpoutUtils; + +public class mcMMO extends JavaPlugin { + private final PlayerListener playerListener = new PlayerListener(this); + private final BlockListener blockListener = new BlockListener(this); + private final EntityListener entityListener = new EntityListener(this); + private final InventoryListener inventoryListener = new InventoryListener(this); + private final WorldListener worldListener = new WorldListener(); + + private HashMap tntTracker = new HashMap(); + private HashMap furnaceTracker = new HashMap(); + + public static mcMMO p; + + public static ChunkManager placeStore; + public static RepairManager repairManager; + + // Jar Stuff + public static File mcmmo; + + // File Paths + private static String mainDirectory; + private static String flatFileDirectory; + private static String usersFile; + private static String modDirectory; + + // Update Check + public boolean updateAvailable; + + // Spout Check + public static boolean spoutEnabled = false; + + // XP Event Check + private boolean xpEventEnabled = false; + + // Metadata Values + public static FixedMetadataValue metadataValue; + public final static String entityMetadataKey = "mcMMO: Spawned Entity"; + public final static String blockMetadataKey = "mcMMO: Piston Tracking"; + + /** + * Things to be run when the plugin is enabled. + */ + @Override + public void onEnable() { + try { + p = this; + getLogger().setFilter(new LogFilter(this)); + metadataValue = new FixedMetadataValue(this, true); + + setupFilePaths(); + setupSpout(); + loadConfigFiles(); + + if (!Config.getInstance().getUseMySQL()) { + UserManager.loadUsers(); + } + + registerEvents(); + + // Setup the leader boards + if (Config.getInstance().getUseMySQL()) { + // TODO: Why do we have to check for a connection that hasn't be made yet? + DatabaseManager.checkConnected(); + DatabaseManager.createStructure(); + } + else { + LeaderboardManager.updateLeaderboards(); + } + + for (Player player : getServer().getOnlinePlayers()) { + UserManager.addUser(player); // In case of reload add all users back into PlayerProfile + } + + getLogger().info("Version " + getDescription().getVersion() + " is enabled!"); + + scheduleTasks(); + registerCommands(); + + MetricsManager.setup(); + + placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager + + checkForUpdates(); + + if (Config.getInstance().getPTPCommandWorldPermissions()) { + Permissions.generateWorldTeleportPermissions(); + } + } + catch (Throwable t) { + getLogger().severe("There was an error while enabling mcMMO!"); + + if (!(t instanceof ExceptionInInitializerError)) { + t.printStackTrace(); + } + else { + getLogger().info("Please do not replace the mcMMO jar while the server is running."); + } + + Bukkit.getPluginManager().disablePlugin(this); + } + } + + /** + * Things to be run when the plugin is disabled. + */ + @Override + public void onDisable() { + try { + UserManager.saveAll(); // Make sure to save player information if the server shuts down + PartyManager.saveParties(); + placeStore.saveAll(); // Save our metadata + placeStore.cleanUp(); // Cleanup empty metadata stores + } + catch (NullPointerException e) {} + + getServer().getScheduler().cancelTasks(this); // This removes our tasks + HandlerList.unregisterAll(this); // Cancel event registrations + + if (Config.getInstance().getBackupsEnabled()) { + // Remove other tasks BEFORE starting the Backup, or we just cancel it straight away. + try { + ZipLibrary.mcMMObackup(); + } + catch (IOException e) { + getLogger().severe(e.toString()); + } + catch (Throwable e) { + if (e instanceof NoClassDefFoundError) { + getLogger().severe("Backup class not found!"); + getLogger().info("Please do not replace the mcMMO jar while the server is running."); + } + else { + getLogger().severe(e.toString()); + } + } + } + + getLogger().info("Was disabled."); // How informative! + } + + /** + * Get profile of the player by name. + *
+ * This function is designed for API usage. + * + * @param playerName Name of player whose profile to get + * @return the PlayerProfile object + */ + public PlayerProfile getPlayerProfile(String playerName) { + return UserManager.getPlayer(playerName).getProfile(); + } + + /** + * Get profile of the player. + *
+ * This function is designed for API usage. + * + * @param player player whose profile to get + * @return the PlayerProfile object + */ + public PlayerProfile getPlayerProfile(OfflinePlayer player) { + return UserManager.getPlayer(player.getName()).getProfile(); + } + + /** + * Get profile of the player. + *
+ * This function is designed for API usage. + * + * @param player player whose profile to get + * @return the PlayerProfile object + */ + @Deprecated + public PlayerProfile getPlayerProfile(Player player) { + return UserManager.getProfile(player); + } + + /** + * Add a set of values to the TNT tracker. + * + * @param tntID The EntityID of the TNT + * @param playerName The name of the detonating player + */ + public void addToTNTTracker(int tntID, String playerName) { + tntTracker.put(tntID, playerName); + } + + /** + * Check to see if a given TNT Entity is tracked. + * + * @param tntID The EntityID of the TNT + * @return true if the TNT is being tracked, false otherwise + */ + public boolean tntIsTracked(int tntID) { + return tntTracker.containsKey(tntID); + } + + /** + * Get the player who detonated the TNT. + * + * @param tntID The EntityID of the TNT + * @return the Player who detonated it + */ + public Player getTNTPlayer(int tntID) { + return getServer().getPlayer(tntTracker.get(tntID)); + } + + /** + * Remove TNT from the tracker after it explodes. + * + * @param tntID The EntityID of the TNT + */ + public void removeFromTNTTracker(int tntID) { + tntTracker.remove(tntID); + } + + public void addToOpenFurnaceTracker(BlockState furnace, String playerName) { + furnaceTracker.put(furnace, playerName); + } + + public boolean furnaceIsTracked(BlockState furnace) { + return furnaceTracker.containsKey(furnace); + } + + public void removeFromFurnaceTracker(BlockState furnace) { + furnaceTracker.remove(furnace); + } + + public Player getFurnacePlayer(BlockState furnace) { + return getServer().getPlayer(furnaceTracker.get(furnace)); + } + + public static String getMainDirectory() { + return mainDirectory; + } + + public static String getFlatFileDirectory() { + return flatFileDirectory; + } + + public static String getUsersFilePath() { + return usersFile; + } + + public static String getModDirectory() { + return modDirectory; + } + + public boolean isXPEventEnabled() { + return xpEventEnabled; + } + + public void setXPEventEnabled(boolean enabled) { + this.xpEventEnabled = enabled; + } + + public void toggleXpEventEnabled() { + xpEventEnabled = !xpEventEnabled; + } + + public void debug(String message) { + getLogger().info("[Debug] " + message); + } + + /** + * Setup the various storage file paths + */ + private void setupFilePaths() { + mcmmo = getFile(); + mainDirectory = getDataFolder().getPath() + File.separator; + flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator; + usersFile = flatFileDirectory + "mcmmo.users"; + modDirectory = mainDirectory + "ModConfigs" + File.separator; + } + + private void checkForUpdates() { + if (Config.getInstance().getUpdateCheckEnabled()) { + try { + updateAvailable = UpdateChecker.updateAvailable(); + } + catch (Exception e) { + updateAvailable = false; + } + + if (updateAvailable) { + getLogger().info(LocaleLoader.getString("UpdateChecker.outdated")); + getLogger().info(LocaleLoader.getString("UpdateChecker.newavailable")); + } + } + } + + private void loadConfigFiles() { + // Force the loading of config files + Config configInstance = Config.getInstance(); + TreasureConfig.getInstance(); + HiddenConfig.getInstance(); + AdvancedConfig.getInstance(); + new ChildConfig(); + + List repairables = new ArrayList(); + + if (configInstance.getToolModsEnabled()) { + repairables.addAll(CustomToolConfig.getInstance().getLoadedRepairables()); + } + + if (configInstance.getArmorModsEnabled()) { + repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables()); + } + + if (configInstance.getBlockModsEnabled()) { + CustomBlockConfig.getInstance(); + } + + if (configInstance.getEntityModsEnabled()) { + CustomEntityConfig.getInstance(); + } + + // Load repair configs, make manager, and register them at this time + RepairConfigManager rManager = new RepairConfigManager(this); + repairables.addAll(rManager.getLoadedRepairables()); + repairManager = RepairManagerFactory.getRepairManager(repairables.size()); + repairManager.registerRepairables(repairables); + + // Check if Repair Anvil and Salvage Anvil have different itemID's + if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) { + getLogger().warning("Can't use the same itemID for Repair/Salvage Anvils!"); + } + } + + private void setupSpout() { + // Check for Spout + if (getServer().getPluginManager().isPluginEnabled("Spout")) { + spoutEnabled = true; + + SpoutConfig.getInstance(); + SpoutUtils.setupSpoutConfigs(); + SpoutUtils.registerCustomEvent(); + SpoutUtils.preCacheFiles(); + SpoutUtils.reloadSpoutPlayers(); // Handle spout players after a /reload + } + } + + private void registerEvents() { + PluginManager pluginManager = getServer().getPluginManager(); + + // Register events + pluginManager.registerEvents(playerListener, this); + pluginManager.registerEvents(blockListener, this); + pluginManager.registerEvents(entityListener, this); + pluginManager.registerEvents(inventoryListener, this); + pluginManager.registerEvents(worldListener, this); + } + + /** + * Register the commands. + */ + private void registerCommands() { + CommandRegistrationManager.registerSkillCommands(); + + // mc* commands + CommandRegistrationManager.registerMcpurgeCommand(); + CommandRegistrationManager.registerMcremoveCommand(); + CommandRegistrationManager.registerMcabilityCommand(); + CommandRegistrationManager.registerMcgodCommand(); + CommandRegistrationManager.registerMcmmoCommand(); + CommandRegistrationManager.registerMcrefreshCommand(); + CommandRegistrationManager.registerMctopCommand(); + CommandRegistrationManager.registerMcrankCommand(); + CommandRegistrationManager.registerMcstatsCommand(); + + // Party commands + CommandRegistrationManager.registerAdminChatCommand(); + CommandRegistrationManager.registerPartyCommand(); + CommandRegistrationManager.registerPartyChatCommand(); + CommandRegistrationManager.registerPtpCommand(); + + // Other commands + CommandRegistrationManager.registerAddxpCommand(); + CommandRegistrationManager.registerAddlevelsCommand(); + CommandRegistrationManager.registerMmoeditCommand(); + CommandRegistrationManager.registerInspectCommand(); + CommandRegistrationManager.registerXprateCommand(); + CommandRegistrationManager.registerMmoupdateCommand(); + CommandRegistrationManager.registerSkillresetCommand(); + CommandRegistrationManager.registerHardcoreCommand(); + CommandRegistrationManager.registerVampirismCommand(); + CommandRegistrationManager.registerMcnotifyCommand(); + + // Spout commands + CommandRegistrationManager.registerXplockCommand(); + CommandRegistrationManager.registerMchudCommand(); + } + + private void scheduleTasks() { + BukkitScheduler scheduler = getServer().getScheduler(); + + // Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException + scheduler.scheduleSyncDelayedTask(this, new PartyLoaderTask(), 0); + + // Periodic save timer (Saves every 10 minutes by default) + long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200; + + scheduler.scheduleSyncRepeatingTask(this, new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks); + // Regen & Cooldown timer (Runs every second) + scheduler.scheduleSyncRepeatingTask(this, new SkillMonitorTask(), 20, 20); + // Bleed timer (Runs every two seconds) + scheduler.scheduleSyncRepeatingTask(this, new BleedTimerTask(), 40, 40); + + // Old & Powerless User remover + int purgeInterval = Config.getInstance().getPurgeInterval(); + + if (purgeInterval == 0) { + scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); // Start 2 seconds after startup. + } + else if (purgeInterval > 0) { + long purgeIntervalTicks = purgeInterval * 60 * 60 * 20; + + scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks); + } + + // Automatically remove old members from parties + long kickInterval = Config.getInstance().getAutoPartyKickInterval(); + + if (kickInterval == 0) { + scheduler.scheduleSyncDelayedTask(this, new PartyAutoKickTask(), 40); // Start 2 seconds after startup. + } + else if (kickInterval > 0) { + long kickIntervalTicks = kickInterval * 60 * 60 * 20; + + scheduler.scheduleSyncRepeatingTask(this, new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java b/src/main/java/com/gmail/nossr50/metrics/MetricsManager.java similarity index 95% rename from src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java rename to src/main/java/com/gmail/nossr50/metrics/MetricsManager.java index 758248b5f..a8db9f42d 100644 --- a/src/main/java/com/gmail/nossr50/util/metrics/MetricsManager.java +++ b/src/main/java/com/gmail/nossr50/metrics/MetricsManager.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.util.metrics; +package com.gmail.nossr50.metrics; import java.io.BufferedReader; import java.io.IOException; @@ -9,12 +9,12 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.locale.LocaleLoader; - import com.turt2live.metrics.EMetrics; import com.turt2live.metrics.Metrics; import com.turt2live.metrics.Metrics.Graph; +import com.turt2live.metrics.data.DataEvent; +import com.turt2live.metrics.data.DataTracker; import com.turt2live.metrics.tracker.Tracker; -import com.turt2live.metrics.data.*; public class MetricsManager { private static boolean setup = false; @@ -81,16 +81,19 @@ public class MetricsManager { int startIndex = version.indexOf("-"); if (version.substring(startIndex + 1).contains("-")) { subVersion = version.substring(startIndex, version.indexOf("-", startIndex + 1)); - } else { + } + else { subVersion = "-release"; } - } else { + } + else { subVersion = "-custom"; } version = majorVersion + "~=~" + subVersion; haveVersionInformation = true; - } else { + } + else { haveVersionInformation = false; } @@ -221,7 +224,7 @@ public class MetricsManager { }); } - //GlobalCurveModifier Fuzzy Logic Numbers + // GlobalCurveModifier Fuzzy Logic Numbers Graph globalCurveMultiplierGraphFuzzy = metrics.createGraph("Global Curve Multiplier Fuzz"); if (Config.getInstance().getFormulaMultiplierCurve() > 20.0) { @@ -298,11 +301,12 @@ public class MetricsManager { }); } - /* Debug stuff - tracker = emetrics.getDataTracker(); - tracker.enable(); - tracker.setFilter(new DataEvent.DataType [] { DataEvent.DataType.SEND_DATA }); - */ + /* + * Debug stuff + * tracker = emetrics.getDataTracker(); + * tracker.enable(); + * tracker.setFilter(new DataEvent.DataType [] { DataEvent.DataType.SEND_DATA }); + */ emetrics.startMetrics(); } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index fabf61c1d..28f1acd07 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -10,12 +10,13 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; public final class PartyManager { private static String partiesFilePath = mcMMO.p.getDataFolder().getPath() + File.separator + "FlatFileStuff" + File.separator + "parties.yml"; @@ -46,8 +47,8 @@ public final class PartyManager { * @return true if they are in the same party, false otherwise */ public static boolean inSameParty(Player firstPlayer, Player secondPlayer) { - McMMOPlayer firstMcMMOPlayer = Users.getPlayer(firstPlayer); - McMMOPlayer secondMcMMOPlayer = Users.getPlayer(secondPlayer); + McMMOPlayer firstMcMMOPlayer = UserManager.getPlayer(firstPlayer); + McMMOPlayer secondMcMMOPlayer = UserManager.getPlayer(secondPlayer); if (firstMcMMOPlayer == null || secondMcMMOPlayer == null) { return false; @@ -82,34 +83,6 @@ public final class PartyManager { return nearMembers; } - /** - * Notify party members when a player joins - * - * @param player The player that joins - * @param party The concerned party - */ - private static void informPartyMembersJoin(OfflinePlayer player, Party party) { - for (Player member : party.getOnlineMembers()) { - if (!member.equals(player)) { - member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName())); - } - } - } - - /** - * Notify party members when a party member quits. - * - * @param player The player that quits - * @param party The concerned party - */ - private static void informPartyMembersQuit(OfflinePlayer player, Party party) { - for (Player member : party.getOnlineMembers()) { - if (!member.equals(player)) { - member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", player.getName())); - } - } - } - /** * Get a list of all players in this player's party. * @@ -117,7 +90,7 @@ public final class PartyManager { * @return all the players in the player's party */ public static List getAllMembers(Player player) { - Party party = Users.getPlayer(player).getParty(); + Party party = UserManager.getPlayer(player).getParty(); if (party == null) { return null; @@ -154,7 +127,7 @@ public final class PartyManager { /** * Retrieve a party by its name - * + * * @param partyName The party name * @return the existing party, null otherwise */ @@ -170,7 +143,7 @@ public final class PartyManager { /** * Retrieve a party by a member name - * + * * @param playerName The member name * @return the existing party, null otherwise */ @@ -210,7 +183,7 @@ public final class PartyManager { parties.remove(party); } else { - //If the leaving player was the party leader, appoint a new leader from the party members + // If the leaving player was the party leader, appoint a new leader from the party members if (party.getLeader().equals(player.getName())) { String newLeader = members.get(0).getName(); party.setLeader(newLeader); @@ -219,8 +192,8 @@ public final class PartyManager { informPartyMembersQuit(player, party); } - McMMOPlayer mcMMOPlayer = Users.getPlayer(player.getName()); - + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player.getName()); + if (mcMMOPlayer != null) { mcMMOPlayer.removeParty(); mcMMOPlayer.setItemShareModifier(10); @@ -236,7 +209,7 @@ public final class PartyManager { List members = party.getMembers(); for (OfflinePlayer member : members) { - McMMOPlayer mcMMOPlayer = Users.getPlayer(member.getName()); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(member.getName()); if (mcMMOPlayer != null) { mcMMOPlayer.removeParty(); @@ -338,7 +311,7 @@ public final class PartyManager { /** * Accept a party invitation - * + * * @param Player The plaer to add to the party * @param mcMMOPlayer The player to add to the party */ @@ -360,7 +333,7 @@ public final class PartyManager { /** * Add a player to a party - * + * * @param player The player to add to a party * @param mcMMOPlayer The player to add to the party * @param party The party @@ -460,7 +433,8 @@ public final class PartyManager { try { partiesFile.load(file); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } @@ -517,7 +491,8 @@ public final class PartyManager { try { partiesFile.save(new File(partiesFilePath)); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } } @@ -538,4 +513,32 @@ public final class PartyManager { return !event.isCancelled(); } + + /** + * Notify party members when a player joins + * + * @param player The player that joins + * @param party The concerned party + */ + private static void informPartyMembersJoin(OfflinePlayer player, Party party) { + for (Player member : party.getOnlineMembers()) { + if (!member.equals(player)) { + member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName())); + } + } + } + + /** + * Notify party members when a party member quits. + * + * @param player The player that quits + * @param party The concerned party + */ + private static void informPartyMembersQuit(OfflinePlayer player, Party party) { + for (Player member : party.getOnlineMembers()) { + if (!member.equals(player)) { + member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", player.getName())); + } + } + } } diff --git a/src/main/java/com/gmail/nossr50/party/ShareHandler.java b/src/main/java/com/gmail/nossr50/party/ShareHandler.java index d00f63bb2..878cbdc9f 100644 --- a/src/main/java/com/gmail/nossr50/party/ShareHandler.java +++ b/src/main/java/com/gmail/nossr50/party/ShareHandler.java @@ -8,12 +8,13 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.ItemWeightsConfig; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.config.party.ItemWeightConfig; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; public final class ShareHandler { public enum ShareMode { @@ -51,32 +52,35 @@ public final class ShareHandler { Party party = mcMMOPlayer.getParty(); switch (party.getXpShareMode()) { - case EQUAL: - Player player = mcMMOPlayer.getPlayer(); - nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); + case EQUAL: + Player player = mcMMOPlayer.getPlayer(); + nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); - if (nearMembers.isEmpty()) { + if (nearMembers.isEmpty()) { + return false; + } + + double partySize = nearMembers.size() + 1; + double shareBonus = Config.getInstance().getPartyShareBonusBase() + partySize * Config.getInstance().getPartyShareBonusIncrease(); + + if (shareBonus > Config.getInstance().getPartyShareBonusCap()) { + shareBonus = Config.getInstance().getPartyShareBonusCap(); + } + + double splitXp = xp / partySize * shareBonus; + int roundedXp = (int) Math.ceil(splitXp); + + for (Player member : nearMembers) { + UserManager.getPlayer(member).beginUnsharedXpGain(skillType, roundedXp); + } + + mcMMOPlayer.beginUnsharedXpGain(skillType, roundedXp); + + return true; + case NONE: + // Fallthrough + default: return false; - } - - double partySize = nearMembers.size() + 1; - double shareBonus = Config.getInstance().getPartyShareBonusBase() + partySize * Config.getInstance().getPartyShareBonusIncrease(); - if (shareBonus > Config.getInstance().getPartyShareBonusCap()) { - shareBonus = Config.getInstance().getPartyShareBonusCap(); - } - double splitXp = xp / partySize * shareBonus; - int roundedXp = (int) Math.ceil(splitXp); - - for (Player member : nearMembers) { - Users.getPlayer(member).beginUnsharedXpGain(skillType, roundedXp); - } - - mcMMOPlayer.beginUnsharedXpGain(skillType, roundedXp); - - return true; - case NONE: - default: - return false; } } @@ -97,94 +101,101 @@ public final class ShareHandler { ItemStack newStack = itemStack.clone(); newStack.setAmount(1); - if (ItemChecks.isMobDrop(itemStack) && !party.sharingLootDrops()) { + if (ItemUtils.isMobDrop(itemStack) && !party.sharingLootDrops()) { return false; } - else if (ItemChecks.isMiningDrop(itemStack) && !party.sharingMiningDrops()) { + else if (ItemUtils.isMiningDrop(itemStack) && !party.sharingMiningDrops()) { return false; } - else if (ItemChecks.isHerbalismDrop(itemStack) && !party.sharingHerbalismDrops()) { + else if (ItemUtils.isHerbalismDrop(itemStack) && !party.sharingHerbalismDrops()) { return false; } - else if (ItemChecks.isWoodcuttingDrop(itemStack) && !party.sharingWoodcuttingDrops()) { + else if (ItemUtils.isWoodcuttingDrop(itemStack) && !party.sharingWoodcuttingDrops()) { return false; } switch (party.getItemShareMode()) { - case EQUAL: - McMMOPlayer mcMMOTarget; - nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); + case EQUAL: + McMMOPlayer mcMMOTarget; + nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); - if (nearMembers.isEmpty()) { - return false; - } - nearMembers.add(player); - partySize = nearMembers.size(); + if (nearMembers.isEmpty()) { + return false; + } - event.setCancelled(true); - item.remove(); - int itemWeight = ItemWeightsConfig.getInstance().getItemWeight(itemStack.getType()); + nearMembers.add(player); + partySize = nearMembers.size(); - for (int i = 0; i < itemStack.getAmount(); i++) { - int highestRoll = 0; + event.setCancelled(true); + item.remove(); + int itemWeight = ItemWeightConfig.getInstance().getItemWeight(itemStack.getType()); - for (Player member : nearMembers) { - McMMOPlayer mcMMOMember = Users.getPlayer(member); - int itemShareModifier = mcMMOMember.getItemShareModifier(); - int diceRoll = Misc.getRandom().nextInt(itemShareModifier); + for (int i = 0; i < itemStack.getAmount(); i++) { + int highestRoll = 0; - if (diceRoll > highestRoll) { - highestRoll = diceRoll; + for (Player member : nearMembers) { + McMMOPlayer mcMMOMember = UserManager.getPlayer(member); + int itemShareModifier = mcMMOMember.getItemShareModifier(); + int diceRoll = Misc.getRandom().nextInt(itemShareModifier); - if (winningPlayer != null) { - McMMOPlayer mcMMOWinning = Users.getPlayer(winningPlayer); - mcMMOWinning.setItemShareModifier(mcMMOWinning.getItemShareModifier() + itemWeight); + if (diceRoll > highestRoll) { + highestRoll = diceRoll; + + if (winningPlayer != null) { + McMMOPlayer mcMMOWinning = UserManager.getPlayer(winningPlayer); + mcMMOWinning.setItemShareModifier(mcMMOWinning.getItemShareModifier() + itemWeight); + } + + winningPlayer = member; } + else { + mcMMOMember.setItemShareModifier(itemShareModifier + itemWeight); + } + } - winningPlayer = member; + mcMMOTarget = UserManager.getPlayer(winningPlayer); + mcMMOTarget.setItemShareModifier(mcMMOTarget.getItemShareModifier() - itemWeight); + + if (winningPlayer.getInventory().addItem(newStack).size() != 0) { + winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), newStack); + } + + winningPlayer.updateInventory(); + } + return true; + case RANDOM: + nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); + + if (nearMembers.isEmpty()) { + return false; + } + + partySize = nearMembers.size() + 1; + + event.setCancelled(true); + item.remove(); + + for (int i = 0; i < itemStack.getAmount(); i++) { + int randomMember = Misc.getRandom().nextInt(partySize); + + if (randomMember >= nearMembers.size()) { + winningPlayer = player; } else { - mcMMOMember.setItemShareModifier(itemShareModifier + itemWeight); + winningPlayer = nearMembers.get(randomMember); } + + if (winningPlayer.getInventory().addItem(newStack).size() != 0) { + winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), newStack); + } + + winningPlayer.updateInventory(); } - - mcMMOTarget = Users.getPlayer(winningPlayer); - mcMMOTarget.setItemShareModifier(mcMMOTarget.getItemShareModifier() - itemWeight); - - if (winningPlayer.getInventory().addItem(newStack).size() != 0) { - winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), newStack); - } - winningPlayer.updateInventory(); - } - return true; - case RANDOM: - nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); - - if (nearMembers.isEmpty()) { + return true; + case NONE: + // Fallthrough + default: return false; - } - partySize = nearMembers.size() + 1; - - event.setCancelled(true); - item.remove(); - - for (int i = 0; i < itemStack.getAmount(); i++) { - int randomMember = Misc.getRandom().nextInt(partySize); - if (randomMember >= nearMembers.size()) { - winningPlayer = player; - } else { - winningPlayer = nearMembers.get(randomMember); - } - - if (winningPlayer.getInventory().addItem(newStack).size() != 0) { - winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), newStack); - } - winningPlayer.updateInventory(); - } - return true; - case NONE: - default: - return false; } } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyAcceptCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyAcceptCommand.java deleted file mode 100644 index ee2a2c7cc..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyAcceptCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyAcceptCommand implements CommandExecutor { - private McMMOPlayer mcMMOPlayer; - private Player player; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - player = (Player) sender; - mcMMOPlayer = Users.getPlayer(player); - - if (!mcMMOPlayer.hasPartyInvite()) { - sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); - return true; - } - - - // Changing parties - if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) { - return true; - } - - PartyManager.joinInvitedParty(player, mcMMOPlayer); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept")); - return true; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java deleted file mode 100644 index 7db6ac2d1..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyChangeOwnerCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - Party playerParty = Users.getPlayer((Player) sender).getParty(); - - if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) { - sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); - return true; - } - - PartyManager.setPartyLeader(args[1], playerParty); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); - return true; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java deleted file mode 100644 index 59d27593d..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.chat.commands.PartyChatCommand; -import com.gmail.nossr50.commands.CommandHelper; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class PartyCommand implements CommandExecutor { - private McMMOPlayer mcMMOPlayer; - private Player player; - - private CommandExecutor partyJoinCommand = new PartyJoinCommand(); - private CommandExecutor partyAcceptCommand = new PartyAcceptCommand(); - private CommandExecutor partyCreateCommand = new PartyCreateCommand(); - private CommandExecutor partyQuitCommand = new PartyQuitCommand(); - private CommandExecutor partyExpShareCommand = new PartyExpShareCommand(); - private CommandExecutor partyItemShareCommand = new PartyItemShareCommand(); - private CommandExecutor partyInviteCommand = new PartyInviteCommand(); - private CommandExecutor partyKickCommand = new PartyKickCommand(); - private CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); - private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); - private CommandExecutor partyLockCommand = new PartyLockCommand(); - private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); - private CommandExecutor partyRenameCommand = new PartyRenameCommand(); - private CommandExecutor partyInfoCommand = new PartyInfoCommand(); - private CommandExecutor partyHelpCommand = new PartyHelpCommand(); - private CommandExecutor partyTeleportCommand = new PtpCommand(); - private CommandExecutor partyChatCommand = new PartyChatCommand(); - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noConsoleUsage(sender)) { - return true; - } - - if (!Permissions.party(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - player = (Player) sender; - mcMMOPlayer = Users.getPlayer(player); - - if (args.length < 1) { - if (!mcMMOPlayer.inParty()) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); - return printUsage(); - } - - return partyInfoCommand.onCommand(sender, command, label, args); - } - - PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]); - - if (subcommand == null) { - return printUsage(); - } - - // Can't use this for lock/unlock since they're handled by the same command - if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !Permissions.partySubcommand(sender, subcommand)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - switch (subcommand) { - case JOIN: - return partyJoinCommand.onCommand(sender, command, label, args); - case ACCEPT: - return partyAcceptCommand.onCommand(sender, command, label, args); - case CREATE: - return partyCreateCommand.onCommand(sender, command, label, args); - case HELP: - return partyHelpCommand.onCommand(sender, command, label, args); - default: - break; - } - - // Party member commands - if (!mcMMOPlayer.inParty()) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); - return printUsage(); - } - - switch (subcommand) { - case INFO: - return partyInfoCommand.onCommand(sender, command, label, args); - case QUIT: - return partyQuitCommand.onCommand(sender, command, label, args); - case INVITE: - return partyInviteCommand.onCommand(sender, command, label, args); - case TELEPORT: - return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args)); - case CHAT: - return partyChatCommand.onCommand(sender, command, label, extractArgs(args)); - default: - break; - } - - // Party leader commands - if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) { - sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } - - switch (subcommand) { - case EXPSHARE: - return partyExpShareCommand.onCommand(sender, command, label, args); - case ITEMSHARE: - return partyItemShareCommand.onCommand(sender, command, label, args); - case KICK: - return partyKickCommand.onCommand(sender, command, label, args); - case DISBAND: - return partyDisbandCommand.onCommand(sender, command, label, args); - case OWNER: - return partyChangeOwnerCommand.onCommand(sender, command, label, args); - case LOCK: - case UNLOCK: - return partyLockCommand.onCommand(sender, command, label, args); - case PASSWORD: - return partyChangePasswordCommand.onCommand(sender, command, label, args); - case RENAME: - return partyRenameCommand.onCommand(sender, command, label, args); - default: - break; - } - - return true; - } - - private boolean printUsage() { - player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join")); - player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); - player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?")); - return true; - } - - private String[] extractArgs(String[] args) { - String[] newArgs = new String[args.length - 1]; - - for (int i = 1; i < args.length; i++) { - newArgs[i - 1] = args[1]; - } - - return newArgs; - } -} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCreateCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCreateCommand.java deleted file mode 100644 index 2fe97aaa2..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCreateCommand.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyCreateCommand implements CommandExecutor { - private McMMOPlayer mcMMOPlayer; - private Player player; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - case 3: - Party newParty = PartyManager.getParty(args[1]); - - // Check to see if the party exists, and if it does cancel creating a new party - if (newParty != null) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", args[1])); - return true; - } - - player = (Player) sender; - mcMMOPlayer = Users.getPlayer(player); - - // Changing parties - if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) { - return true; - } - - PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args)); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "create", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); - return true; - } - } - - private String getPassword(String[] args) { - if (args.length == 3) { - return args[2]; - } - - return null; - } -} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java deleted file mode 100644 index 38bb40842..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyDisbandCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - Party playerParty = Users.getPlayer((Player) sender).getParty(); - - for (Player member : playerParty.getOnlineMembers()) { - if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) { - return true; - } - - member.sendMessage(LocaleLoader.getString("Party.Disband")); - } - - PartyManager.disbandParty(playerParty); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband")); - return true; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java deleted file mode 100644 index 0531f6ffa..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import com.gmail.nossr50.locale.LocaleLoader; - -public class PartyHelpCommand implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); - sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); - sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); - sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); - sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); - sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader")); - sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help")); - return true; - } - } - -} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java deleted file mode 100644 index 9e851a94e..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyInviteCommand implements CommandExecutor { - private McMMOPlayer mcMMOTarget; - private Player target; - - private McMMOPlayer mcMMOPlayer; - private Player player; - private Party playerParty; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - if (!mcMMO.p.getServer().getOfflinePlayer(args[1]).isOnline()) { - sender.sendMessage(LocaleLoader.getString("Party.NotOnline", args[1])); - return true; - } - - mcMMOTarget = Users.getPlayer(args[1]); - - if (mcMMOTarget == null) { - sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); - return true; - } - - target = mcMMOTarget.getPlayer(); - mcMMOPlayer = Users.getPlayer((Player) sender); - player = mcMMOPlayer.getPlayer(); - - if (player.equals(target)) { - sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); - return true; - } - - if (PartyManager.inSameParty(player, target)) { - sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName())); - return true; - } - - playerParty = mcMMOPlayer.getParty(); - - if (!PartyManager.canInvite(player, playerParty)) { - player.sendMessage(LocaleLoader.getString("Party.Locked")); - return true; - } - - mcMMOTarget.setPartyInvite(playerParty); - - sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); - target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), player.getName())); - target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1")); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); - return true; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java deleted file mode 100644 index b63856376..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.ShareHandler; -import com.gmail.nossr50.party.ShareHandler.ShareMode; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; - -public class PartyItemShareCommand implements CommandExecutor { - private Party playerParty; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!Config.getInstance().getItemShareEnabled()) { - sender.sendMessage(LocaleLoader.getString("Party.ItemShare.Disabled")); - return true; - } - - switch (args.length) { - case 2: - playerParty = Users.getPlayer((Player) sender).getParty(); - - if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { - handleChangingShareMode(ShareMode.NONE); - } - else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) { - handleChangingShareMode(ShareMode.EQUAL); - } - else if (args[1].equalsIgnoreCase("random")) { - handleChangingShareMode(ShareMode.RANDOM); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); - } - - return true; - - case 3: - playerParty = Users.getPlayer((Player) sender).getParty(); - boolean toggle = false; - - if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("on")|| args[2].equalsIgnoreCase("enabled")) { - toggle = true; - } - else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("off")|| args[2].equalsIgnoreCase("disabled")) { - toggle = false; - } - - if (args[1].equalsIgnoreCase("loot")) { - playerParty.setSharingLootDrops(toggle); - } - else if (args[1].equalsIgnoreCase("mining")) { - playerParty.setSharingMiningDrops(toggle); - } - else if (args[1].equalsIgnoreCase("herbalism")) { - playerParty.setSharingHerbalismDrops(toggle); - } - else if (args[1].equalsIgnoreCase("woodcutting")) { - playerParty.setSharingWoodcuttingDrops(toggle); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); - } - notifyToggleItemShareCategory(args, toggle); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); - return true; - } - } - - private void handleChangingShareMode(ShareHandler.ShareMode mode) { - playerParty.setItemShareMode(mode); - - for (Player member : playerParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())))); - } - } - - private void notifyToggleItemShareCategory(String[] args, boolean toggle) { - String state = "disabled"; - - if (toggle) { - state = "enabled"; - } - - for (Player member : playerParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(args[1]), state)); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java deleted file mode 100644 index e74d25bcf..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyKickCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - Party playerParty = Users.getPlayer((Player) sender).getParty(); - - OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]); - - if (!playerParty.getMembers().contains(target)) { - sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); - return true; - } - - if (target.isOnline()) { - Player onlineTarget = target.getPlayer(); - String partyName = playerParty.getName(); - - if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) { - return true; - } - - onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); - } - - PartyManager.removeFromParty(target, playerParty); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); - return true; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyQuitCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyQuitCommand.java deleted file mode 100644 index 6af61eb1d..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyQuitCommand.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyQuitCommand implements CommandExecutor { - private Player player; - private Party playerParty; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - player = (Player) sender; - playerParty = Users.getPlayer(player).getParty(); - - if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { - return true; - } - - PartyManager.removeFromParty(player, playerParty); - sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave")); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "[quit|q|leave]")); - return true; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyRenameCommand.java deleted file mode 100644 index a4f4ed0fb..000000000 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyRenameCommand.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.gmail.nossr50.party.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; - -public class PartyRenameCommand implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - Party playerParty = Users.getPlayer((Player) sender).getParty(); - String leaderName = playerParty.getLeader(); - - switch (args.length) { - case 2: - String newPartyName = args[1]; - - // This is to prevent party leaders from spamming other players with the rename message - if (playerParty.getName().equalsIgnoreCase(newPartyName)) { - sender.sendMessage(LocaleLoader.getString("Party.Rename.Same")); - return true; - } - - Party newParty = PartyManager.getParty(newPartyName); - - // Check to see if the party exists, and if it does cancel renaming the party - if (newParty != null) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", newPartyName)); - return true; - } - - for (Player member : playerParty.getOnlineMembers()) { - if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) { - return true; - } - - if (!member.getName().equals(leaderName)) { - member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName)); - } - } - - playerParty.setName(newPartyName); - - sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName)); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">")); - return true; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/runnables/ProfileSaveTask.java b/src/main/java/com/gmail/nossr50/runnables/ProfileSaveTask.java deleted file mode 100644 index e778d41cc..000000000 --- a/src/main/java/com/gmail/nossr50/runnables/ProfileSaveTask.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.gmail.nossr50.runnables; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.util.Users; - -public class ProfileSaveTask implements Runnable { - private McMMOPlayer mcMMOPlayer; - private PlayerProfile playerProfile; - - public ProfileSaveTask(McMMOPlayer mcMMOPlayer) { - this.mcMMOPlayer = mcMMOPlayer; - this.playerProfile = mcMMOPlayer.getProfile(); - } - - @Override - public void run() { - playerProfile.save(); - - if (!mcMMOPlayer.getPlayer().isOnline()) { - Users.remove(playerProfile.getPlayerName()); - } - } -} diff --git a/src/main/java/com/gmail/nossr50/runnables/SaveTimer.java b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java similarity index 52% rename from src/main/java/com/gmail/nossr50/runnables/SaveTimer.java rename to src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java index 5929b2ed1..8a1af3760 100644 --- a/src/main/java/com/gmail/nossr50/runnables/SaveTimer.java +++ b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java @@ -3,19 +3,20 @@ package com.gmail.nossr50.runnables; import org.bukkit.scheduler.BukkitScheduler; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask; +import com.gmail.nossr50.util.player.UserManager; -public class SaveTimer implements Runnable { +public class SaveTimerTask implements Runnable { @Override public void run() { - //All player data will be saved periodically through this + // All player data will be saved periodically through this int count = 1; BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler(); - for (McMMOPlayer mcMMOPlayer : Users.getPlayers().values()) { - bukkitScheduler.scheduleSyncDelayedTask(mcMMO.p, new ProfileSaveTask(mcMMOPlayer), count); + for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) { + bukkitScheduler.scheduleSyncDelayedTask(mcMMO.p, new PlayerProfileSaveTask(mcMMOPlayer), count); count++; } diff --git a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTracker.java b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java similarity index 85% rename from src/main/java/com/gmail/nossr50/runnables/StickyPistonTracker.java rename to src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java index c2d325505..fcdda3c43 100644 --- a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTracker.java +++ b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java @@ -6,10 +6,10 @@ import org.bukkit.event.block.BlockPistonRetractEvent; import com.gmail.nossr50.mcMMO; -public class StickyPistonTracker implements Runnable { +public class StickyPistonTrackerTask implements Runnable { BlockPistonRetractEvent event; - public StickyPistonTracker(BlockPistonRetractEvent event) { + public StickyPistonTrackerTask(BlockPistonRetractEvent event) { this.event = event; } diff --git a/src/main/java/com/gmail/nossr50/runnables/McRankAsync.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java similarity index 74% rename from src/main/java/com/gmail/nossr50/runnables/McRankAsync.java rename to src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java index 4883d4fdc..85ff65364 100644 --- a/src/main/java/com/gmail/nossr50/runnables/McRankAsync.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.runnables; +package com.gmail.nossr50.runnables.commands; import java.util.Map; @@ -6,23 +6,23 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.database.Database; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.skills.SkillUtils; -public class McRankAsync implements Runnable { +public class McrankCommandAsyncTask implements Runnable { private final String playerName; private final CommandSender sender; - public McRankAsync(String playerName, CommandSender sender) { + public McrankCommandAsyncTask(String playerName, CommandSender sender) { this.playerName = playerName; this.sender = sender; } @Override public void run() { - final Map skills = Database.readSQLRank(playerName); + final Map skills = DatabaseManager.readSQLRank(playerName); Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { @Override @@ -36,10 +36,10 @@ public class McRankAsync implements Runnable { } if (skills.get(skillType.name()) == null) { - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); } else { - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), skills.get(skillType.name()))); + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), skills.get(skillType.name()))); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/McTopAsync.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java similarity index 79% rename from src/main/java/com/gmail/nossr50/runnables/McTopAsync.java rename to src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java index b62a67864..9d04d98c6 100644 --- a/src/main/java/com/gmail/nossr50/runnables/McTopAsync.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.runnables; +package com.gmail.nossr50.runnables.commands; import java.util.ArrayList; import java.util.HashMap; @@ -10,20 +10,20 @@ import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.Database; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; -public class McTopAsync implements Runnable { +public class MctopCommandAsyncTask implements Runnable { private CommandSender sender; private String query; private int page; private Command command; - public McTopAsync(int page, String query, CommandSender sender, Command command) { + public MctopCommandAsyncTask(int page, String query, CommandSender sender, Command command) { this.page = page; this.query = query; this.sender = sender; @@ -39,13 +39,14 @@ public class McTopAsync implements Runnable { } } String tablePrefix = Config.getInstance().getMySQLTablePrefix(); - final HashMap> userslist = Database.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT " + ((page * 10) - 10) + ",10"); + final HashMap> userslist = DatabaseManager.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT " + ((page * 10) - 10) + ",10"); Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { @Override public void run() { if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); - } else { + } + else { sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query))); } diff --git a/src/main/java/com/gmail/nossr50/database/runnables/SQLConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java similarity index 87% rename from src/main/java/com/gmail/nossr50/database/runnables/SQLConversionTask.java rename to src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java index 666222e87..8297772f7 100644 --- a/src/main/java/com/gmail/nossr50/database/runnables/SQLConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java @@ -1,285 +1,277 @@ -package com.gmail.nossr50.database.runnables; - -import java.io.BufferedReader; -import java.io.FileReader; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.Database; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.StringUtils; - -public class SQLConversionTask implements Runnable { - private String tablePrefix = Config.getInstance().getMySQLTablePrefix(); - - @Override - public void run() { - String location = mcMMO.getUsersFilePath(); - - try { - FileReader file = new FileReader(location); - BufferedReader in = new BufferedReader(file); - String line = ""; - String playerName = null; - //String party = null; - String mining = null; - String woodcutting = null; - String repair = null; - String unarmed = null; - String herbalism = null; - String excavation = null; - String archery = null; - String swords = null; - String axes = null; - String acrobatics = null; - String taming = null; - String fishing = null; - String miningXP = null; - String woodCuttingXP = null; - String repairXP = null; - String unarmedXP = null; - String herbalismXP = null; - String excavationXP = null; - String archeryXP = null; - String swordsXP = null; - String axesXP = null; - String acrobaticsXP = null; - String tamingXP = null; - String fishingXP = null; - int id = 0; - int theCount = 0; - - while ((line = in.readLine()) != null) { - - //Find if the line contains the player we want. - String[] character = line.split(":"); - playerName = character[0]; - - //Check for things we don't want put in the DB - if (playerName == null || playerName.equals("null") || playerName.equals("#Storage place for user information")) { - continue; - } - - if (character.length > 1) { - mining = character[1]; - } - - /* - * Looks like we still have party as the 4th string in the array but we don't use it anymore - if (character.length > 3) { - party = character[3]; - } - */ - - if (character.length > 4) { - miningXP = character[4]; - } - - if (character.length > 5) { - woodcutting = character[5]; - } - - if (character.length > 6) { - woodCuttingXP = character[6]; - } - - if (character.length > 7) { - repair = character[7]; - } - - if (character.length > 8) { - unarmed = character[8]; - } - - if (character.length > 9) { - herbalism = character[9]; - } - - if (character.length > 10) { - excavation = character[10]; - } - - if (character.length > 11) { - archery = character[11]; - } - - if (character.length > 12) { - swords = character[12]; - } - - if (character.length > 13) { - axes = character[13]; - } - - if (character.length > 14) { - acrobatics = character[14]; - } - - if (character.length > 15) { - repairXP = character[15]; - } - - if (character.length > 16) { - unarmedXP = character[16]; - } - - if (character.length > 17) { - herbalismXP = character[17]; - } - - if (character.length > 18) { - excavationXP = character[18]; - } - - if (character.length > 19) { - archeryXP = character[19]; - } - - if (character.length > 20) { - swordsXP = character[20]; - } - - if (character.length > 21) { - axesXP = character[21]; - } - - if (character.length > 22) { - acrobaticsXP = character[22]; - } - - if (character.length > 24) { - taming = character[24]; - } - - if (character.length > 25) { - tamingXP = character[25]; - } - - if (character.length > 34) { - fishing = character[34]; - } - - if (character.length > 35) { - fishingXP = character[35]; - } - - //Check to see if the user is in the DB - id = Database.getInt("SELECT id FROM " - + tablePrefix - + "users WHERE user = '" + playerName + "'"); - - if (id > 0) { - theCount++; - - //Update the skill values - Database.write("UPDATE " - + tablePrefix - + "users SET lastlogin = " + 0 - + " WHERE id = " + id); - Database.write("UPDATE " - + tablePrefix - + "skills SET " - + " taming = taming+" + StringUtils.getInt(taming) - + ", mining = mining+" + StringUtils.getInt(mining) - + ", repair = repair+" + StringUtils.getInt(repair) - + ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting) - + ", unarmed = unarmed+" + StringUtils.getInt(unarmed) - + ", herbalism = herbalism+" + StringUtils.getInt(herbalism) - + ", excavation = excavation+" + StringUtils.getInt(excavation) - + ", archery = archery+" + StringUtils.getInt(archery) - + ", swords = swords+" + StringUtils.getInt(swords) - + ", axes = axes+" + StringUtils.getInt(axes) - + ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics) - + ", fishing = fishing+" + StringUtils.getInt(fishing) - + " WHERE user_id = " + id); - Database.write("UPDATE " - + tablePrefix - + "experience SET " - + " taming = " + StringUtils.getInt(tamingXP) - + ", mining = " + StringUtils.getInt(miningXP) - + ", repair = " + StringUtils.getInt(repairXP) - + ", woodcutting = " + StringUtils.getInt(woodCuttingXP) - + ", unarmed = " + StringUtils.getInt(unarmedXP) - + ", herbalism = " + StringUtils.getInt(herbalismXP) - + ", excavation = " + StringUtils.getInt(excavationXP) - + ", archery = " + StringUtils.getInt(archeryXP) - + ", swords = " + StringUtils.getInt(swordsXP) - + ", axes = " + StringUtils.getInt(axesXP) - + ", acrobatics = " + StringUtils.getInt(acrobaticsXP) - + ", fishing = " + StringUtils.getInt(fishingXP) - + " WHERE user_id = " + id); - } - else { - theCount++; - - //Create the user in the DB - Database.write("INSERT INTO " - + tablePrefix - + "users (user, lastlogin) VALUES ('" - + playerName + "'," - + System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")"); - id = Database.getInt("SELECT id FROM " - + tablePrefix - + "users WHERE user = '" - + playerName + "'"); - Database.write("INSERT INTO " - + tablePrefix - + "skills (user_id) VALUES (" + id + ")"); - Database.write("INSERT INTO " - + tablePrefix - + "experience (user_id) VALUES (" + id - + ")"); - //Update the skill values - Database.write("UPDATE " - + tablePrefix - + "users SET lastlogin = " + 0 - + " WHERE id = " + id); - /* - Database.write("UPDATE " - + tablePrefix - + "users SET party = '" + party - + "' WHERE id = " + id); - */ - Database.write("UPDATE " - + tablePrefix - + "skills SET " - + " taming = taming+" + StringUtils.getInt(taming) - + ", mining = mining+" + StringUtils.getInt(mining) - + ", repair = repair+" + StringUtils.getInt(repair) - + ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting) - + ", unarmed = unarmed+" + StringUtils.getInt(unarmed) - + ", herbalism = herbalism+" + StringUtils.getInt(herbalism) - + ", excavation = excavation+" + StringUtils.getInt(excavation) - + ", archery = archery+" + StringUtils.getInt(archery) - + ", swords = swords+" + StringUtils.getInt(swords) - + ", axes = axes+" + StringUtils.getInt(axes) - + ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics) - + ", fishing = fishing+" + StringUtils.getInt(fishing) - + " WHERE user_id = " + id); - Database.write("UPDATE " - + tablePrefix - + "experience SET " - + " taming = " + StringUtils.getInt(tamingXP) - + ", mining = " + StringUtils.getInt(miningXP) - + ", repair = " + StringUtils.getInt(repairXP) - + ", woodcutting = " + StringUtils.getInt(woodCuttingXP) - + ", unarmed = " + StringUtils.getInt(unarmedXP) - + ", herbalism = " + StringUtils.getInt(herbalismXP) - + ", excavation = " + StringUtils.getInt(excavationXP) - + ", archery = " + StringUtils.getInt(archeryXP) - + ", swords = " + StringUtils.getInt(swordsXP) - + ", axes = " + StringUtils.getInt(axesXP) - + ", acrobatics = " + StringUtils.getInt(acrobaticsXP) - + ", fishing = " + StringUtils.getInt(fishingXP) - + " WHERE user_id = " + id); - } - } - - mcMMO.p.getLogger().info("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB"); - in.close(); - } - catch (Exception e) { - mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString()); - } - } -} +package com.gmail.nossr50.runnables.database; + +import java.io.BufferedReader; +import java.io.FileReader; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; + +public class SQLConversionTask implements Runnable { + private String tablePrefix = Config.getInstance().getMySQLTablePrefix(); + + @Override + public void run() { + String location = mcMMO.getUsersFilePath(); + + try { + FileReader file = new FileReader(location); + BufferedReader in = new BufferedReader(file); + String line = ""; + String playerName = null; + String mining = null; + String woodcutting = null; + String repair = null; + String unarmed = null; + String herbalism = null; + String excavation = null; + String archery = null; + String swords = null; + String axes = null; + String acrobatics = null; + String taming = null; + String fishing = null; + String miningXP = null; + String woodCuttingXP = null; + String repairXP = null; + String unarmedXP = null; + String herbalismXP = null; + String excavationXP = null; + String archeryXP = null; + String swordsXP = null; + String axesXP = null; + String acrobaticsXP = null; + String tamingXP = null; + String fishingXP = null; + int id = 0; + int theCount = 0; + + while ((line = in.readLine()) != null) { + + // Find if the line contains the player we want. + String[] character = line.split(":"); + playerName = character[0]; + + // Check for things we don't want put in the DB + if (playerName == null || playerName.equals("null") || playerName.equals("#Storage place for user information")) { + continue; + } + + if (character.length > 1) { + mining = character[1]; + } + + if (character.length > 4) { + miningXP = character[4]; + } + + if (character.length > 5) { + woodcutting = character[5]; + } + + if (character.length > 6) { + woodCuttingXP = character[6]; + } + + if (character.length > 7) { + repair = character[7]; + } + + if (character.length > 8) { + unarmed = character[8]; + } + + if (character.length > 9) { + herbalism = character[9]; + } + + if (character.length > 10) { + excavation = character[10]; + } + + if (character.length > 11) { + archery = character[11]; + } + + if (character.length > 12) { + swords = character[12]; + } + + if (character.length > 13) { + axes = character[13]; + } + + if (character.length > 14) { + acrobatics = character[14]; + } + + if (character.length > 15) { + repairXP = character[15]; + } + + if (character.length > 16) { + unarmedXP = character[16]; + } + + if (character.length > 17) { + herbalismXP = character[17]; + } + + if (character.length > 18) { + excavationXP = character[18]; + } + + if (character.length > 19) { + archeryXP = character[19]; + } + + if (character.length > 20) { + swordsXP = character[20]; + } + + if (character.length > 21) { + axesXP = character[21]; + } + + if (character.length > 22) { + acrobaticsXP = character[22]; + } + + if (character.length > 24) { + taming = character[24]; + } + + if (character.length > 25) { + tamingXP = character[25]; + } + + if (character.length > 34) { + fishing = character[34]; + } + + if (character.length > 35) { + fishingXP = character[35]; + } + + // Check to see if the user is in the DB + id = DatabaseManager.getInt("SELECT id FROM " + + tablePrefix + + "users WHERE user = '" + playerName + "'"); + + if (id > 0) { + theCount++; + + // Update the skill values + DatabaseManager.write("UPDATE " + + tablePrefix + + "users SET lastlogin = " + 0 + + " WHERE id = " + id); + DatabaseManager.write("UPDATE " + + tablePrefix + + "skills SET " + + " taming = taming+" + StringUtils.getInt(taming) + + ", mining = mining+" + StringUtils.getInt(mining) + + ", repair = repair+" + StringUtils.getInt(repair) + + ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting) + + ", unarmed = unarmed+" + StringUtils.getInt(unarmed) + + ", herbalism = herbalism+" + StringUtils.getInt(herbalism) + + ", excavation = excavation+" + StringUtils.getInt(excavation) + + ", archery = archery+" + StringUtils.getInt(archery) + + ", swords = swords+" + StringUtils.getInt(swords) + + ", axes = axes+" + StringUtils.getInt(axes) + + ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics) + + ", fishing = fishing+" + StringUtils.getInt(fishing) + + " WHERE user_id = " + id); + DatabaseManager.write("UPDATE " + + tablePrefix + + "experience SET " + + " taming = " + StringUtils.getInt(tamingXP) + + ", mining = " + StringUtils.getInt(miningXP) + + ", repair = " + StringUtils.getInt(repairXP) + + ", woodcutting = " + StringUtils.getInt(woodCuttingXP) + + ", unarmed = " + StringUtils.getInt(unarmedXP) + + ", herbalism = " + StringUtils.getInt(herbalismXP) + + ", excavation = " + StringUtils.getInt(excavationXP) + + ", archery = " + StringUtils.getInt(archeryXP) + + ", swords = " + StringUtils.getInt(swordsXP) + + ", axes = " + StringUtils.getInt(axesXP) + + ", acrobatics = " + StringUtils.getInt(acrobaticsXP) + + ", fishing = " + StringUtils.getInt(fishingXP) + + " WHERE user_id = " + id); + } + else { + theCount++; + + // Create the user in the DB + DatabaseManager.write("INSERT INTO " + + tablePrefix + + "users (user, lastlogin) VALUES ('" + + playerName + "'," + + System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")"); + id = DatabaseManager.getInt("SELECT id FROM " + + tablePrefix + + "users WHERE user = '" + + playerName + "'"); + DatabaseManager.write("INSERT INTO " + + tablePrefix + + "skills (user_id) VALUES (" + id + ")"); + DatabaseManager.write("INSERT INTO " + + tablePrefix + + "experience (user_id) VALUES (" + id + + ")"); + // Update the skill values + DatabaseManager.write("UPDATE " + + tablePrefix + + "users SET lastlogin = " + 0 + + " WHERE id = " + id); + /* + Database.write("UPDATE " + + tablePrefix + + "users SET party = '" + party + + "' WHERE id = " + id); + */ + DatabaseManager.write("UPDATE " + + tablePrefix + + "skills SET " + + " taming = taming+" + StringUtils.getInt(taming) + + ", mining = mining+" + StringUtils.getInt(mining) + + ", repair = repair+" + StringUtils.getInt(repair) + + ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting) + + ", unarmed = unarmed+" + StringUtils.getInt(unarmed) + + ", herbalism = herbalism+" + StringUtils.getInt(herbalism) + + ", excavation = excavation+" + StringUtils.getInt(excavation) + + ", archery = archery+" + StringUtils.getInt(archery) + + ", swords = swords+" + StringUtils.getInt(swords) + + ", axes = axes+" + StringUtils.getInt(axes) + + ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics) + + ", fishing = fishing+" + StringUtils.getInt(fishing) + + " WHERE user_id = " + id); + DatabaseManager.write("UPDATE " + + tablePrefix + + "experience SET " + + " taming = " + StringUtils.getInt(tamingXP) + + ", mining = " + StringUtils.getInt(miningXP) + + ", repair = " + StringUtils.getInt(repairXP) + + ", woodcutting = " + StringUtils.getInt(woodCuttingXP) + + ", unarmed = " + StringUtils.getInt(unarmedXP) + + ", herbalism = " + StringUtils.getInt(herbalismXP) + + ", excavation = " + StringUtils.getInt(excavationXP) + + ", archery = " + StringUtils.getInt(archeryXP) + + ", swords = " + StringUtils.getInt(swordsXP) + + ", axes = " + StringUtils.getInt(axesXP) + + ", acrobatics = " + StringUtils.getInt(acrobaticsXP) + + ", fishing = " + StringUtils.getInt(fishingXP) + + " WHERE user_id = " + id); + } + } + + mcMMO.p.getLogger().info("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB"); + in.close(); + } + catch (Exception e) { + mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString()); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/runnables/database/SQLReconnectTask.java b/src/main/java/com/gmail/nossr50/runnables/database/SQLReconnectTask.java new file mode 100644 index 000000000..e4896a3c4 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/database/SQLReconnectTask.java @@ -0,0 +1,21 @@ +package com.gmail.nossr50.runnables.database; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.util.player.UserManager; + +public class SQLReconnectTask implements Runnable { + @Override + public void run() { + if (DatabaseManager.checkConnected()) { + UserManager.saveAll(); // Save all profiles + UserManager.clearAll(); // Clear the profiles + + for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { + UserManager.addUser(player); // Add in new profiles, forcing them to 'load' again from MySQL + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/database/runnables/UserPurgeTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java similarity index 51% rename from src/main/java/com/gmail/nossr50/database/runnables/UserPurgeTask.java rename to src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java index 7cb89c7a8..d0d1dc261 100644 --- a/src/main/java/com/gmail/nossr50/database/runnables/UserPurgeTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java @@ -1,25 +1,25 @@ -package com.gmail.nossr50.database.runnables; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.Database; -import com.gmail.nossr50.database.Leaderboard; - -public class UserPurgeTask implements Runnable { - @Override - public void run() { - if (Config.getInstance().getUseMySQL()) { - Database.purgePowerlessSQL(); - - if (Config.getInstance().getOldUsersCutoff() != -1) { - Database.purgeOldSQL(); - } - } - else { - Leaderboard.purgePowerlessFlatfile(); - - if (Config.getInstance().getOldUsersCutoff() != -1) { - Leaderboard.purgeOldFlatfile(); - } - } - } -} +package com.gmail.nossr50.runnables.database; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.database.LeaderboardManager; + +public class UserPurgeTask implements Runnable { + @Override + public void run() { + if (Config.getInstance().getUseMySQL()) { + DatabaseManager.purgePowerlessSQL(); + + if (Config.getInstance().getOldUsersCutoff() != -1) { + DatabaseManager.purgeOldSQL(); + } + } + else { + LeaderboardManager.purgePowerlessFlatfile(); + + if (Config.getInstance().getOldUsersCutoff() != -1) { + LeaderboardManager.purgeOldFlatfile(); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/party/runnables/PartyAutoKick.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java similarity index 86% rename from src/main/java/com/gmail/nossr50/party/runnables/PartyAutoKick.java rename to src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java index 5b64fc61e..5a78978c5 100644 --- a/src/main/java/com/gmail/nossr50/party/runnables/PartyAutoKick.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java @@ -1,14 +1,14 @@ -package com.gmail.nossr50.party.runnables; +package com.gmail.nossr50.runnables.party; import java.util.Iterator; import org.bukkit.OfflinePlayer; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.party.Party; +import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.party.PartyManager; -public class PartyAutoKick implements Runnable { +public class PartyAutoKickTask implements Runnable { @Override public void run() { updatePartyMembers(); diff --git a/src/main/java/com/gmail/nossr50/party/runnables/PartiesLoader.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyLoaderTask.java similarity index 57% rename from src/main/java/com/gmail/nossr50/party/runnables/PartiesLoader.java rename to src/main/java/com/gmail/nossr50/runnables/party/PartyLoaderTask.java index 4cf76741f..2f8986d27 100644 --- a/src/main/java/com/gmail/nossr50/party/runnables/PartiesLoader.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyLoaderTask.java @@ -1,8 +1,8 @@ -package com.gmail.nossr50.party.runnables; +package com.gmail.nossr50.runnables.party; import com.gmail.nossr50.party.PartyManager; -public class PartiesLoader implements Runnable { +public class PartyLoaderTask implements Runnable { @Override public void run() { PartyManager.loadParties(); diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java new file mode 100644 index 000000000..6ed2f1c91 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java @@ -0,0 +1,24 @@ +package com.gmail.nossr50.runnables.player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.util.player.UserManager; + +public class PlayerProfileSaveTask implements Runnable { + private McMMOPlayer mcMMOPlayer; + private PlayerProfile playerProfile; + + public PlayerProfileSaveTask(McMMOPlayer mcMMOPlayer) { + this.mcMMOPlayer = mcMMOPlayer; + this.playerProfile = mcMMOPlayer.getProfile(); + } + + @Override + public void run() { + playerProfile.save(); + + if (!mcMMOPlayer.getPlayer().isOnline()) { + UserManager.remove(playerProfile.getPlayerName()); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/runnables/CombatXpGiver.java b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java similarity index 59% rename from src/main/java/com/gmail/nossr50/skills/runnables/CombatXpGiver.java rename to src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java index f28caaecd..645193c9b 100644 --- a/src/main/java/com/gmail/nossr50/skills/runnables/CombatXpGiver.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java @@ -1,40 +1,40 @@ -package com.gmail.nossr50.skills.runnables; - -import org.bukkit.entity.LivingEntity; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.skills.utilities.SkillType; - -public class CombatXpGiver implements Runnable { - private McMMOPlayer mcMMOPlayer; - private double baseXp; - private SkillType skillType; - private LivingEntity target; - private int baseHealth; - - public CombatXpGiver(McMMOPlayer mcMMOPlayer, SkillType skillType, double baseXp, LivingEntity target) { - this.mcMMOPlayer = mcMMOPlayer; - this.skillType = skillType; - this.baseXp = baseXp; - this.target = target; - baseHealth = target.getHealth(); - } - - @Override - public void run() { - int health = target.getHealth(); - int damage = baseHealth - health; - - //May avoid negative xp, we don't know what other plugins do with the entity health - if (damage <= 0) { - return; - } - - //Don't reward the player for overkills - if (health < 0) { - damage += health; - } - - mcMMOPlayer.beginXpGain(skillType, (int) (damage * baseXp)); - } -} +package com.gmail.nossr50.runnables.skills; + +import org.bukkit.entity.LivingEntity; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; + +public class AwardCombatXpTask implements Runnable { + private McMMOPlayer mcMMOPlayer; + private double baseXp; + private SkillType skillType; + private LivingEntity target; + private int baseHealth; + + public AwardCombatXpTask(McMMOPlayer mcMMOPlayer, SkillType skillType, double baseXp, LivingEntity target) { + this.mcMMOPlayer = mcMMOPlayer; + this.skillType = skillType; + this.baseXp = baseXp; + this.target = target; + baseHealth = target.getHealth(); + } + + @Override + public void run() { + int health = target.getHealth(); + int damage = baseHealth - health; + + // May avoid negative xp, we don't know what other plugins do with the entity health + if (damage <= 0) { + return; + } + + // Don't reward the player for overkills + if (health < 0) { + damage += health; + } + + mcMMOPlayer.beginXpGain(skillType, (int) (damage * baseXp)); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java similarity index 88% rename from src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java rename to src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index 464b6b013..768ec5d8b 100644 --- a/src/main/java/com/gmail/nossr50/skills/runnables/BleedTimer.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.skills.runnables; +package com.gmail.nossr50.runnables.skills; import java.util.HashMap; import java.util.Iterator; @@ -9,10 +9,10 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.CombatTools; -import com.gmail.nossr50.util.ParticleEffectUtils; +import com.gmail.nossr50.util.skills.CombatUtils; +import com.gmail.nossr50.util.skills.ParticleEffectUtils; -public class BleedTimer implements Runnable { +public class BleedTimerTask implements Runnable { private final static int MAX_BLEED_TICKS = 10; private static Map bleedList = new HashMap(); @@ -39,7 +39,7 @@ public class BleedTimer implements Runnable { // Never kill with Bleeding if (player.getHealth() - damage > 0) { - CombatTools.dealDamage(player, damage); + CombatUtils.dealDamage(player, damage); ParticleEffectUtils.playBleedEffect(entity); } @@ -60,7 +60,7 @@ public class BleedTimer implements Runnable { bleedIterator.remove(); } - CombatTools.dealDamage(entity, damage); + CombatUtils.dealDamage(entity, damage); ParticleEffectUtils.playBleedEffect(entity); } } @@ -73,7 +73,7 @@ public class BleedTimer implements Runnable { */ public static void bleedOut(LivingEntity entity) { if (bleedList.containsKey(entity)) { - CombatTools.dealDamage(entity, bleedList.get(entity) * 2); + CombatUtils.dealDamage(entity, bleedList.get(entity) * 2); bleedList.remove(entity); } } diff --git a/src/main/java/com/gmail/nossr50/skills/runnables/SkillMonitor.java b/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java similarity index 59% rename from src/main/java/com/gmail/nossr50/skills/runnables/SkillMonitor.java rename to src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java index 93652cc6e..5d8c9f137 100644 --- a/src/main/java/com/gmail/nossr50/skills/runnables/SkillMonitor.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java @@ -1,16 +1,16 @@ -package com.gmail.nossr50.skills.runnables; +package com.gmail.nossr50.runnables.skills; import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; -public class SkillMonitor implements Runnable { +public class SkillMonitorTask implements Runnable { @Override public void run() { long curTime = System.currentTimeMillis(); @@ -20,14 +20,14 @@ public class SkillMonitor implements Runnable { continue; } - PlayerProfile profile = Users.getPlayer(player).getProfile(); + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); /* * MONITOR SKILLS */ for (SkillType skill : SkillType.values()) { if (skill.getTool() != null && skill.getAbility() != null) { - SkillTools.monitorSkill(player, profile, curTime, skill); + SkillUtils.monitorSkill(player, profile, curTime, skill); } } @@ -36,7 +36,7 @@ public class SkillMonitor implements Runnable { */ for (AbilityType ability : AbilityType.values()) { if (ability.getCooldown() > 0) { - SkillTools.watchCooldown(player, profile, ability); + SkillUtils.watchCooldown(player, profile, ability); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenTerraTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenTerraTimerTask.java new file mode 100644 index 000000000..846e04d13 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenTerraTimerTask.java @@ -0,0 +1,46 @@ +package com.gmail.nossr50.runnables.skills.herbalism; + +import org.bukkit.CropState; +import org.bukkit.block.BlockState; +import org.bukkit.material.CocoaPlant; +import org.bukkit.material.CocoaPlant.CocoaPlantSize; + +public class GreenTerraTimerTask implements Runnable { + private BlockState blockState; + + /** + * Convert plants affected by the Green Terra ability. + * + * @param blockState The {@link BlockState} to check ability activation for + */ + public GreenTerraTimerTask(BlockState blockState) { + this.blockState = blockState; + } + + @Override + public void run() { + switch (blockState.getType()) { + case CROPS: + case CARROT: + case POTATO: + blockState.setRawData(CropState.MEDIUM.getData()); + blockState.update(true); + return; + + case NETHER_WARTS: + blockState.setRawData((byte) 0x2); + blockState.update(true); + return; + + case COCOA: + CocoaPlant plant = (CocoaPlant) blockState.getData(); + plant.setSize(CocoaPlantSize.MEDIUM); + blockState.setData(plant); + blockState.update(true); + return; + + default: + return; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenThumbTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenThumbTimerTask.java new file mode 100644 index 000000000..5b9d8da17 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenThumbTimerTask.java @@ -0,0 +1,66 @@ +package com.gmail.nossr50.runnables.skills.herbalism; + +import org.bukkit.block.BlockState; +import org.bukkit.material.CocoaPlant; +import org.bukkit.material.CocoaPlant.CocoaPlantSize; + +import com.gmail.nossr50.skills.herbalism.Herbalism; + +public class GreenThumbTimerTask implements Runnable { + private BlockState blockState; + private int skillLevel; + + /** + * Convert plants affected by the Green Thumb ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param skillLevel The player's Herbalism skill level + */ + public GreenThumbTimerTask(BlockState blockState, int skillLevel) { + this.blockState = blockState; + this.skillLevel = skillLevel; + } + + @Override + public void run() { + int greenThumbStage = Math.min(Math.min(skillLevel, Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4); + + switch (blockState.getType()) { + case CROPS: + case CARROT: + case POTATO: + blockState.setRawData((byte) greenThumbStage); + blockState.update(true); + return; + + case NETHER_WARTS: + if (greenThumbStage > 2) { + blockState.setRawData((byte) 0x2); + } + else if (greenThumbStage == 2) { + blockState.setRawData((byte) 0x1); + } + else { + blockState.setRawData((byte) 0x0); + } + blockState.update(true); + return; + + case COCOA: + CocoaPlant plant = (CocoaPlant) blockState.getData(); + + if (greenThumbStage > 1) { + plant.setSize(CocoaPlantSize.MEDIUM); + } + else { + plant.setSize(CocoaPlantSize.SMALL); + } + blockState.setData(plant); + blockState.update(true); + return; + + default: + return; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/SkillGuide.java b/src/main/java/com/gmail/nossr50/skills/SkillGuide.java deleted file mode 100644 index 62375bca2..000000000 --- a/src/main/java/com/gmail/nossr50/skills/SkillGuide.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.gmail.nossr50.skills; - -import java.util.ArrayList; - -import org.bukkit.entity.Player; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.StringUtils; - -public final class SkillGuide { - private SkillGuide() {} - - public static int getTotalPageNumber(String address) { - String[] addressSplit = LocaleLoader.getString(address).split("\n"); - - if (addressSplit.length <= 8) { - return 1; - } - - return (addressSplit.length/8)+1; - } - - public static ArrayList grabPageContents(String header, String address, int pagenum) { - int pageIndexStart = 0; - - //Determine what string to start at - if (pagenum > 1) { - pageIndexStart = 8*(pagenum-1); - } - - ArrayList allStrings = new ArrayList(); - String split[] = LocaleLoader.getString(address).split("\n"); - - allStrings.add(LocaleLoader.getString("Guides.Header", header)); - - //Add targeted strings - while (allStrings.size() < 9) { - if (pageIndexStart+allStrings.size() > split.length) { - allStrings.add(""); - } - else { - allStrings.add(split[pageIndexStart+allStrings.size()-1]); - } - } - - allStrings.add("Page "+pagenum+" of "+getTotalPageNumber(address)); - return allStrings; - } - - public static void clearChat(Player player) { - player.sendMessage("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - } - - public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) { - String skillName = skilltype.toString(); - String capitalized = StringUtils.getCapitalized(skillName); - String localized = SkillTools.getSkillName(skilltype); - player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase())); - - String address = "Guides." + capitalized; - - switch (args.length) { - case 0: - // We have to specify this, otherwise we get the usage string every time we call /skillname... - return true; - - case 1: - if (!args[0].equals("?")) { - return false; - } - - SkillGuide.clearChat(player); - - for (String target : SkillGuide.grabPageContents(localized, address, 1)) { - player.sendMessage(target); - } - - return true; - - case 2: - int totalPages = SkillGuide.getTotalPageNumber(address); - - if (!StringUtils.isInt(args[1])) { - player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid")); - return true; - } - - if (Integer.parseInt(args[1]) > totalPages) { - player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages)); - return true; - } - - SkillGuide.clearChat(player); - - for (String target : SkillGuide.grabPageContents(localized, address, Integer.parseInt(args[1]))) { - player.sendMessage(target); - } - - return true; - - default: - return false; - } - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManager.java b/src/main/java/com/gmail/nossr50/skills/SkillManager.java index 612b7a2dd..8595b0929 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManager.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManager.java @@ -1,44 +1,44 @@ -package com.gmail.nossr50.skills; - -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.skills.utilities.PerksUtils; -import com.gmail.nossr50.skills.utilities.SkillType; - -public abstract class SkillManager { - protected McMMOPlayer mcMMOPlayer; - protected int activationChance; - protected SkillType skill; - - public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) { - this.mcMMOPlayer = mcMMOPlayer; - this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill); - this.skill = skill; - } - - public McMMOPlayer getMcMMOPlayer() { - return mcMMOPlayer; - } - - public Player getPlayer() { - return mcMMOPlayer.getPlayer(); - } - - public PlayerProfile getProfile() { - return mcMMOPlayer.getProfile(); - } - - public int getSkillLevel() { - return mcMMOPlayer.getProfile().getSkillLevel(skill); - } - - public int getActivationChance() { - return activationChance; - } - - public void applyXpGain(int xp) { - mcMMOPlayer.beginXpGain(skill, xp); - } -} +package com.gmail.nossr50.skills; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.util.skills.PerksUtils; + +public abstract class SkillManager { + protected McMMOPlayer mcMMOPlayer; + protected int activationChance; + protected SkillType skill; + + public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) { + this.mcMMOPlayer = mcMMOPlayer; + this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill); + this.skill = skill; + } + + public McMMOPlayer getMcMMOPlayer() { + return mcMMOPlayer; + } + + public Player getPlayer() { + return mcMMOPlayer.getPlayer(); + } + + public PlayerProfile getProfile() { + return mcMMOPlayer.getProfile(); + } + + public int getSkillLevel() { + return mcMMOPlayer.getProfile().getSkillLevel(skill); + } + + public int getActivationChance() { + return activationChance; + } + + public void applyXpGain(int xp) { + mcMMOPlayer.beginXpGain(skill, xp); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java index d4f27f6f4..e8dcdcf62 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java @@ -1,128 +1,128 @@ -package com.gmail.nossr50.skills; - -import java.util.HashMap; - -import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; -import com.gmail.nossr50.skills.archery.ArcheryManager; -import com.gmail.nossr50.skills.axes.AxeManager; -import com.gmail.nossr50.skills.excavation.ExcavationManager; -import com.gmail.nossr50.skills.fishing.FishingManager; -import com.gmail.nossr50.skills.herbalism.HerbalismManager; -import com.gmail.nossr50.skills.mining.MiningManager; -import com.gmail.nossr50.skills.smelting.SmeltingManager; -import com.gmail.nossr50.skills.swords.SwordsManager; -import com.gmail.nossr50.skills.taming.TamingManager; -import com.gmail.nossr50.skills.unarmed.UnarmedManager; -import com.gmail.nossr50.util.Users; - -public class SkillManagerStore { - private static SkillManagerStore instance; - - private HashMap acrobaticsManagers = new HashMap(); - private HashMap archeryManagers = new HashMap(); - private HashMap axeManagers = new HashMap(); - private HashMap excavationManagers = new HashMap(); - private HashMap fishingManagers = new HashMap(); - private HashMap herbalismManagers = new HashMap(); - private HashMap miningManagers = new HashMap(); - private HashMap smeltingManagers = new HashMap(); - private HashMap swordsManagers = new HashMap(); - private HashMap tamingManagers = new HashMap(); - private HashMap unarmedManagers = new HashMap(); - - public static SkillManagerStore getInstance() { - if (instance == null) { - instance = new SkillManagerStore(); - } - - return instance; - } - - public AcrobaticsManager getAcrobaticsManager(String playerName) { - if (!acrobaticsManagers.containsKey(playerName)) { - acrobaticsManagers.put(playerName, new AcrobaticsManager(Users.getPlayer(playerName))); - } - - return acrobaticsManagers.get(playerName); - } - - public ArcheryManager getArcheryManager(String playerName) { - if (!archeryManagers.containsKey(playerName)) { - archeryManagers.put(playerName, new ArcheryManager(Users.getPlayer(playerName))); - } - - return archeryManagers.get(playerName); - } - - public AxeManager getAxeManager(String playerName) { - if (!axeManagers.containsKey(playerName)) { - axeManagers.put(playerName, new AxeManager(Users.getPlayer(playerName))); - } - - return axeManagers.get(playerName); - } - - public ExcavationManager getExcavationManager(String playerName) { - if (!excavationManagers.containsKey(playerName)) { - excavationManagers.put(playerName, new ExcavationManager(Users.getPlayer(playerName))); - } - - return excavationManagers.get(playerName); - } - - public FishingManager getFishingManager(String playerName) { - if (!fishingManagers.containsKey(playerName)) { - fishingManagers.put(playerName, new FishingManager(Users.getPlayer(playerName))); - } - - return fishingManagers.get(playerName); - } - - public HerbalismManager getHerbalismManager(String playerName) { - if (!herbalismManagers.containsKey(playerName)) { - herbalismManagers.put(playerName, new HerbalismManager(Users.getPlayer(playerName))); - } - - return herbalismManagers.get(playerName); - } - - public MiningManager getMiningManager(String playerName) { - if (!miningManagers.containsKey(playerName)) { - miningManagers.put(playerName, new MiningManager(Users.getPlayer(playerName))); - } - - return miningManagers.get(playerName); - } - - public SmeltingManager getSmeltingManager(String playerName) { - if (!smeltingManagers.containsKey(playerName)) { - smeltingManagers.put(playerName, new SmeltingManager(Users.getPlayer(playerName))); - } - - return smeltingManagers.get(playerName); - } - - public SwordsManager getSwordsManager(String playerName) { - if (!swordsManagers.containsKey(playerName)) { - swordsManagers.put(playerName, new SwordsManager(Users.getPlayer(playerName))); - } - - return swordsManagers.get(playerName); - } - - public TamingManager getTamingManager(String playerName) { - if (!tamingManagers.containsKey(playerName)) { - tamingManagers.put(playerName, new TamingManager(Users.getPlayer(playerName))); - } - - return tamingManagers.get(playerName); - } - - public UnarmedManager getUnarmedManager(String playerName) { - if (!unarmedManagers.containsKey(playerName)) { - unarmedManagers.put(playerName, new UnarmedManager(Users.getPlayer(playerName))); - } - - return unarmedManagers.get(playerName); - } -} +package com.gmail.nossr50.skills; + +import java.util.HashMap; + +import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; +import com.gmail.nossr50.skills.archery.ArcheryManager; +import com.gmail.nossr50.skills.axes.AxeManager; +import com.gmail.nossr50.skills.excavation.ExcavationManager; +import com.gmail.nossr50.skills.fishing.FishingManager; +import com.gmail.nossr50.skills.herbalism.HerbalismManager; +import com.gmail.nossr50.skills.mining.MiningManager; +import com.gmail.nossr50.skills.smelting.SmeltingManager; +import com.gmail.nossr50.skills.swords.SwordsManager; +import com.gmail.nossr50.skills.taming.TamingManager; +import com.gmail.nossr50.skills.unarmed.UnarmedManager; +import com.gmail.nossr50.util.player.UserManager; + +public class SkillManagerStore { + private static SkillManagerStore instance; + + private HashMap acrobaticsManagers = new HashMap(); + private HashMap archeryManagers = new HashMap(); + private HashMap axeManagers = new HashMap(); + private HashMap excavationManagers = new HashMap(); + private HashMap fishingManagers = new HashMap(); + private HashMap herbalismManagers = new HashMap(); + private HashMap miningManagers = new HashMap(); + private HashMap smeltingManagers = new HashMap(); + private HashMap swordsManagers = new HashMap(); + private HashMap tamingManagers = new HashMap(); + private HashMap unarmedManagers = new HashMap(); + + public static SkillManagerStore getInstance() { + if (instance == null) { + instance = new SkillManagerStore(); + } + + return instance; + } + + public AcrobaticsManager getAcrobaticsManager(String playerName) { + if (!acrobaticsManagers.containsKey(playerName)) { + acrobaticsManagers.put(playerName, new AcrobaticsManager(UserManager.getPlayer(playerName))); + } + + return acrobaticsManagers.get(playerName); + } + + public ArcheryManager getArcheryManager(String playerName) { + if (!archeryManagers.containsKey(playerName)) { + archeryManagers.put(playerName, new ArcheryManager(UserManager.getPlayer(playerName))); + } + + return archeryManagers.get(playerName); + } + + public AxeManager getAxeManager(String playerName) { + if (!axeManagers.containsKey(playerName)) { + axeManagers.put(playerName, new AxeManager(UserManager.getPlayer(playerName))); + } + + return axeManagers.get(playerName); + } + + public ExcavationManager getExcavationManager(String playerName) { + if (!excavationManagers.containsKey(playerName)) { + excavationManagers.put(playerName, new ExcavationManager(UserManager.getPlayer(playerName))); + } + + return excavationManagers.get(playerName); + } + + public FishingManager getFishingManager(String playerName) { + if (!fishingManagers.containsKey(playerName)) { + fishingManagers.put(playerName, new FishingManager(UserManager.getPlayer(playerName))); + } + + return fishingManagers.get(playerName); + } + + public HerbalismManager getHerbalismManager(String playerName) { + if (!herbalismManagers.containsKey(playerName)) { + herbalismManagers.put(playerName, new HerbalismManager(UserManager.getPlayer(playerName))); + } + + return herbalismManagers.get(playerName); + } + + public MiningManager getMiningManager(String playerName) { + if (!miningManagers.containsKey(playerName)) { + miningManagers.put(playerName, new MiningManager(UserManager.getPlayer(playerName))); + } + + return miningManagers.get(playerName); + } + + public SmeltingManager getSmeltingManager(String playerName) { + if (!smeltingManagers.containsKey(playerName)) { + smeltingManagers.put(playerName, new SmeltingManager(UserManager.getPlayer(playerName))); + } + + return smeltingManagers.get(playerName); + } + + public SwordsManager getSwordsManager(String playerName) { + if (!swordsManagers.containsKey(playerName)) { + swordsManagers.put(playerName, new SwordsManager(UserManager.getPlayer(playerName))); + } + + return swordsManagers.get(playerName); + } + + public TamingManager getTamingManager(String playerName) { + if (!tamingManagers.containsKey(playerName)) { + tamingManagers.put(playerName, new TamingManager(UserManager.getPlayer(playerName))); + } + + return tamingManagers.get(playerName); + } + + public UnarmedManager getUnarmedManager(String playerName) { + if (!unarmedManagers.containsKey(playerName)) { + unarmedManagers.put(playerName, new UnarmedManager(UserManager.getPlayer(playerName))); + } + + return unarmedManagers.get(playerName); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index 36ba599ca..81a98023b 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -1,36 +1,36 @@ -package com.gmail.nossr50.skills.acrobatics; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; - -public final class Acrobatics { - public static double dodgeMaxChance = AdvancedConfig.getInstance().getDodgeChanceMax(); - public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel(); - public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier(); - public static int dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier(); - - public static double rollMaxChance = AdvancedConfig.getInstance().getRollChanceMax(); - public static int rollMaxBonusLevel = AdvancedConfig.getInstance().getRollMaxBonusLevel(); - public static int rollThreshold = AdvancedConfig.getInstance().getRollDamageThreshold(); - - public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax(); - public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel(); - public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold(); - public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer(); - - public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier(); - public static int fallXpModifier = AdvancedConfig.getInstance().getFallXPModifier(); - - public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled(); - public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled(); - - private Acrobatics() {}; - - protected static int calculateModifiedDodgeDamage(int damage, int damageModifier) { - return Math.max(damage / damageModifier, 1); - } - - protected static int calculateModifiedRollDamage(int damage, int damageThreshold) { - return Math.max(damage - damageThreshold, 0); - } -} \ No newline at end of file +package com.gmail.nossr50.skills.acrobatics; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; + +public final class Acrobatics { + public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel(); + public static int dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier(); + public static double dodgeMaxChance = AdvancedConfig.getInstance().getDodgeChanceMax(); + + public static int rollMaxBonusLevel = AdvancedConfig.getInstance().getRollMaxBonusLevel(); + public static int rollThreshold = AdvancedConfig.getInstance().getRollDamageThreshold(); + public static double rollMaxChance = AdvancedConfig.getInstance().getRollChanceMax(); + + public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel(); + public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold(); + public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer(); + public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax(); + + public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier(); + public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier(); + public static int fallXpModifier = AdvancedConfig.getInstance().getFallXPModifier(); + + public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled(); + public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled(); + + private Acrobatics() {}; + + protected static int calculateModifiedDodgeDamage(int damage, int damageModifier) { + return Math.max(damage / damageModifier, 1); + } + + protected static int calculateModifiedRollDamage(int damage, int damageThreshold) { + return Math.max(damage - damageThreshold, 0); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 060b09050..93350b314 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -1,129 +1,129 @@ -package com.gmail.nossr50.skills.acrobatics; - -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LightningStrike; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.ParticleEffectUtils; -import com.gmail.nossr50.util.Permissions; - -public class AcrobaticsManager extends SkillManager { - public AcrobaticsManager (McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.ACROBATICS); - } - - public boolean canRoll() { - Player player = getPlayer(); - - return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player); - } - - public boolean canDodge(Entity damager) { - if (Permissions.dodge(getPlayer())) { - if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) { - return true; - } - else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) { - return true; - } - } - - return false; - } - - /** - * Handle the damage reduction and XP gain from the Dodge ability - * - * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the ability was successful, the original event damage otherwise - */ - public int dodgeCheck(int damage) { - int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier); - Player player = getPlayer(); - - if (!isFatal(modifiedDamage) && SkillTools.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) { - ParticleEffectUtils.playDodgeEffect(player); - - PlayerProfile playerProfile = getProfile(); - - if (playerProfile.useChatNotifications()) { - player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc")); - } - - // Why do we check respawn cooldown here? - if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) { - applyXpGain(damage * Acrobatics.dodgeXpModifier); - } - - return modifiedDamage; - } - - return damage; - } - - /** - * Handle the damage reduction and XP gain from the Roll ability - * - * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the ability was successful, the original event damage otherwise - */ - public int rollCheck(int damage) { - Player player = getPlayer(); - - if (player.isSneaking() && Permissions.gracefulRoll(player)) { - return gracefulRollCheck(damage); - } - - int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold); - - if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) { - player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); - applyXpGain(damage * Acrobatics.rollXpModifier); - - return modifiedDamage; - } - else if (!isFatal(damage)) { - applyXpGain(damage * Acrobatics.fallXpModifier); - } - - return damage; - } - - /** - * Handle the damage reduction and XP gain from the Graceful Roll ability - * - * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the ability was successful, the original event damage otherwise - */ - private int gracefulRollCheck(int damage) { - int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold); - - if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) { - getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); - applyXpGain(damage * Acrobatics.rollXpModifier); - - return modifiedDamage; - } - else if (!isFatal(damage)) { - applyXpGain(damage * Acrobatics.fallXpModifier); - } - - return damage; - } - - private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) { - return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance); - } - - private boolean isFatal(int damage) { - return getPlayer().getHealth() - damage < 1; - } -} +package com.gmail.nossr50.skills.acrobatics; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LightningStrike; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.ParticleEffectUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class AcrobaticsManager extends SkillManager { + public AcrobaticsManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.ACROBATICS); + } + + public boolean canRoll() { + Player player = getPlayer(); + + return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player); + } + + public boolean canDodge(Entity damager) { + if (Permissions.dodge(getPlayer())) { + if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) { + return true; + } + else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) { + return true; + } + } + + return false; + } + + /** + * Handle the damage reduction and XP gain from the Dodge ability + * + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the ability was successful, the original event damage otherwise + */ + public int dodgeCheck(int damage) { + int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier); + Player player = getPlayer(); + + if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) { + ParticleEffectUtils.playDodgeEffect(player); + + PlayerProfile playerProfile = getProfile(); + + if (playerProfile.useChatNotifications()) { + player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc")); + } + + // Why do we check respawn cooldown here? + if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) { + applyXpGain(damage * Acrobatics.dodgeXpModifier); + } + + return modifiedDamage; + } + + return damage; + } + + /** + * Handle the damage reduction and XP gain from the Roll ability + * + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the ability was successful, the original event damage otherwise + */ + public int rollCheck(int damage) { + Player player = getPlayer(); + + if (player.isSneaking() && Permissions.gracefulRoll(player)) { + return gracefulRollCheck(damage); + } + + int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold); + + if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) { + player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); + applyXpGain(damage * Acrobatics.rollXpModifier); + + return modifiedDamage; + } + else if (!isFatal(damage)) { + applyXpGain(damage * Acrobatics.fallXpModifier); + } + + return damage; + } + + /** + * Handle the damage reduction and XP gain from the Graceful Roll ability + * + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the ability was successful, the original event damage otherwise + */ + private int gracefulRollCheck(int damage) { + int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold); + + if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) { + getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); + applyXpGain(damage * Acrobatics.rollXpModifier); + + return modifiedDamage; + } + else if (!isFatal(damage)) { + applyXpGain(damage * Acrobatics.fallXpModifier); + } + + return damage; + } + + private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) { + return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance); + } + + private boolean isFatal(int damage) { + return getPlayer().getHealth() - damage < 1; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index 797d68ea7..06c542e2c 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -1,68 +1,68 @@ -package com.gmail.nossr50.skills.archery; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.util.Misc; - -public class Archery { - private static List trackedEntities = new ArrayList(); - - public static int retrieveMaxBonusLevel = AdvancedConfig.getInstance().getRetrieveMaxBonusLevel(); - public static double retrieveMaxChance = AdvancedConfig.getInstance().getRetrieveChanceMax(); - - public static int skillShotIncreaseLevel = AdvancedConfig.getInstance().getSkillShotIncreaseLevel(); - public static double skillShotIncreasePercentage = AdvancedConfig.getInstance().getSkillShotIncreasePercentage(); - public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax(); - - public static int dazeMaxBonusLevel = AdvancedConfig.getInstance().getDazeMaxBonusLevel(); - public static double dazeMaxBonus = AdvancedConfig.getInstance().getDazeBonusMax(); - public static int dazeModifier = AdvancedConfig.getInstance().getDazeModifier(); - - public static double distanceXpModifer = 0.025; - - protected static void incrementTrackerValue(LivingEntity livingEntity) { - for (TrackedEntity trackedEntity : trackedEntities) { - if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) { - trackedEntity.incrementArrowCount(); - return; - } - } - - addToTracker(livingEntity); //If the entity isn't tracked yet - } - - protected static void addToTracker(LivingEntity livingEntity) { - TrackedEntity trackedEntity = new TrackedEntity(livingEntity); - - trackedEntity.incrementArrowCount(); - trackedEntities.add(trackedEntity); - } - - protected static void removeFromTracker(TrackedEntity trackedEntity) { - trackedEntities.remove(trackedEntity); - } - - /** - * Check for arrow retrieval. - * - * @param livingEntity The entity hit by the arrows - */ - public static void arrowRetrievalCheck(LivingEntity livingEntity) { - for (Iterator entityIterator = trackedEntities.iterator(); entityIterator.hasNext(); ) { - TrackedEntity trackedEntity = entityIterator.next(); - - if (trackedEntity.getID() == livingEntity.getUniqueId()) { - Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount()); - entityIterator.remove(); - return; - } - } - } -} +package com.gmail.nossr50.skills.archery; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.util.Misc; + +public class Archery { + private static List trackedEntities = new ArrayList(); + + public static int retrieveMaxBonusLevel = AdvancedConfig.getInstance().getRetrieveMaxBonusLevel(); + public static double retrieveMaxChance = AdvancedConfig.getInstance().getRetrieveChanceMax(); + + public static int skillShotIncreaseLevel = AdvancedConfig.getInstance().getSkillShotIncreaseLevel(); + public static double skillShotIncreasePercentage = AdvancedConfig.getInstance().getSkillShotIncreasePercentage(); + public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax(); + + public static int dazeMaxBonusLevel = AdvancedConfig.getInstance().getDazeMaxBonusLevel(); + public static int dazeModifier = AdvancedConfig.getInstance().getDazeModifier(); + public static double dazeMaxBonus = AdvancedConfig.getInstance().getDazeBonusMax(); + + public static final double DISTANCE_XP_MULTIPLIER = 0.025; + + protected static void incrementTrackerValue(LivingEntity livingEntity) { + for (TrackedEntity trackedEntity : trackedEntities) { + if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) { + trackedEntity.incrementArrowCount(); + return; + } + } + + addToTracker(livingEntity); // If the entity isn't tracked yet + } + + protected static void addToTracker(LivingEntity livingEntity) { + TrackedEntity trackedEntity = new TrackedEntity(livingEntity); + + trackedEntity.incrementArrowCount(); + trackedEntities.add(trackedEntity); + } + + protected static void removeFromTracker(TrackedEntity trackedEntity) { + trackedEntities.remove(trackedEntity); + } + + /** + * Check for arrow retrieval. + * + * @param livingEntity The entity hit by the arrows + */ + public static void arrowRetrievalCheck(LivingEntity livingEntity) { + for (Iterator entityIterator = trackedEntities.iterator(); entityIterator.hasNext();) { + TrackedEntity trackedEntity = entityIterator.next(); + + if (trackedEntity.getID() == livingEntity.getUniqueId()) { + Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount()); + entityIterator.remove(); + return; + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index ca95cdf9f..3d6e610bb 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -1,115 +1,115 @@ -package com.gmail.nossr50.skills.archery; - -import org.bukkit.Location; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class ArcheryManager extends SkillManager { - public ArcheryManager (McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.ARCHERY); - } - - public boolean canDaze(LivingEntity target) { - return target instanceof Player && Permissions.daze(getPlayer()); - } - - public boolean canSkillShot() { - Player player = getPlayer(); - - return SkillTools.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill); - } - - public boolean canTrackArrows() { - Player player = getPlayer(); - - return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player); - } - - /** - * Calculate bonus XP awarded for Archery when hitting a far-away target. - * - * @param target The {@link LivingEntity} damaged by the arrow - */ - public void distanceXpBonus(LivingEntity target) { - Player player = getPlayer(); - Location shooterLocation = player.getLocation(); - Location targetLocation = target.getLocation(); - - if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) { - return; - } - - // Cap distance at 100^2 to prevent teleport exploit. - // TODO: Better way to handle this would be great... - double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000); - - applyXpGain((int) (squaredDistance * Archery.distanceXpModifer)); - } - - /** - * Track arrows fired for later retrieval. - * - * @param target The {@link LivingEntity} damaged by the arrow - */ - public void trackArrows(LivingEntity target) { - if (SkillTools.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) { - Archery.incrementTrackerValue(target); - } - } - - /** - * Handle the effects of the Daze ability - * - * @param defender The player being affected by the ability - * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the ability was successful, the original event damage otherwise - */ - public int dazeCheck(Player defender, int damage) { - Player attacker = getPlayer(); - - if (SkillTools.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) { - Location dazedLocation = defender.getLocation(); - dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181)); - - defender.teleport(dazedLocation); - defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10)); - - if (Users.getPlayer(defender).getProfile().useChatNotifications()) { - defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy")); - } - - if (getProfile().useChatNotifications()) { - attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed")); - } - - return damage + Archery.dazeModifier; - } - - return damage; - } - - /** - * Handle the effects of the Skill Shot ability - * - * @param damage The amount of damage initially dealt by the event - * @return the modified event damage - */ - public int skillShotCheck(int damage) { - double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage); - int archeryBonus = (int) (damage * damageBonusPercent); - - return damage + archeryBonus; - } -} +package com.gmail.nossr50.skills.archery; + +import org.bukkit.Location; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class ArcheryManager extends SkillManager { + public ArcheryManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.ARCHERY); + } + + public boolean canDaze(LivingEntity target) { + return target instanceof Player && Permissions.daze(getPlayer()); + } + + public boolean canSkillShot() { + Player player = getPlayer(); + + return SkillUtils.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill); + } + + public boolean canTrackArrows() { + Player player = getPlayer(); + + return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player); + } + + /** + * Calculate bonus XP awarded for Archery when hitting a far-away target. + * + * @param target The {@link LivingEntity} damaged by the arrow + */ + public void distanceXpBonus(LivingEntity target) { + Player player = getPlayer(); + Location shooterLocation = player.getLocation(); + Location targetLocation = target.getLocation(); + + if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) { + return; + } + + // Cap distance at 100^2 to prevent teleport exploit. + // TODO: Better way to handle this would be great... + double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000); + + applyXpGain((int) (squaredDistance * Archery.DISTANCE_XP_MULTIPLIER)); + } + + /** + * Track arrows fired for later retrieval. + * + * @param target The {@link LivingEntity} damaged by the arrow + */ + public void trackArrows(LivingEntity target) { + if (SkillUtils.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) { + Archery.incrementTrackerValue(target); + } + } + + /** + * Handle the effects of the Daze ability + * + * @param defender The player being affected by the ability + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the ability was successful, the original event damage otherwise + */ + public int dazeCheck(Player defender, int damage) { + Player attacker = getPlayer(); + + if (SkillUtils.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) { + Location dazedLocation = defender.getLocation(); + dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181)); + + defender.teleport(dazedLocation); + defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10)); + + if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) { + defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy")); + } + + if (getProfile().useChatNotifications()) { + attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed")); + } + + return damage + Archery.dazeModifier; + } + + return damage; + } + + /** + * Handle the effects of the Skill Shot ability + * + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage + */ + public int skillShotCheck(int damage) { + double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage); + int archeryBonus = (int) (damage * damageBonusPercent); + + return damage + archeryBonus; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java index b78d01f90..267f80ba9 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java @@ -21,6 +21,14 @@ public class TrackedEntity implements Runnable { this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000); } + @Override + public void run() { + if (!livingEntity.isValid()) { + Archery.removeFromTracker(this); + scheduler.cancelTask(taskId); + } + } + protected LivingEntity getLivingEntity() { return livingEntity; } @@ -36,12 +44,4 @@ public class TrackedEntity implements Runnable { protected void incrementArrowCount() { arrowCount++; } - - @Override - public void run() { - if (!livingEntity.isValid()) { - Archery.removeFromTracker(this); - scheduler.cancelTask(taskId); - } - } } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java index fc720f869..98b3027ee 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java @@ -1,148 +1,148 @@ -package com.gmail.nossr50.skills.axes; - -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.CombatTools; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.skills.utilities.ToolType; -import com.gmail.nossr50.util.ItemChecks; -import com.gmail.nossr50.util.ParticleEffectUtils; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public class AxeManager extends SkillManager { - public AxeManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.AXES); - } - - public boolean canUseAxeMastery() { - return Permissions.bonusDamage(getPlayer(), skill); - } - - public boolean canCriticalHit(LivingEntity target) { - return target.isValid() && Permissions.criticalStrikes(getPlayer()); - } - - public boolean canImpact(LivingEntity target) { - return target.isValid() && Permissions.armorImpact(getPlayer()) && Axes.hasArmor(target); - } - - public boolean canGreaterImpact(LivingEntity target) { - return target.isValid() && Permissions.greaterImpact(getPlayer()) && !Axes.hasArmor(target); - } - - public boolean canUseSkullSplitter(LivingEntity target) { - return target.isValid() && getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer()); - } - - public boolean canActivateAbility() { - return getProfile().getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer()); - } - - /** - * Handle the effects of the Axe Mastery ability - * - * @param damage The amount of damage initially dealt by the event - * @return the modified event damage - */ - public int axeMasteryCheck(int damage) { - int axeBonus = Math.min(getSkillLevel() / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus); - - return damage + axeBonus; - } - - /** - * Handle the effects of the Critical Hit ability - * - * @param target The {@link LivingEntity} being affected by the ability - * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the ability was successful, the original event damage otherwise - */ - public int criticalHitCheck(LivingEntity target, int damage) { - Player player = getPlayer(); - - if (SkillTools.activationSuccessful(player, skill, Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) { - player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit")); - - if (target instanceof Player) { - ((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck")); - - return (int) (damage * Axes.criticalHitPVPModifier); - } - - return (int) (damage * Axes.criticalHitPVEModifier); - } - - return damage; - } - - /** - * Handle the effects of the Impact ability - * - * @param target The {@link LivingEntity} being affected by Impact - */ - public void impactCheck(LivingEntity target) { - int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel); - - for (ItemStack armor : target.getEquipment().getArmorContents()) { - if (ItemChecks.isArmor(armor) && SkillTools.activationSuccessful(getPlayer(), skill, Axes.impactChance)) { - double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior - double modifiedDurabilityDamage = durabilityDamage * durabilityModifier; - double maxDurabilityDamage = (ModChecks.isCustomArmor(armor) ? ModChecks.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability()) * Axes.impactMaxDurabilityDamageModifier; - - armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability())); - } - } - } - - /** - * Handle the effects of the Greater Impact ability - * - * @param target The {@link LivingEntity} being affected by the ability - * @param damage The amount of damage initially dealt by the event - * @return the modified event damage if the ability was successful, the original event damage otherwise - */ - public int greaterImpactCheck(LivingEntity target, int damage) { - Player player = getPlayer(); - - if (SkillTools.activationSuccessful(player, skill, Axes.greaterImpactChance)) { - ParticleEffectUtils.playGreaterImpactEffect(target); - target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier)); - - if (getProfile().useChatNotifications()) { - player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc")); - } - - if (target instanceof Player) { - Player defender = (Player) target; - - if (Users.getPlayer(defender).getProfile().useChatNotifications()) { - defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck")); - } - } - - return damage + Axes.greaterImpactBonusDamage; - } - - return damage; - } - - /** - * Handle the effects of the Skull Splitter ability - * - * @param target The {@link LivingEntity} being affected by the ability - * @param damage The amount of damage initially dealt by the event - */ - public void skullSplitterCheck(LivingEntity target, int damage) { - CombatTools.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill); - } -} +package com.gmail.nossr50.skills.axes; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.skills.ToolType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.ModUtils; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.CombatUtils; +import com.gmail.nossr50.util.skills.ParticleEffectUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class AxeManager extends SkillManager { + public AxeManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.AXES); + } + + public boolean canUseAxeMastery() { + return Permissions.bonusDamage(getPlayer(), skill); + } + + public boolean canCriticalHit(LivingEntity target) { + return target.isValid() && Permissions.criticalStrikes(getPlayer()); + } + + public boolean canImpact(LivingEntity target) { + return target.isValid() && Permissions.armorImpact(getPlayer()) && Axes.hasArmor(target); + } + + public boolean canGreaterImpact(LivingEntity target) { + return target.isValid() && Permissions.greaterImpact(getPlayer()) && !Axes.hasArmor(target); + } + + public boolean canUseSkullSplitter(LivingEntity target) { + return target.isValid() && getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer()); + } + + public boolean canActivateAbility() { + return getProfile().getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer()); + } + + /** + * Handle the effects of the Axe Mastery ability + * + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage + */ + public int axeMasteryCheck(int damage) { + int axeBonus = Math.min(getSkillLevel() / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus); + + return damage + axeBonus; + } + + /** + * Handle the effects of the Critical Hit ability + * + * @param target The {@link LivingEntity} being affected by the ability + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the ability was successful, the original event damage otherwise + */ + public int criticalHitCheck(LivingEntity target, int damage) { + Player player = getPlayer(); + + if (SkillUtils.activationSuccessful(player, skill, Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) { + player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit")); + + if (target instanceof Player) { + ((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck")); + + return (int) (damage * Axes.criticalHitPVPModifier); + } + + return (int) (damage * Axes.criticalHitPVEModifier); + } + + return damage; + } + + /** + * Handle the effects of the Impact ability + * + * @param target The {@link LivingEntity} being affected by Impact + */ + public void impactCheck(LivingEntity target) { + int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel); + + for (ItemStack armor : target.getEquipment().getArmorContents()) { + if (ItemUtils.isArmor(armor) && SkillUtils.activationSuccessful(getPlayer(), skill, Axes.impactChance)) { + double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior + double modifiedDurabilityDamage = durabilityDamage * durabilityModifier; + double maxDurabilityDamage = (ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability()) * Axes.impactMaxDurabilityModifier; + + armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability())); + } + } + } + + /** + * Handle the effects of the Greater Impact ability + * + * @param target The {@link LivingEntity} being affected by the ability + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage if the ability was successful, the original event damage otherwise + */ + public int greaterImpactCheck(LivingEntity target, int damage) { + Player player = getPlayer(); + + if (SkillUtils.activationSuccessful(player, skill, Axes.greaterImpactChance)) { + ParticleEffectUtils.playGreaterImpactEffect(target); + target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier)); + + if (getProfile().useChatNotifications()) { + player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc")); + } + + if (target instanceof Player) { + Player defender = (Player) target; + + if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) { + defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck")); + } + } + + return damage + Axes.greaterImpactBonusDamage; + } + + return damage; + } + + /** + * Handle the effects of the Skull Splitter ability + * + * @param target The {@link LivingEntity} being affected by the ability + * @param damage The amount of damage initially dealt by the event + */ + public void skullSplitterCheck(LivingEntity target, int damage) { + CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java index 6beb94881..5b9173627 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java @@ -1,37 +1,37 @@ -package com.gmail.nossr50.skills.axes; - -import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.util.ItemChecks; - -public class Axes { - public static int bonusDamageMaxBonus = AdvancedConfig.getInstance().getBonusDamageAxesBonusMax(); - public static int bonusDamageMaxBonusLevel = AdvancedConfig.getInstance().getBonusDamageAxesMaxBonusLevel(); - - public static int criticalHitMaxBonusLevel = AdvancedConfig.getInstance().getAxesCriticalMaxBonusLevel(); - public static double criticalHitMaxChance = AdvancedConfig.getInstance().getAxesCriticalChance(); - public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getAxesCriticalPVPModifier(); - public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getAxesCriticalPVEModifier(); - - public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel(); - public static double impactChance = AdvancedConfig.getInstance().getImpactChance(); - public static double impactMaxDurabilityDamageModifier = AdvancedConfig.getInstance().getArmorImpactMaxDurabilityDamage() / 100D; - - public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance(); - public static double greaterImpactKnockbackMultiplier = AdvancedConfig.getInstance().getGreaterImpactModifier(); - public static int greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage(); - - public static int skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier(); - - protected static boolean hasArmor(LivingEntity target) { - for (ItemStack itemStack : target.getEquipment().getArmorContents()) { - if (ItemChecks.isArmor(itemStack)) { - return true; - } - } - - return false; - } -} +package com.gmail.nossr50.skills.axes; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.util.ItemUtils; + +public class Axes { + public static int bonusDamageMaxBonus = AdvancedConfig.getInstance().getBonusDamageAxesBonusMax(); + public static int bonusDamageMaxBonusLevel = AdvancedConfig.getInstance().getBonusDamageAxesMaxBonusLevel(); + + public static int criticalHitMaxBonusLevel = AdvancedConfig.getInstance().getAxesCriticalMaxBonusLevel(); + public static double criticalHitMaxChance = AdvancedConfig.getInstance().getAxesCriticalChance(); + public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getAxesCriticalPVPModifier(); + public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getAxesCriticalPVEModifier(); + + public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel(); + public static double impactChance = AdvancedConfig.getInstance().getImpactChance(); + public static double impactMaxDurabilityModifier = AdvancedConfig.getInstance().getArmorImpactMaxDurabilityDamage() / 100D; + + public static int greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage(); + public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance(); + public static double greaterImpactKnockbackMultiplier = AdvancedConfig.getInstance().getGreaterImpactModifier(); + + public static int skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier(); + + protected static boolean hasArmor(LivingEntity target) { + for (ItemStack itemStack : target.getEquipment().getArmorContents()) { + if (ItemUtils.isArmor(itemStack)) { + return true; + } + } + + return false; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java b/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java index 9419946c4..6f53ff422 100644 --- a/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java +++ b/src/main/java/com/gmail/nossr50/skills/child/ChildConfig.java @@ -6,7 +6,7 @@ import java.util.List; import org.bukkit.configuration.file.YamlConfiguration; import com.gmail.nossr50.config.AutoUpdateConfigLoader; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.util.StringUtils; public class ChildConfig extends AutoUpdateConfigLoader { @@ -22,15 +22,18 @@ public class ChildConfig extends AutoUpdateConfigLoader { for (SkillType skill : SkillType.values()) { if (skill.isChildSkill()) { plugin.debug("Finding parents of " + skill.name()); + List parentNames = config.getStringList(StringUtils.getCapitalized(skill.name())); EnumSet parentSkills = EnumSet.noneOf(SkillType.class); boolean useDefaults = false; // If we had an error we back out and use defaults + for (String name : parentNames) { try { SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase()); FamilyTree.enforceNotChildSkill(parentSkill); parentSkills.add(parentSkill); - } catch (IllegalArgumentException ex) { + } + catch (IllegalArgumentException ex) { plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!"); useDefaults = true; break; @@ -55,6 +58,7 @@ public class ChildConfig extends AutoUpdateConfigLoader { } } } + FamilyTree.closeRegistration(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java b/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java index 382619507..49d597812 100644 --- a/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java +++ b/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java @@ -5,7 +5,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.Set; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.datatypes.skills.SkillType; public class FamilyTree { private static HashMap> tree = new HashMap>(); diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index 5fcfb2556..689603751 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -1,59 +1,58 @@ -package com.gmail.nossr50.skills.excavation; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.block.BlockState; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.TreasuresConfig; -import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.skills.utilities.SkillType; - -public class Excavation { - - /** - * Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block. - * - * @param blockState The {@link BlockState} of the block to check. - * @return the list of treasures that could be found - */ - protected static List getTreasures(BlockState blockState) { - switch (blockState.getType()) { - case DIRT: - return TreasuresConfig.getInstance().excavationFromDirt; - - case GRASS: - return TreasuresConfig.getInstance().excavationFromGrass; - - case SAND: - return TreasuresConfig.getInstance().excavationFromSand; - - case GRAVEL: - return TreasuresConfig.getInstance().excavationFromGravel; - - case CLAY: - return TreasuresConfig.getInstance().excavationFromClay; - - case MYCEL: - return TreasuresConfig.getInstance().excavationFromMycel; - - case SOUL_SAND: - return TreasuresConfig.getInstance().excavationFromSoulSand; - - default: - return new ArrayList(); - } - } - - protected static int getBlockXP(BlockState blockState) { - int xp = Config.getInstance().getXp(SkillType.EXCAVATION, blockState.getType()); - - if (xp == 0 && ModChecks.isCustomExcavationBlock(blockState)) { - xp = ModChecks.getCustomBlock(blockState).getXpGain(); - } - - return xp; - } -} +package com.gmail.nossr50.skills.excavation; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.block.BlockState; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.treasure.TreasureConfig; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; +import com.gmail.nossr50.util.ModUtils; + +public class Excavation { + /** + * Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block. + * + * @param blockState The {@link BlockState} of the block to check. + * @return the list of treasures that could be found + */ + protected static List getTreasures(BlockState blockState) { + switch (blockState.getType()) { + case DIRT: + return TreasureConfig.getInstance().excavationFromDirt; + + case GRASS: + return TreasureConfig.getInstance().excavationFromGrass; + + case SAND: + return TreasureConfig.getInstance().excavationFromSand; + + case GRAVEL: + return TreasureConfig.getInstance().excavationFromGravel; + + case CLAY: + return TreasureConfig.getInstance().excavationFromClay; + + case MYCEL: + return TreasureConfig.getInstance().excavationFromMycel; + + case SOUL_SAND: + return TreasureConfig.getInstance().excavationFromSoulSand; + + default: + return new ArrayList(); + } + } + + protected static int getBlockXP(BlockState blockState) { + int xp = Config.getInstance().getXp(SkillType.EXCAVATION, blockState.getType()); + + if (xp == 0 && ModUtils.isCustomExcavationBlock(blockState)) { + xp = ModUtils.getCustomBlock(blockState).getXpGain(); + } + + return xp; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index fdd2838e3..264691c6c 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -1,57 +1,57 @@ -package com.gmail.nossr50.skills.excavation; - -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.block.BlockState; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; - -public class ExcavationManager extends SkillManager { - public ExcavationManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.EXCAVATION); - } - - /** - * Process treasure drops & XP gain for Excavation. - * - * @param blockState The {@link BlockState} to check ability activation for - */ - public void excavationBlockCheck(BlockState blockState) { - int xp = Excavation.getBlockXP(blockState); - - if (Permissions.excavationTreasureHunter(getPlayer())) { - List treasures = Excavation.getTreasures(blockState); - - if (!treasures.isEmpty()) { - int skillLevel = getSkillLevel(); - Location location = blockState.getLocation(); - - for (ExcavationTreasure treasure : treasures) { - if (skillLevel >= treasure.getDropLevel() && SkillTools.treasureDropSuccessful(treasure.getDropChance(), activationChance)) { - xp += treasure.getXp(); - Misc.dropItem(location, treasure.getDrop()); - } - } - } - } - - applyXpGain(xp); - } - - /** - * Process the Giga Drill Breaker ability. - * - * @param blockState The {@link BlockState} to check ability activation for - */ - public void gigaDrillBreaker(BlockState blockState) { - excavationBlockCheck(blockState); - excavationBlockCheck(blockState); - } -} +package com.gmail.nossr50.skills.excavation; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.block.BlockState; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class ExcavationManager extends SkillManager { + public ExcavationManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.EXCAVATION); + } + + /** + * Process treasure drops & XP gain for Excavation. + * + * @param blockState The {@link BlockState} to check ability activation for + */ + public void excavationBlockCheck(BlockState blockState) { + int xp = Excavation.getBlockXP(blockState); + + if (Permissions.excavationTreasureHunter(getPlayer())) { + List treasures = Excavation.getTreasures(blockState); + + if (!treasures.isEmpty()) { + int skillLevel = getSkillLevel(); + Location location = blockState.getLocation(); + + for (ExcavationTreasure treasure : treasures) { + if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(treasure.getDropChance(), activationChance)) { + xp += treasure.getXp(); + Misc.dropItem(location, treasure.getDrop()); + } + } + } + } + + applyXpGain(xp); + } + + /** + * Process the Giga Drill Breaker ability. + * + * @param blockState The {@link BlockState} to check ability activation for + */ + public void gigaDrillBreaker(BlockState blockState) { + excavationBlockCheck(blockState); + excavationBlockCheck(blockState); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index bb1e03533..842c80246 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -1,201 +1,201 @@ -package com.gmail.nossr50.skills.fishing; - -import java.util.Map; -import java.util.Map.Entry; - -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.Potion; -import org.bukkit.potion.PotionType; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.util.Misc; - -public final class Fishing { - // The order of the values is extremely important, a few methods depend on it to work properly - protected enum Tier { - FIVE(5) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier5();} - @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank5();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5();}}, - FOUR(4) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier4();} - @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank4();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4();}}, - THREE(3) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier3();} - @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank3();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3();}}, - TWO(2) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier2();} - @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank2();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2();}}, - ONE(1) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier1();} - @Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank1();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1();}}; - - int numerical; - - private Tier(int numerical) { - this.numerical = numerical; - } - - public int toNumerical() { - return numerical; - } - - abstract protected int getLevel(); - abstract protected int getShakeChance(); - abstract protected int getVanillaXPBoostModifier(); - } - - // TODO: Get rid of that - public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange(); - public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2; - public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5; - public static final double STORM_MODIFIER = 0.909; - - private Fishing() {} - - /** - * Finds the possible drops of an entity - * - * @param target Targeted entity - * @param possibleDrops List of ItemStack that can be dropped - */ - protected static void findPossibleDrops(LivingEntity target, Map possibleDrops) { - switch (target.getType()) { - case BLAZE: - possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100); - break; - - case CAVE_SPIDER: - case SPIDER: - possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50); - possibleDrops.put(new ItemStack(Material.STRING), 50); - break; - - case CHICKEN: - possibleDrops.put(new ItemStack(Material.FEATHER), 34); - possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33); - possibleDrops.put(new ItemStack(Material.EGG), 33); - break; - - case COW: - possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2); - possibleDrops.put(new ItemStack(Material.LEATHER), 49); - possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49); - break; - - case CREEPER: - possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1); - possibleDrops.put(new ItemStack(Material.SULPHUR), 99); - break; - - case ENDERMAN: - possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100); - break; - - case GHAST: - possibleDrops.put(new ItemStack(Material.SULPHUR), 50); - possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50); - break; - - case IRON_GOLEM: - possibleDrops.put(new ItemStack(Material.PUMPKIN), 3); - possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12); - possibleDrops.put(new ItemStack(Material.RED_ROSE), 85); - break; - - case MAGMA_CUBE: - possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100); - break; - - case MUSHROOM_COW: - possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5); - possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5); - possibleDrops.put(new ItemStack(Material.LEATHER), 30); - possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30); - possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30); - break; - - case PIG: - possibleDrops.put(new ItemStack(Material.PORK), 100); - break; - - case PIG_ZOMBIE: - possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50); - possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50); - break; - - case SHEEP: - possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100); - break; - - case SKELETON: - possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2); - possibleDrops.put(new ItemStack(Material.BONE), 49); - possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49); - break; - - case SLIME: - possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100); - break; - - case SNOWMAN: - possibleDrops.put(new ItemStack(Material.PUMPKIN), 3); - possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97); - break; - - case SQUID: - possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100); - break; - - case WITCH: - possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1); - possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1); - possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1); - possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9); - possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13); - possibleDrops.put(new ItemStack(Material.SULPHUR), 12); - possibleDrops.put(new ItemStack(Material.REDSTONE), 13); - possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12); - possibleDrops.put(new ItemStack(Material.STICK), 13); - possibleDrops.put(new ItemStack(Material.SUGAR), 12); - possibleDrops.put(new ItemStack(Material.POTION), 13); - break; - - case ZOMBIE: - possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2); - possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98); - break; - - default: - return; - } - } - - /** - * Randomly chooses a drop among the list - * - * @param possibleDrops List of ItemStack that can be dropped - * @return Chosen ItemStack - */ - protected static ItemStack chooseDrop(Map possibleDrops) { - int dropProbability = Misc.getRandom().nextInt(100); - int cumulatedProbability = 0; - - for (Entry entry : possibleDrops.entrySet()) { - cumulatedProbability += entry.getValue(); - - if (dropProbability < cumulatedProbability) { - return entry.getKey(); - } - } - - return null; - } -} +package com.gmail.nossr50.skills.fishing; + +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionType; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.util.Misc; + +public final class Fishing { + // The order of the values is extremely important, a few methods depend on it to work properly + protected enum Tier { + FIVE(5) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier5(); } + @Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank5(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5(); }}, + FOUR(4) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier4(); } + @Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank4(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4(); }}, + THREE(3) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier3(); } + @Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank3(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3(); }}, + TWO(2) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier2(); } + @Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank2(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2(); }}, + ONE(1) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier1(); } + @Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank1(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1(); }}; + + int numerical; + + private Tier(int numerical) { + this.numerical = numerical; + } + + public int toNumerical() { + return numerical; + } + + abstract protected int getLevel(); + abstract protected int getShakeChance(); + abstract protected int getVanillaXPBoostModifier(); + } + + public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange(); + public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2; + public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5; + + public static final double STORM_MODIFIER = 0.909; + + private Fishing() {} + + /** + * Finds the possible drops of an entity + * + * @param target Targeted entity + * @param possibleDrops List of ItemStack that can be dropped + */ + protected static void findPossibleDrops(LivingEntity target, Map possibleDrops) { + switch (target.getType()) { + case BLAZE: + possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100); + break; + + case CAVE_SPIDER: + case SPIDER: + possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50); + possibleDrops.put(new ItemStack(Material.STRING), 50); + break; + + case CHICKEN: + possibleDrops.put(new ItemStack(Material.FEATHER), 34); + possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33); + possibleDrops.put(new ItemStack(Material.EGG), 33); + break; + + case COW: + possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2); + possibleDrops.put(new ItemStack(Material.LEATHER), 49); + possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49); + break; + + case CREEPER: + possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1); + possibleDrops.put(new ItemStack(Material.SULPHUR), 99); + break; + + case ENDERMAN: + possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100); + break; + + case GHAST: + possibleDrops.put(new ItemStack(Material.SULPHUR), 50); + possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50); + break; + + case IRON_GOLEM: + possibleDrops.put(new ItemStack(Material.PUMPKIN), 3); + possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12); + possibleDrops.put(new ItemStack(Material.RED_ROSE), 85); + break; + + case MAGMA_CUBE: + possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100); + break; + + case MUSHROOM_COW: + possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5); + possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5); + possibleDrops.put(new ItemStack(Material.LEATHER), 30); + possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30); + possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30); + break; + + case PIG: + possibleDrops.put(new ItemStack(Material.PORK), 100); + break; + + case PIG_ZOMBIE: + possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50); + possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50); + break; + + case SHEEP: + possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100); + break; + + case SKELETON: + possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2); + possibleDrops.put(new ItemStack(Material.BONE), 49); + possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49); + break; + + case SLIME: + possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100); + break; + + case SNOWMAN: + possibleDrops.put(new ItemStack(Material.PUMPKIN), 3); + possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97); + break; + + case SQUID: + possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100); + break; + + case WITCH: + possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1); + possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1); + possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1); + possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9); + possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13); + possibleDrops.put(new ItemStack(Material.SULPHUR), 12); + possibleDrops.put(new ItemStack(Material.REDSTONE), 13); + possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12); + possibleDrops.put(new ItemStack(Material.STICK), 13); + possibleDrops.put(new ItemStack(Material.SUGAR), 12); + possibleDrops.put(new ItemStack(Material.POTION), 13); + break; + + case ZOMBIE: + possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2); + possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98); + break; + + default: + return; + } + } + + /** + * Randomly chooses a drop among the list + * + * @param possibleDrops List of ItemStack that can be dropped + * @return Chosen ItemStack + */ + protected static ItemStack chooseDrop(Map possibleDrops) { + int dropProbability = Misc.getRandom().nextInt(100); + int cumulatedProbability = 0; + + for (Entry entry : possibleDrops.entrySet()) { + cumulatedProbability += entry.getValue(); + + if (dropProbability < cumulatedProbability) { + return entry.getKey(); + } + } + + return null; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index d7bb591b3..709534007 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -1,305 +1,305 @@ -package com.gmail.nossr50.skills.fishing; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Sheep; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Skeleton.SkeletonType; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.TreasuresConfig; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.treasure.FishingTreasure; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.fishing.Fishing.Tier; -import com.gmail.nossr50.skills.utilities.CombatTools; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.ItemChecks; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; - -public class FishingManager extends SkillManager { - public FishingManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.FISHING); - } - - public boolean canShake(Entity target) { - Player player = getPlayer(); - - return target instanceof LivingEntity && SkillTools.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player); - } - - /** - * Handle the Fisherman's Diet ability - * - * @param rankChange The # of levels to change rank for the food - * @param eventFoodLevel The initial change in hunger from the event - * @return the modified change in hunger for the event - */ - public int handleFishermanDiet(int rankChange, int eventFoodLevel) { - return SkillTools.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange); - } - - /** - * Process the results from a successful fishing trip - * - * @param fishingCatch The {@link Item} initially caught - */ - public void handleFishing(Item fishingCatch) { - int treasureXp = 0; - Player player = getPlayer(); - FishingTreasure treasure = null; - - if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) { - treasure = getFishingTreasure(); - } - - if (treasure != null) { - player.sendMessage(LocaleLoader.getString("Fishing.ItemFound")); - - treasureXp = treasure.getXp(); - ItemStack treasureDrop = treasure.getDrop(); - - if (Permissions.magicHunter(player) && ItemChecks.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) { - player.sendMessage(LocaleLoader.getString("Fishing.MagicFound")); - } - - // Drop the original catch at the feet of the player and set the treasure as the real catch - Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack()); - fishingCatch.setItemStack(treasureDrop); - } - - applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp); - } - - /** - * Handle the vanilla XP boost for Fishing - * - * @param experience The amount of experience initially awarded by the event - * @return the modified event damage - */ - public int handleVanillaXpBoost(int experience) { - return experience * getVanillaXpMultiplier(); - } - - /** - * Handle the Shake ability - * - * @param mob The {@link LivingEntity} affected by the ability - */ - public void shakeCheck(LivingEntity target) { - if (SkillTools.activationSuccessful(getPlayer(), skill, getShakeProbability())) { - Map possibleDrops = new HashMap(); - - Fishing.findPossibleDrops(target, possibleDrops); - - if (possibleDrops.isEmpty()) { - return; - } - - ItemStack drop = Fishing.chooseDrop(possibleDrops); - - // It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100 - if (drop == null) { - return; - } - - // Extra processing depending on the mob and drop type - switch (target.getType()) { - case SHEEP: - Sheep sheep = (Sheep) target; - - if (drop.getType() == Material.WOOL) { - if (sheep.isSheared()) { - return; - } - - drop.setDurability(sheep.getColor().getWoolData()); - sheep.setSheared(true); - } - break; - - case SKELETON: - Skeleton skeleton = (Skeleton) target; - - if (skeleton.getSkeletonType() == SkeletonType.WITHER) { - switch (drop.getType()) { - case SKULL_ITEM: - drop.setDurability((short) 1); - break; - - case ARROW: - drop.setType(Material.COAL); - break; - - default: - break; - } - } - break; - - default: - break; - } - - Misc.dropItem(target.getLocation(), drop); - CombatTools.dealDamage(target, target.getMaxHealth() / 4); // Make it so you can shake a mob no more than 4 times. - } - } - - /** - * Process the Treasure Hunter ability for Fishing - * - * @return The {@link FishingTreasure} found, or null if no treasure was found. - */ - private FishingTreasure getFishingTreasure() { - List rewards = new ArrayList(); - int skillLevel = getSkillLevel(); - - for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) { - int maxLevel = treasure.getMaxLevel(); - - if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) { - rewards.add(treasure); - } - } - - if (rewards.isEmpty()) { - return null; - } - - FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size())); - ItemStack treasureDrop = treasure.getDrop(); - - if (!SkillTools.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) { - return null; - } - - short maxDurability = treasureDrop.getType().getMaxDurability(); - - if (maxDurability > 0) { - treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability))); - } - - return treasure; - } - - /** - * Process the Magic Hunter ability - * - * @param treasureDrop The {@link ItemStack} to enchant - * @return true if the item has been enchanted - */ - private boolean handleMagicHunter(ItemStack treasureDrop) { - Player player = getPlayer(); - int activationChance = this.activationChance; - - if (player.getWorld().hasStorm()) { - activationChance *= Fishing.STORM_MODIFIER; - } - - if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) { - return false; - } - - List possibleEnchantments = new ArrayList(); - - for (Enchantment enchantment : Enchantment.values()) { - if (enchantment.canEnchantItem(treasureDrop)) { - possibleEnchantments.add(enchantment); - } - } - - // This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant - Collections.shuffle(possibleEnchantments, Misc.getRandom()); - - boolean enchanted = false; - int specificChance = 1; - - for (Enchantment possibleEnchantment : possibleEnchantments) { - boolean conflicts = false; - - for (Enchantment currentEnchantment : treasureDrop.getEnchantments().keySet()) { - conflicts = currentEnchantment.conflictsWith(possibleEnchantment); - - if (conflicts) { - break; - } - } - - if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) { - treasureDrop.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1); - - specificChance++; - enchanted = true; - } - } - - return enchanted; - } - - /** - * Gets the loot tier - * - * @return the loot tier - */ - public int getLootTier() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.toNumerical(); - } - } - - return 0; - } - - /** - * Gets the Shake Mob probability - * - * @return Shake Mob probability - */ - public int getShakeProbability() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getShakeChance(); - } - } - - return 0; - } - - /** - * Gets the vanilla XP multiplier - * - * @return the vanilla XP multiplier - */ - private int getVanillaXpMultiplier() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getVanillaXPBoostModifier(); - } - } - - return 0; - } -} +package com.gmail.nossr50.skills.fishing; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.treasure.TreasureConfig; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.treasure.FishingTreasure; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.fishing.Fishing.Tier; +import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.CombatUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class FishingManager extends SkillManager { + public FishingManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.FISHING); + } + + public boolean canShake(Entity target) { + Player player = getPlayer(); + + return target instanceof LivingEntity && SkillUtils.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player); + } + + /** + * Gets the loot tier + * + * @return the loot tier + */ + public int getLootTier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.toNumerical(); + } + } + + return 0; + } + + /** + * Gets the Shake Mob probability + * + * @return Shake Mob probability + */ + public int getShakeProbability() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getShakeChance(); + } + } + + return 0; + } + + /** + * Handle the Fisherman's Diet ability + * + * @param rankChange The # of levels to change rank for the food + * @param eventFoodLevel The initial change in hunger from the event + * @return the modified change in hunger for the event + */ + public int handleFishermanDiet(int rankChange, int eventFoodLevel) { + return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange); + } + + /** + * Process the results from a successful fishing trip + * + * @param fishingCatch The {@link Item} initially caught + */ + public void handleFishing(Item fishingCatch) { + int treasureXp = 0; + Player player = getPlayer(); + FishingTreasure treasure = null; + + if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) { + treasure = getFishingTreasure(); + } + + if (treasure != null) { + player.sendMessage(LocaleLoader.getString("Fishing.ItemFound")); + + treasureXp = treasure.getXp(); + ItemStack treasureDrop = treasure.getDrop(); + + if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) { + player.sendMessage(LocaleLoader.getString("Fishing.MagicFound")); + } + + // Drop the original catch at the feet of the player and set the treasure as the real catch + Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack()); + fishingCatch.setItemStack(treasureDrop); + } + + applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp); + } + + /** + * Handle the vanilla XP boost for Fishing + * + * @param experience The amount of experience initially awarded by the event + * @return the modified event damage + */ + public int handleVanillaXpBoost(int experience) { + return experience * getVanillaXpMultiplier(); + } + + /** + * Handle the Shake ability + * + * @param mob The {@link LivingEntity} affected by the ability + */ + public void shakeCheck(LivingEntity target) { + if (SkillUtils.activationSuccessful(getPlayer(), skill, getShakeProbability())) { + Map possibleDrops = new HashMap(); + + Fishing.findPossibleDrops(target, possibleDrops); + + if (possibleDrops.isEmpty()) { + return; + } + + ItemStack drop = Fishing.chooseDrop(possibleDrops); + + // It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100 + if (drop == null) { + return; + } + + // Extra processing depending on the mob and drop type + switch (target.getType()) { + case SHEEP: + Sheep sheep = (Sheep) target; + + if (drop.getType() == Material.WOOL) { + if (sheep.isSheared()) { + return; + } + + drop.setDurability(sheep.getColor().getWoolData()); + sheep.setSheared(true); + } + break; + + case SKELETON: + Skeleton skeleton = (Skeleton) target; + + if (skeleton.getSkeletonType() == SkeletonType.WITHER) { + switch (drop.getType()) { + case SKULL_ITEM: + drop.setDurability((short) 1); + break; + + case ARROW: + drop.setType(Material.COAL); + break; + + default: + break; + } + } + break; + + default: + break; + } + + Misc.dropItem(target.getLocation(), drop); + CombatUtils.dealDamage(target, target.getMaxHealth() / 4); // Make it so you can shake a mob no more than 4 times. + } + } + + /** + * Process the Treasure Hunter ability for Fishing + * + * @return The {@link FishingTreasure} found, or null if no treasure was found. + */ + private FishingTreasure getFishingTreasure() { + List rewards = new ArrayList(); + int skillLevel = getSkillLevel(); + + for (FishingTreasure treasure : TreasureConfig.getInstance().fishingRewards) { + int maxLevel = treasure.getMaxLevel(); + + if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) { + rewards.add(treasure); + } + } + + if (rewards.isEmpty()) { + return null; + } + + FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size())); + ItemStack treasureDrop = treasure.getDrop(); + + if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) { + return null; + } + + short maxDurability = treasureDrop.getType().getMaxDurability(); + + if (maxDurability > 0) { + treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability))); + } + + return treasure; + } + + /** + * Process the Magic Hunter ability + * + * @param treasureDrop The {@link ItemStack} to enchant + * @return true if the item has been enchanted + */ + private boolean handleMagicHunter(ItemStack treasureDrop) { + Player player = getPlayer(); + int activationChance = this.activationChance; + + if (player.getWorld().hasStorm()) { + activationChance *= Fishing.STORM_MODIFIER; + } + + if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) { + return false; + } + + List possibleEnchantments = new ArrayList(); + + for (Enchantment enchantment : Enchantment.values()) { + if (enchantment.canEnchantItem(treasureDrop)) { + possibleEnchantments.add(enchantment); + } + } + + // This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant + Collections.shuffle(possibleEnchantments, Misc.getRandom()); + + boolean enchanted = false; + int specificChance = 1; + + for (Enchantment possibleEnchantment : possibleEnchantments) { + boolean conflicts = false; + + for (Enchantment currentEnchantment : treasureDrop.getEnchantments().keySet()) { + conflicts = currentEnchantment.conflictsWith(possibleEnchantment); + + if (conflicts) { + break; + } + } + + if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) { + treasureDrop.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1); + + specificChance++; + enchanted = true; + } + } + + return enchanted; + } + + /** + * Gets the vanilla XP multiplier + * + * @return the vanilla XP multiplier + */ + private int getVanillaXpMultiplier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getVanillaXPBoostModifier(); + } + } + + return 0; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java deleted file mode 100644 index b29c05c3e..000000000 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.gmail.nossr50.skills.herbalism; - -import org.bukkit.CropState; -import org.bukkit.block.BlockState; -import org.bukkit.material.CocoaPlant; -import org.bukkit.material.CocoaPlant.CocoaPlantSize; - -/** - * Convert plants affected by the Green Terra ability. - * - * @param blockState The {@link BlockState} to check ability activation for - */ -public class GreenTerraTimer implements Runnable { - private BlockState blockState; - - public GreenTerraTimer(BlockState blockState) { - this.blockState = blockState; - } - - @Override - public void run() { - switch (blockState.getType()) { - case CROPS: - case CARROT: - case POTATO: - blockState.setRawData(CropState.MEDIUM.getData()); - blockState.update(true); - return; - - case NETHER_WARTS: - blockState.setRawData((byte) 0x2); - blockState.update(true); - return; - - case COCOA: - CocoaPlant plant = (CocoaPlant) blockState.getData(); - plant.setSize(CocoaPlantSize.MEDIUM); - blockState.setData(plant); - blockState.update(true); - return; - - default: - return; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java deleted file mode 100644 index 1cd2b6301..000000000 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.gmail.nossr50.skills.herbalism; - -import org.bukkit.block.BlockState; -import org.bukkit.material.CocoaPlant; -import org.bukkit.material.CocoaPlant.CocoaPlantSize; - -/** - * Convert plants affected by the Green Thumb ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param skillLevel The player's Herbalism skill level - */ -public class GreenThumbTimer implements Runnable { - private BlockState blockState; - private int skillLevel; - - public GreenThumbTimer(BlockState blockState, int skillLevel) { - this.blockState = blockState; - this.skillLevel = skillLevel; - } - - @Override - public void run() { - int greenThumbStage = Math.min(Math.min(skillLevel, Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4); - - switch(blockState.getType()) { - case CROPS: - case CARROT: - case POTATO: - blockState.setRawData((byte) greenThumbStage); - blockState.update(true); - return; - - case NETHER_WARTS: - if (greenThumbStage > 2) { - blockState.setRawData((byte) 0x2); - } - else if (greenThumbStage == 2) { - blockState.setRawData((byte) 0x1); - } - else { - blockState.setRawData((byte) 0x0); - } - blockState.update(true); - return; - - case COCOA: - CocoaPlant plant = (CocoaPlant) blockState.getData(); - - if (greenThumbStage > 1) { - plant.setSize(CocoaPlantSize.MEDIUM); - } - else { - plant.setSize(CocoaPlantSize.SMALL); - } - blockState.setData(plant); - blockState.update(true); - return; - - default: - return; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 96179e233..0578f39f2 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -1,108 +1,108 @@ -package com.gmail.nossr50.skills.herbalism; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.AdvancedConfig; - -public class Herbalism { - public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange(); - public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2; - public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5; - - public static int greenThumbStageChangeLevel = AdvancedConfig.getInstance().getGreenThumbStageChange(); - public static int greenThumbStageMaxLevel = greenThumbStageChangeLevel * 4; - - public static double greenThumbMaxChance = AdvancedConfig.getInstance().getGreenThumbChanceMax(); - public static int greenThumbMaxLevel = AdvancedConfig.getInstance().getGreenThumbMaxLevel(); - - public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getHerbalismDoubleDropsChanceMax(); - public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getHerbalismDoubleDropsMaxLevel(); - - public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax(); - public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel(); - - public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax(); - public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel(); - - /** - * Convert blocks affected by the Green Thumb & Green Terra abilities. - * - * @param blockState The {@link BlockState} to check ability activation for - * @return true if the ability was successful, false otherwise - */ - protected static boolean convertGreenTerraBlocks(BlockState blockState) { - switch (blockState.getType()) { - case COBBLE_WALL: - case SMOOTH_BRICK: - blockState.setRawData((byte) 0x1); - return true; - - case DIRT: - blockState.setType(Material.GRASS); - return true; - - case COBBLESTONE: - blockState.setType(Material.MOSSY_COBBLESTONE); - return true; - - default: - return false; - } - } - - /** - * Calculate the drop amounts for cacti & sugar cane based on the blocks above them. - * - * @param blockState The {@link BlockState} of the bottom block of the plant - * @return the number of bonus drops to award from the blocks in this plant - */ - protected static int calculateCatciAndSugarDrops(BlockState blockState) { - Block block = blockState.getBlock(); - Material blockType = blockState.getType(); - int dropAmount = 0; - - // Handle the original block - if (!mcMMO.placeStore.isTrue(blockState)) { - dropAmount++; - } - - // Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally - for (int y = 1; y < 3; y++) { - Block relativeBlock = block.getRelative(BlockFace.UP, y); - Material relativeBlockType = relativeBlock.getType(); - - // If the first one is air, so is the next one - if (relativeBlockType == Material.AIR) { - break; - } - - if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) { - dropAmount++; - } - } - - return dropAmount; - } - - /** - * Convert blocks affected by the Green Thumb & Green Terra abilities. - * - * @param blockState The {@link BlockState} to check ability activation for - * @return true if the ability was successful, false otherwise - */ - protected static boolean convertShroomThumb(BlockState blockState) { - switch (blockState.getType()){ - case DIRT: - case GRASS: - blockState.setType(Material.MYCEL); - return true; - - default: - return false; - } - } -} +package com.gmail.nossr50.skills.herbalism; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.AdvancedConfig; + +public class Herbalism { + public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange(); + public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2; + public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5; + + public static int greenThumbStageChangeLevel = AdvancedConfig.getInstance().getGreenThumbStageChange(); + public static int greenThumbStageMaxLevel = greenThumbStageChangeLevel * 4; + + public static int greenThumbMaxLevel = AdvancedConfig.getInstance().getGreenThumbMaxLevel(); + public static double greenThumbMaxChance = AdvancedConfig.getInstance().getGreenThumbChanceMax(); + + public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getHerbalismDoubleDropsMaxLevel(); + public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getHerbalismDoubleDropsChanceMax(); + + public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel(); + public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax(); + + public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel(); + public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax(); + + /** + * Convert blocks affected by the Green Thumb & Green Terra abilities. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + protected static boolean convertGreenTerraBlocks(BlockState blockState) { + switch (blockState.getType()) { + case COBBLE_WALL: + case SMOOTH_BRICK: + blockState.setRawData((byte) 0x1); + return true; + + case DIRT: + blockState.setType(Material.GRASS); + return true; + + case COBBLESTONE: + blockState.setType(Material.MOSSY_COBBLESTONE); + return true; + + default: + return false; + } + } + + /** + * Calculate the drop amounts for cacti & sugar cane based on the blocks above them. + * + * @param blockState The {@link BlockState} of the bottom block of the plant + * @return the number of bonus drops to award from the blocks in this plant + */ + protected static int calculateCatciAndSugarDrops(BlockState blockState) { + Block block = blockState.getBlock(); + Material blockType = blockState.getType(); + int dropAmount = 0; + + // Handle the original block + if (!mcMMO.placeStore.isTrue(blockState)) { + dropAmount++; + } + + // Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally + for (int y = 1; y < 3; y++) { + Block relativeBlock = block.getRelative(BlockFace.UP, y); + Material relativeBlockType = relativeBlock.getType(); + + // If the first one is air, so is the next one + if (relativeBlockType == Material.AIR) { + break; + } + + if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) { + dropAmount++; + } + } + + return dropAmount; + } + + /** + * Convert blocks affected by the Green Thumb & Green Terra abilities. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + protected static boolean convertShroomThumb(BlockState blockState) { + switch (blockState.getType()) { + case DIRT: + case GRASS: + blockState.setType(Material.MYCEL); + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismBlock.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismBlock.java index 1d47ea7b1..32a644b99 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismBlock.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismBlock.java @@ -1,75 +1,75 @@ -package com.gmail.nossr50.skills.herbalism; - -import java.util.Map; - -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -import com.google.common.collect.Maps; - -public enum HerbalismBlock { - BROWN_MUSHROOM(Material.BROWN_MUSHROOM), - CACTUS(Material.CACTUS), - CARROT(Material.CARROT, Material.CARROT_ITEM), - COCOA(Material.COCOA, new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())), - CROPS(Material.CROPS, Material.WHEAT), - MELON_BLOCK(Material.MELON_BLOCK, Material.MELON), - NETHER_WARTS(Material.NETHER_WARTS, Material.NETHER_STALK), - POTATO(Material.POTATO, Material.POTATO_ITEM), - PUMPKIN(Material.PUMPKIN), - RED_MUSHROOM(Material.RED_MUSHROOM), - RED_ROSE(Material.RED_ROSE), - SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK, Material.SUGAR_CANE), - VINE(Material.VINE), - WATER_LILY(Material.WATER_LILY), - YELLOW_FLOWER(Material.YELLOW_FLOWER); - - private Material blockType; - private ItemStack dropItem; - private final static Map BY_MATERIAL = Maps.newHashMap(); - - private HerbalismBlock(Material blockType) { - this(blockType, new ItemStack(blockType)); - } - - private HerbalismBlock(Material blockType, Material dropType) { - this(blockType, new ItemStack(dropType)); - } - - private HerbalismBlock(Material blockType, ItemStack dropItem) { - this.blockType = blockType; - this.dropItem = dropItem; - } - - static { - for (HerbalismBlock herbalismBlock : values()) { - BY_MATERIAL.put(herbalismBlock.blockType, herbalismBlock); - } - } - - public ItemStack getDropItem() { - return dropItem; - } - - public int getXpGain() { - return Config.getInstance().getXp(SkillType.HERBALISM, blockType); - } - - public boolean canDoubleDrop() { - return Config.getInstance().getDoubleDropsEnabled(SkillType.HERBALISM, blockType); - } - - public boolean hasGreenThumbPermission(Player player) { - return Permissions.greenThumbPlant(player, blockType); - } - - public static HerbalismBlock getHerbalismBlock(Material blockType) { - return BY_MATERIAL.get(blockType); - } -} +package com.gmail.nossr50.skills.herbalism; + +import java.util.Map; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.util.Permissions; +import com.google.common.collect.Maps; + +public enum HerbalismBlock { + BROWN_MUSHROOM(Material.BROWN_MUSHROOM), + CACTUS(Material.CACTUS), + CARROT(Material.CARROT, Material.CARROT_ITEM), + COCOA(Material.COCOA, new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())), + CROPS(Material.CROPS, Material.WHEAT), + MELON_BLOCK(Material.MELON_BLOCK, Material.MELON), + NETHER_WARTS(Material.NETHER_WARTS, Material.NETHER_STALK), + POTATO(Material.POTATO, Material.POTATO_ITEM), + PUMPKIN(Material.PUMPKIN), + RED_MUSHROOM(Material.RED_MUSHROOM), + RED_ROSE(Material.RED_ROSE), + SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK, Material.SUGAR_CANE), + VINE(Material.VINE), + WATER_LILY(Material.WATER_LILY), + YELLOW_FLOWER(Material.YELLOW_FLOWER); + + private Material blockType; + private ItemStack dropItem; + + private final static Map BY_MATERIAL = Maps.newHashMap(); + + private HerbalismBlock(Material blockType) { + this(blockType, new ItemStack(blockType)); + } + + private HerbalismBlock(Material blockType, Material dropType) { + this(blockType, new ItemStack(dropType)); + } + + private HerbalismBlock(Material blockType, ItemStack dropItem) { + this.blockType = blockType; + this.dropItem = dropItem; + } + + static { + for (HerbalismBlock herbalismBlock : values()) { + BY_MATERIAL.put(herbalismBlock.blockType, herbalismBlock); + } + } + + public ItemStack getDropItem() { + return dropItem; + } + + public int getXpGain() { + return Config.getInstance().getXp(SkillType.HERBALISM, blockType); + } + + public boolean canDoubleDrop() { + return Config.getInstance().getDoubleDropsEnabled(SkillType.HERBALISM, blockType); + } + + public boolean hasGreenThumbPermission(Player player) { + return Permissions.greenThumbPlant(player, blockType); + } + + public static HerbalismBlock getHerbalismBlock(Material blockType) { + return BY_MATERIAL.get(blockType); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 74d4d41d5..5919d5bc4 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -1,306 +1,308 @@ -package com.gmail.nossr50.skills.herbalism; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.TreasuresConfig; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.datatypes.treasure.HylianTreasure; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.mods.datatypes.CustomBlock; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.skills.utilities.ToolType; -import com.gmail.nossr50.util.BlockChecks; -import com.gmail.nossr50.util.ItemChecks; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; - -public class HerbalismManager extends SkillManager { - public HerbalismManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.HERBALISM); - } - - public boolean canBlockCheck() { - return !(Config.getInstance().getHerbalismAFKDisabled() && getPlayer().isInsideVehicle()); - } - - public boolean canGreenThumbBlock(BlockState blockState) { - Player player = getPlayer(); - - return player.getItemInHand().getType() == Material.SEEDS && BlockChecks.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); - } - - public boolean canUseShroomThumb(BlockState blockState) { - Player player = getPlayer(); - Material itemType = player.getItemInHand().getType(); - - return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockChecks.canMakeShroomy(blockState) && Permissions.shroomThumb(player); - } - - public boolean canUseHylianLuck() { - Player player = getPlayer(); - - return ItemChecks.isSword(player.getItemInHand()) && Permissions.hylianLuck(player); - } - - public boolean canGreenTerraBlock(BlockState blockState) { - return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(blockState); - } - - public boolean canActivateAbility() { - return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer()); - } - - public boolean canGreenTerraPlant() { - return getProfile().getAbilityMode(AbilityType.GREEN_TERRA); - } - - /** - * Handle the Farmer's Diet ability - * - * @param rankChange The # of levels to change rank for the food - * @param eventFoodLevel The initial change in hunger from the event - * @return the modified change in hunger for the event - */ - public int farmersDiet(int rankChange, int eventFoodLevel) { - return SkillTools.handleFoodSkills(getPlayer(), SkillType.HERBALISM, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange); - } - - /** - * Process the Green Terra ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @return true if the ability was successful, false otherwise - */ - public boolean processGreenTerra(BlockState blockState) { - Player player = getPlayer(); - - if (!Permissions.greenThumbBlock(player, blockState.getType())) { - return false; - } - - PlayerInventory playerInventory = player.getInventory(); - ItemStack seed = new ItemStack(Material.SEEDS); - - if (!playerInventory.containsAtLeast(seed, 1)) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore")); - return false; - } - - playerInventory.removeItem(seed); - player.updateInventory(); // Needed until replacement available - - return Herbalism.convertGreenTerraBlocks(blockState); - } - - /** - * Process double drops & XP gain for Herbalism. - * - * @param blockState The {@link BlockState} to check ability activation for - * @return true if the ability was successful, false otherwise - */ - public void herbalismBlockCheck(BlockState blockState) { - Player player = getPlayer(); - Material blockType = blockState.getType(); - - HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType); - CustomBlock customBlock = null; - - int xp = 0; - int dropAmount = 1; - ItemStack dropItem = null; - - if (herbalismBlock != null) { - if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) { - dropItem = herbalismBlock.getDropItem(); - dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState); - xp = herbalismBlock.getXpGain() * dropAmount; - } - else if (herbalismBlock.hasGreenThumbPermission(player)){ - dropItem = herbalismBlock.getDropItem(); - xp = herbalismBlock.getXpGain(); - processGreenThumbPlants(blockState); - } - else { - if (!mcMMO.placeStore.isTrue(blockState)) { - dropItem = herbalismBlock.getDropItem(); - xp = herbalismBlock.getXpGain(); - } - } - } - else { - customBlock = ModChecks.getCustomBlock(blockState); - dropItem = customBlock.getItemDrop(); - xp = customBlock.getXpGain(); - } - - if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) { - Location location = blockState.getLocation(); - - if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) { - Misc.dropItems(location, dropItem, dropAmount); - } - else if (customBlock != null){ - int minimumDropAmount = customBlock.getMinimumDropAmount(); - int maximumDropAmount = customBlock.getMaximumDropAmount(); - - if (minimumDropAmount != maximumDropAmount) { - Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); - } - - Misc.dropItems(location, dropItem, minimumDropAmount); - } - } - - applyXpGain(xp); - } - - /** - * Process the Green Thumb ability for blocks. - * - * @param blockState The {@link BlockState} to check ability activation for - * @return true if the ability was successful, false otherwise - */ - public boolean processGreenThumbBlocks(BlockState blockState) { - Player player = getPlayer(); - - if (!SkillTools.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail")); - return false; - } - - return Herbalism.convertGreenTerraBlocks(blockState); - } - - /** - * Process the Hylian Luck ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @return true if the ability was successful, false otherwise - */ - public boolean processHylianLuck(BlockState blockState) { - Player player = getPlayer(); - - if (!SkillTools.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) { - return false; - } - - List treasures = new ArrayList(); - - switch (blockState.getType()) { - case DEAD_BUSH: - case LONG_GRASS: - case SAPLING: - treasures = TreasuresConfig.getInstance().hylianFromBushes; - break; - - case RED_ROSE: - case YELLOW_FLOWER: - if (mcMMO.placeStore.isTrue(blockState)) { - mcMMO.placeStore.setFalse(blockState); - return false; - } - - treasures = TreasuresConfig.getInstance().hylianFromFlowers; - break; - - case FLOWER_POT: - treasures = TreasuresConfig.getInstance().hylianFromPots; - break; - - default: - return false; - } - - if (treasures.isEmpty()) { - return false; - } - - blockState.setRawData((byte) 0x0); - blockState.setType(Material.AIR); - - Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop()); - player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); - return true; - } - - /** - * Process the Shroom Thumb ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @return true if the ability was successful, false otherwise - */ - public boolean processShroomThumb(BlockState blockState) { - Player player = getPlayer(); - PlayerInventory playerInventory = player.getInventory(); - - if (!playerInventory.contains(Material.BROWN_MUSHROOM)) { - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM))); - return false; - } - - if (!playerInventory.contains(Material.RED_MUSHROOM)) { - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM))); - return false; - } - - playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM)); - playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM)); - player.updateInventory(); - - if (!SkillTools.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail")); - return false; - } - - return Herbalism.convertShroomThumb(blockState); - } - - /** - * Process the Green Thumb ability for plants. - * - * @param blockState The {@link BlockState} to check ability activation for - */ - private void processGreenThumbPlants(BlockState blockState) { - Player player = getPlayer(); - PlayerInventory playerInventory = player.getInventory(); - ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); - - if (!playerInventory.containsAtLeast(seed, 1)) { - return; - } - - PlayerProfile playerProfile = Users.getPlayer(player).getProfile(); - - if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) { - playerInventory.removeItem(seed); - player.updateInventory(); // Needed until replacement available - - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimer(blockState), 0); - return; - } - else if (SkillTools.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { - playerInventory.removeItem(seed); - player.updateInventory(); // Needed until replacement available - - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimer(blockState, getSkillLevel()), 0); - return; - } - } -} +package com.gmail.nossr50.skills.herbalism; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.treasure.TreasureConfig; +import com.gmail.nossr50.datatypes.mods.CustomBlock; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.skills.ToolType; +import com.gmail.nossr50.datatypes.treasure.HylianTreasure; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask; +import com.gmail.nossr50.runnables.skills.herbalism.GreenThumbTimerTask; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.util.BlockUtils; +import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.ModUtils; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class HerbalismManager extends SkillManager { + public HerbalismManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.HERBALISM); + } + + public boolean canBlockCheck() { + return !(Config.getInstance().getHerbalismAFKDisabled() && getPlayer().isInsideVehicle()); + } + + public boolean canGreenThumbBlock(BlockState blockState) { + Player player = getPlayer(); + + return player.getItemInHand().getType() == Material.SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); + } + + public boolean canUseShroomThumb(BlockState blockState) { + Player player = getPlayer(); + Material itemType = player.getItemInHand().getType(); + + return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockUtils.canMakeShroomy(blockState) && Permissions.shroomThumb(player); + } + + public boolean canUseHylianLuck() { + Player player = getPlayer(); + + return ItemUtils.isSword(player.getItemInHand()) && Permissions.hylianLuck(player); + } + + public boolean canGreenTerraBlock(BlockState blockState) { + return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState); + } + + public boolean canActivateAbility() { + return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer()); + } + + public boolean canGreenTerraPlant() { + return getProfile().getAbilityMode(AbilityType.GREEN_TERRA); + } + + /** + * Handle the Farmer's Diet ability + * + * @param rankChange The # of levels to change rank for the food + * @param eventFoodLevel The initial change in hunger from the event + * @return the modified change in hunger for the event + */ + public int farmersDiet(int rankChange, int eventFoodLevel) { + return SkillUtils.handleFoodSkills(getPlayer(), SkillType.HERBALISM, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange); + } + + /** + * Process the Green Terra ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processGreenTerra(BlockState blockState) { + Player player = getPlayer(); + + if (!Permissions.greenThumbBlock(player, blockState.getType())) { + return false; + } + + PlayerInventory playerInventory = player.getInventory(); + ItemStack seed = new ItemStack(Material.SEEDS); + + if (!playerInventory.containsAtLeast(seed, 1)) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore")); + return false; + } + + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + + return Herbalism.convertGreenTerraBlocks(blockState); + } + + /** + * Process double drops & XP gain for Herbalism. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public void herbalismBlockCheck(BlockState blockState) { + Player player = getPlayer(); + Material blockType = blockState.getType(); + + HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType); + CustomBlock customBlock = null; + + int xp = 0; + int dropAmount = 1; + ItemStack dropItem = null; + + if (herbalismBlock != null) { + if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) { + dropItem = herbalismBlock.getDropItem(); + dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState); + xp = herbalismBlock.getXpGain() * dropAmount; + } + else if (herbalismBlock.hasGreenThumbPermission(player)) { + dropItem = herbalismBlock.getDropItem(); + xp = herbalismBlock.getXpGain(); + processGreenThumbPlants(blockState); + } + else { + if (!mcMMO.placeStore.isTrue(blockState)) { + dropItem = herbalismBlock.getDropItem(); + xp = herbalismBlock.getXpGain(); + } + } + } + else { + customBlock = ModUtils.getCustomBlock(blockState); + dropItem = customBlock.getItemDrop(); + xp = customBlock.getXpGain(); + } + + if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) { + Location location = blockState.getLocation(); + + if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) { + Misc.dropItems(location, dropItem, dropAmount); + } + else if (customBlock != null) { + int minimumDropAmount = customBlock.getMinimumDropAmount(); + int maximumDropAmount = customBlock.getMaximumDropAmount(); + + if (minimumDropAmount != maximumDropAmount) { + Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); + } + + Misc.dropItems(location, dropItem, minimumDropAmount); + } + } + + applyXpGain(xp); + } + + /** + * Process the Green Thumb ability for blocks. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processGreenThumbBlocks(BlockState blockState) { + Player player = getPlayer(); + + if (!SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail")); + return false; + } + + return Herbalism.convertGreenTerraBlocks(blockState); + } + + /** + * Process the Hylian Luck ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processHylianLuck(BlockState blockState) { + Player player = getPlayer(); + + if (!SkillUtils.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) { + return false; + } + + List treasures = new ArrayList(); + + switch (blockState.getType()) { + case DEAD_BUSH: + case LONG_GRASS: + case SAPLING: + treasures = TreasureConfig.getInstance().hylianFromBushes; + break; + + case RED_ROSE: + case YELLOW_FLOWER: + if (mcMMO.placeStore.isTrue(blockState)) { + mcMMO.placeStore.setFalse(blockState); + return false; + } + + treasures = TreasureConfig.getInstance().hylianFromFlowers; + break; + + case FLOWER_POT: + treasures = TreasureConfig.getInstance().hylianFromPots; + break; + + default: + return false; + } + + if (treasures.isEmpty()) { + return false; + } + + blockState.setRawData((byte) 0x0); + blockState.setType(Material.AIR); + + Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop()); + player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); + return true; + } + + /** + * Process the Shroom Thumb ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processShroomThumb(BlockState blockState) { + Player player = getPlayer(); + PlayerInventory playerInventory = player.getInventory(); + + if (!playerInventory.contains(Material.BROWN_MUSHROOM)) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM))); + return false; + } + + if (!playerInventory.contains(Material.RED_MUSHROOM)) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM))); + return false; + } + + playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM)); + playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM)); + player.updateInventory(); + + if (!SkillUtils.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail")); + return false; + } + + return Herbalism.convertShroomThumb(blockState); + } + + /** + * Process the Green Thumb ability for plants. + * + * @param blockState The {@link BlockState} to check ability activation for + */ + private void processGreenThumbPlants(BlockState blockState) { + Player player = getPlayer(); + PlayerInventory playerInventory = player.getInventory(); + ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); + + if (!playerInventory.containsAtLeast(seed, 1)) { + return; + } + + PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); + + if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) { + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimerTask(blockState), 0); + return; + } + else if (SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimerTask(blockState, getSkillLevel()), 0); + return; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java index 0152b0909..05617872d 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java @@ -1,103 +1,103 @@ -package com.gmail.nossr50.skills.mining; - -import java.util.HashSet; - -import org.bukkit.Material; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; - -public class BlastMining { - // The order of the values is extremely important, a few methods depend on it to work properly - protected enum Tier { - EIGHT(8) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank8();} - @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank8();} - @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank8();} - @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank8();} - @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank8();} - @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank8();}}, - SEVEN(7) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank7();} - @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank7();} - @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank7();} - @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank7();} - @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank7();} - @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank7();}}, - SIX(6) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank6();} - @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank6();} - @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank6();} - @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank6();} - @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank6();} - @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank6();}}, - FIVE(5) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank5();} - @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank5();} - @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank5();} - @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank5();} - @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank5();} - @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank5();}}, - FOUR(4) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank4();} - @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank4();} - @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank4();} - @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank4();} - @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank4();} - @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank4();}}, - THREE(3) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank3();} - @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank3();} - @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank3();} - @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank3();} - @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank3();} - @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank3();}}, - TWO(2) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank2();} - @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank2();} - @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank2();} - @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank2();} - @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank2();} - @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank2();}}, - ONE(1) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank1();} - @Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank1();} - @Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank1();} - @Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank1();} - @Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank1();} - @Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank1();}}; - - int numerical; - - private Tier(int numerical) { - this.numerical = numerical; - } - - public int toNumerical() { - return numerical; - } - - abstract protected int getLevel(); - abstract protected double getBlastRadiusModifier(); - abstract protected double getOreBonus(); - abstract protected double getDebrisReduction(); - abstract protected double getBlastDamageDecrease(); - abstract protected int getDropMultiplier(); - } - - public static int detonatorID = Config.getInstance().getDetonatorItemID(); - - public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100; - - protected static HashSet generateTransparentBlockList() { - HashSet transparentBlocks = new HashSet(); - - for (Material material : Material.values()) { - if (material.isTransparent()) { - transparentBlocks.add((byte) material.getId()); - } - } - - return transparentBlocks; - } -} +package com.gmail.nossr50.skills.mining; + +import java.util.HashSet; + +import org.bukkit.Material; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; + +public class BlastMining { + // The order of the values is extremely important, a few methods depend on it to work properly + protected enum Tier { + EIGHT(8) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank8(); } + @Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank8(); } + @Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank8(); } + @Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank8(); } + @Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank8(); } + @Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank8(); }}, + SEVEN(7) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank7(); } + @Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank7(); } + @Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank7(); } + @Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank7(); } + @Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank7(); } + @Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank7(); }}, + SIX(6) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank6(); } + @Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank6(); } + @Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank6(); } + @Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank6(); } + @Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank6(); } + @Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank6(); }}, + FIVE(5) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank5(); } + @Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank5(); } + @Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank5(); } + @Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank5(); } + @Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank5(); } + @Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank5(); }}, + FOUR(4) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank4(); } + @Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank4(); } + @Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank4(); } + @Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank4(); } + @Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank4(); } + @Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank4(); }}, + THREE(3) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank3(); } + @Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank3(); } + @Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank3(); } + @Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank3(); } + @Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank3(); } + @Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank3(); }}, + TWO(2) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank2(); } + @Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank2(); } + @Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank2(); } + @Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank2(); } + @Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank2(); } + @Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank2(); }}, + ONE(1) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank1(); } + @Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank1(); } + @Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank1(); } + @Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank1(); } + @Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank1(); } + @Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank1(); }}; + + int numerical; + + private Tier(int numerical) { + this.numerical = numerical; + } + + public int toNumerical() { + return numerical; + } + + abstract protected int getLevel(); + abstract protected double getBlastRadiusModifier(); + abstract protected double getOreBonus(); + abstract protected double getDebrisReduction(); + abstract protected double getBlastDamageDecrease(); + abstract protected int getDropMultiplier(); + } + + public static int detonatorID = Config.getInstance().getDetonatorItemID(); + + public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100; + + protected static HashSet generateTransparentBlockList() { + HashSet transparentBlocks = new HashSet(); + + for (Material material : Material.values()) { + if (material.isTransparent()) { + transparentBlocks.add((byte) material.getId()); + } + } + + return transparentBlocks; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java index 7dd154666..ddf9e80f6 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -1,148 +1,146 @@ -package com.gmail.nossr50.skills.mining; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.mods.datatypes.CustomBlock; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; - -public class Mining { - private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); - - public static int doubleDropsMaxLevel = advancedConfig.getMiningDoubleDropMaxLevel(); - public static double doubleDropsMaxChance = advancedConfig.getMiningDoubleDropChance(); - - /** - * Calculate XP gain for Mining. - * - * @param blockState The {@link BlockState} to check ability activation for - */ - protected static int getBlockXp(BlockState blockState) { - Material blockType = blockState.getType(); - int xp = Config.getInstance().getXp(SkillType.MINING, blockType); - - if (blockType == Material.GLOWING_REDSTONE_ORE) { - xp = Config.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE); - } - else if (xp == 0 && ModChecks.isCustomMiningBlock(blockState)) { - xp = ModChecks.getCustomBlock(blockState).getXpGain(); - } - - return xp; - } - - /** - * Handle double drops when using Silk Touch. - * - * @param blockState The {@link BlockState} to check ability activation for - */ - protected static void handleSilkTouchDrops(BlockState blockState) { - Material blockType = blockState.getType(); - - if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) { - return; - } - - switch (blockType) { - case ENDER_STONE: - case GOLD_ORE: - case IRON_ORE: - case MOSSY_COBBLESTONE: - case NETHERRACK: - case OBSIDIAN: - case SANDSTONE: - handleMiningDrops(blockState); - return; - - case GLOWING_REDSTONE_ORE: - if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) { - Misc.dropItem(blockState.getLocation(), new ItemStack(Material.REDSTONE_ORE)); - } - return; - - case COAL_ORE: - case DIAMOND_ORE: - case REDSTONE_ORE: - case GLOWSTONE: - case LAPIS_ORE: - case STONE: - case EMERALD_ORE: - Misc.dropItem(blockState.getLocation(), new ItemStack(blockType)); - return; - - default: - if (ModChecks.isCustomMiningBlock(blockState)) { - Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); - } - return; - } - } - - /** - * Handle double drops from Mining & Blast Mining. - * - * @param blockState The {@link BlockState} to check ability activation for - */ - protected static void handleMiningDrops(BlockState blockState) { - Material blockType = blockState.getType(); - - if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) { - return; - } - - Location location = blockState.getLocation(); - ItemStack dropItem; - - switch (blockType) { - case COAL_ORE: - case DIAMOND_ORE: - case EMERALD_ORE: - case GLOWSTONE: - case LAPIS_ORE: - case STONE: - case ENDER_STONE: - case GOLD_ORE: - case IRON_ORE: - case MOSSY_COBBLESTONE: - case NETHERRACK: - case OBSIDIAN: - case SANDSTONE: - for (ItemStack drop : blockState.getBlock().getDrops()) { - Misc.dropItem(location, drop); - } - return; - - case GLOWING_REDSTONE_ORE: - case REDSTONE_ORE: - if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) { - for (ItemStack drop : blockState.getBlock().getDrops()) { - Misc.dropItem(location, drop); - } - } - return; - default: - if (ModChecks.isCustomMiningBlock(blockState)) { - CustomBlock customBlock = ModChecks.getCustomBlock(blockState); - int minimumDropAmount = customBlock.getMinimumDropAmount(); - int maximumDropAmount = customBlock.getMaximumDropAmount(); - - dropItem = customBlock.getItemDrop(); - - if (minimumDropAmount != maximumDropAmount) { - Misc.dropItems(location, dropItem, minimumDropAmount); - Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); - } - else { - Misc.dropItems(location, dropItem, minimumDropAmount); - } - } - return; - } - } -} +package com.gmail.nossr50.skills.mining; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.mods.CustomBlock; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.ModUtils; + +public class Mining { + public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getMiningDoubleDropMaxLevel(); + public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getMiningDoubleDropChance(); + + /** + * Calculate XP gain for Mining. + * + * @param blockState The {@link BlockState} to check ability activation for + */ + protected static int getBlockXp(BlockState blockState) { + Material blockType = blockState.getType(); + int xp = Config.getInstance().getXp(SkillType.MINING, blockType); + + if (blockType == Material.GLOWING_REDSTONE_ORE) { + xp = Config.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE); + } + else if (xp == 0 && ModUtils.isCustomMiningBlock(blockState)) { + xp = ModUtils.getCustomBlock(blockState).getXpGain(); + } + + return xp; + } + + /** + * Handle double drops when using Silk Touch. + * + * @param blockState The {@link BlockState} to check ability activation for + */ + protected static void handleSilkTouchDrops(BlockState blockState) { + Material blockType = blockState.getType(); + + if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) { + return; + } + + switch (blockType) { + case ENDER_STONE: + case GOLD_ORE: + case IRON_ORE: + case MOSSY_COBBLESTONE: + case NETHERRACK: + case OBSIDIAN: + case SANDSTONE: + handleMiningDrops(blockState); + return; + + case GLOWING_REDSTONE_ORE: + if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) { + Misc.dropItem(blockState.getLocation(), new ItemStack(Material.REDSTONE_ORE)); + } + return; + + case COAL_ORE: + case DIAMOND_ORE: + case REDSTONE_ORE: + case GLOWSTONE: + case LAPIS_ORE: + case STONE: + case EMERALD_ORE: + Misc.dropItem(blockState.getLocation(), new ItemStack(blockType)); + return; + + default: + if (ModUtils.isCustomMiningBlock(blockState)) { + Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); + } + return; + } + } + + /** + * Handle double drops from Mining & Blast Mining. + * + * @param blockState The {@link BlockState} to check ability activation for + */ + protected static void handleMiningDrops(BlockState blockState) { + Material blockType = blockState.getType(); + + if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) { + return; + } + + Location location = blockState.getLocation(); + ItemStack dropItem; + + switch (blockType) { + case COAL_ORE: + case DIAMOND_ORE: + case EMERALD_ORE: + case GLOWSTONE: + case LAPIS_ORE: + case STONE: + case ENDER_STONE: + case GOLD_ORE: + case IRON_ORE: + case MOSSY_COBBLESTONE: + case NETHERRACK: + case OBSIDIAN: + case SANDSTONE: + for (ItemStack drop : blockState.getBlock().getDrops()) { + Misc.dropItem(location, drop); + } + return; + + case GLOWING_REDSTONE_ORE: + case REDSTONE_ORE: + if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) { + for (ItemStack drop : blockState.getBlock().getDrops()) { + Misc.dropItem(location, drop); + } + } + return; + default: + if (ModUtils.isCustomMiningBlock(blockState)) { + CustomBlock customBlock = ModUtils.getCustomBlock(blockState); + int minimumDropAmount = customBlock.getMinimumDropAmount(); + int maximumDropAmount = customBlock.getMaximumDropAmount(); + + dropItem = customBlock.getItemDrop(); + + if (minimumDropAmount != maximumDropAmount) { + Misc.dropItems(location, dropItem, minimumDropAmount); + Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); + } + else { + Misc.dropItems(location, dropItem, minimumDropAmount); + } + } + return; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 2f219f4e3..a5a1f8116 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -1,288 +1,288 @@ -package com.gmail.nossr50.skills.mining; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.mining.BlastMining.Tier; -import com.gmail.nossr50.skills.utilities.AbilityType; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.BlockChecks; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; - -public class MiningManager extends SkillManager{ - public MiningManager (McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.MINING); - } - - public boolean canUseDemolitionsExpertise() { - Player player = getPlayer(); - - return SkillTools.unlockLevelReached(player, skill, BlastMining.Tier.FOUR.getLevel()) && Permissions.demolitionsExpertise(player); - } - - public boolean canDetonate() { - Player player = getPlayer(); - - return player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player) && SkillTools.unlockLevelReached(player, skill, BlastMining.Tier.ONE.getLevel()); - } - - public boolean canUseBlastMining() { - return SkillTools.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.ONE.getLevel()); - } - - public boolean canUseBiggerBombs() { - Player player = getPlayer(); - - return Permissions.biggerBombs(player) && SkillTools.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.TWO.getLevel()); - } - - /** - * Process double drops & XP gain for Mining. - * - * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability - */ - public void miningBlockCheck(BlockState blockState) { - Player player = getPlayer(); - int xp = Mining.getBlockXp(blockState); - - if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { - if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { - Mining.handleSilkTouchDrops(blockState); - } - else { - Mining.handleMiningDrops(blockState); - } - } - - applyXpGain(xp); - } - - /** - * Detonate TNT for Blast Mining - */ - public void remoteDetonation() { - Player player = getPlayer(); - - HashSet transparentBlocks = BlastMining.generateTransparentBlockList(); - Block targetBlock = player.getTargetBlock(transparentBlocks, BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE); - - if (targetBlock.getType() != Material.TNT || !SkillTools.blockBreakSimulate(targetBlock, player, true) || !blastMiningCooldownOver()) { - return; - } - - PlayerProfile profile = getProfile(); - TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class); - - SkillTools.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player)); - player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom")); - - mcMMO.p.addToTNTTracker(tnt.getEntityId(), player.getName()); - tnt.setFuseTicks(0); - targetBlock.setData((byte) 0x0); - targetBlock.setType(Material.AIR); - - profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis()); - profile.setAbilityInformed(AbilityType.BLAST_MINING, false); - } - - /** - * Handler for explosion drops and XP gain. - * - * @param event Event whose explosion is being processed - */ - public void blastMiningDropProcessing(float yield, List blockList) { - List ores = new ArrayList(); - List debris = new ArrayList(); - int xp = 0; - - float oreBonus = (float) (getOreBonus() / 100); - float debrisReduction = (float) (getDebrisReduction() / 100); - int dropMultiplier = getDropMultiplier(); - - float debrisYield = yield - debrisReduction; - - for (Block block : blockList) { - BlockState blockState = block.getState(); - - if (BlockChecks.isOre(blockState)) { - ores.add(blockState); - } - else { - debris.add(blockState); - } - } - - for (BlockState blockState : ores) { - if (Misc.getRandom().nextFloat() < (yield + oreBonus)) { - if (!mcMMO.placeStore.isTrue(blockState)) { - xp += Mining.getBlockXp(blockState); - } - - Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); // Initial block that would have been dropped - - if (!mcMMO.placeStore.isTrue(blockState)) { - for (int i = 1 ; i < dropMultiplier ; i++) { - xp += Mining.getBlockXp(blockState); - Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items - } - } - } - } - - if (debrisYield > 0) { - for (BlockState blockState : debris) { - if (Misc.getRandom().nextFloat() < debrisYield) { - Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); - } - } - } - - applyXpGain(xp); - } - - /** - * Increases the blast radius of the explosion. - * - * @param event Event whose explosion radius is being changed - */ - public float biggerBombs(float radius) { - return (float) (radius + getBlastRadiusModifier()); - } - - public int processDemolitionsExpertise(int damage) { - return (int) (damage * (100.0 - getBlastDamageModifier())); - } - - private boolean blastMiningCooldownOver() { - Player player = getPlayer(); - PlayerProfile profile = getProfile(); - - long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR; - int cooldown = AbilityType.BLAST_MINING.getCooldown(); - - if (!SkillTools.cooldownOver(oldTime, cooldown, player)) { - player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillTools.calculateTimeLeft(oldTime, cooldown, player))); - return false; - } - - return true; - } - - /** - * Gets the Blast Mining tier - * - * @return the Blast Mining tier - */ - public int getBlastMiningTier() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.toNumerical(); - } - } - - return 0; - } - - /** - * Gets the Blast Mining tier - * - * @return the Blast Mining tier - */ - public double getOreBonus() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getOreBonus(); - } - } - - return 0; - } - - /** - * Gets the Blast Mining tier - * - * @return the Blast Mining tier - */ - public double getDebrisReduction() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getDebrisReduction(); - } - } - - return 0; - } - - /** - * Gets the Blast Mining tier - * - * @return the Blast Mining tier - */ - public int getDropMultiplier() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getDropMultiplier(); - } - } - - return 0; - } - - /** - * Gets the Blast Mining tier - * - * @return the Blast Mining tier - */ - public double getBlastRadiusModifier() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getBlastRadiusModifier(); - } - } - - return 0; - } - - /** - * Gets the Blast Mining tier - * - * @return the Blast Mining tier - */ - public double getBlastDamageModifier() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getBlastDamageDecrease(); - } - } - - return 0; - } -} +package com.gmail.nossr50.skills.mining; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.mining.BlastMining.Tier; +import com.gmail.nossr50.util.BlockUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class MiningManager extends SkillManager{ + public MiningManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.MINING); + } + + public boolean canUseDemolitionsExpertise() { + Player player = getPlayer(); + + return SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.FOUR.getLevel()) && Permissions.demolitionsExpertise(player); + } + + public boolean canDetonate() { + Player player = getPlayer(); + + return player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player) && SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.ONE.getLevel()); + } + + public boolean canUseBlastMining() { + return SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.ONE.getLevel()); + } + + public boolean canUseBiggerBombs() { + Player player = getPlayer(); + + return Permissions.biggerBombs(player) && SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.TWO.getLevel()); + } + + /** + * Process double drops & XP gain for Mining. + * + * @param blockState The {@link BlockState} to check ability activation for + * @param player The {@link Player} using this ability + */ + public void miningBlockCheck(BlockState blockState) { + Player player = getPlayer(); + int xp = Mining.getBlockXp(blockState); + + if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { + if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { + Mining.handleSilkTouchDrops(blockState); + } + else { + Mining.handleMiningDrops(blockState); + } + } + + applyXpGain(xp); + } + + /** + * Detonate TNT for Blast Mining + */ + public void remoteDetonation() { + Player player = getPlayer(); + + HashSet transparentBlocks = BlastMining.generateTransparentBlockList(); + Block targetBlock = player.getTargetBlock(transparentBlocks, BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE); + + if (targetBlock.getType() != Material.TNT || !SkillUtils.blockBreakSimulate(targetBlock, player, true) || !blastMiningCooldownOver()) { + return; + } + + PlayerProfile profile = getProfile(); + TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class); + + SkillUtils.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player)); + player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom")); + + mcMMO.p.addToTNTTracker(tnt.getEntityId(), player.getName()); + tnt.setFuseTicks(0); + targetBlock.setData((byte) 0x0); + targetBlock.setType(Material.AIR); + + profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis()); + profile.setAbilityInformed(AbilityType.BLAST_MINING, false); + } + + /** + * Handler for explosion drops and XP gain. + * + * @param event Event whose explosion is being processed + */ + public void blastMiningDropProcessing(float yield, List blockList) { + List ores = new ArrayList(); + List debris = new ArrayList(); + int xp = 0; + + float oreBonus = (float) (getOreBonus() / 100); + float debrisReduction = (float) (getDebrisReduction() / 100); + int dropMultiplier = getDropMultiplier(); + + float debrisYield = yield - debrisReduction; + + for (Block block : blockList) { + BlockState blockState = block.getState(); + + if (BlockUtils.isOre(blockState)) { + ores.add(blockState); + } + else { + debris.add(blockState); + } + } + + for (BlockState blockState : ores) { + if (Misc.getRandom().nextFloat() < (yield + oreBonus)) { + if (!mcMMO.placeStore.isTrue(blockState)) { + xp += Mining.getBlockXp(blockState); + } + + Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); // Initial block that would have been dropped + + if (!mcMMO.placeStore.isTrue(blockState)) { + for (int i = 1; i < dropMultiplier; i++) { + xp += Mining.getBlockXp(blockState); + Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items + } + } + } + } + + if (debrisYield > 0) { + for (BlockState blockState : debris) { + if (Misc.getRandom().nextFloat() < debrisYield) { + Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); + } + } + } + + applyXpGain(xp); + } + + /** + * Increases the blast radius of the explosion. + * + * @param event Event whose explosion radius is being changed + */ + public float biggerBombs(float radius) { + return (float) (radius + getBlastRadiusModifier()); + } + + public int processDemolitionsExpertise(int damage) { + return (int) (damage * (100.0 - getBlastDamageModifier())); + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public int getBlastMiningTier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.toNumerical(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public double getOreBonus() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getOreBonus(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public double getDebrisReduction() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getDebrisReduction(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public int getDropMultiplier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getDropMultiplier(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public double getBlastRadiusModifier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getBlastRadiusModifier(); + } + } + + return 0; + } + + /** + * Gets the Blast Mining tier + * + * @return the Blast Mining tier + */ + public double getBlastDamageModifier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getBlastDamageDecrease(); + } + } + + return 0; + } + + private boolean blastMiningCooldownOver() { + Player player = getPlayer(); + PlayerProfile profile = getProfile(); + + long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR; + int cooldown = AbilityType.BLAST_MINING.getCooldown(); + + if (!SkillUtils.cooldownOver(oldTime, cooldown, player)) { + player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillUtils.calculateTimeLeft(oldTime, cooldown, player))); + return false; + } + + return true; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java index 8a5afc20c..64607d624 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -14,43 +14,27 @@ import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.PerksUtils; -import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.PerksUtils; public class Repair { - private static final AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); + public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel(); + public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus(); - public static final double REPAIR_MASTERY_CHANCE_MAX = advancedConfig.getRepairMasteryMaxBonus(); - public static final int REPAIR_MASTERY_MAX_BONUS_LEVEL = advancedConfig.getRepairMasteryMaxLevel(); - public static final double SUPER_REPAIR_CHANCE_MAX = advancedConfig.getSuperRepairChanceMax(); - public static final int SUPER_REPAIR_MAX_BONUS_LEVEL = advancedConfig.getSuperRepairMaxLevel(); + public static int superRepairMaxBonusLevel = AdvancedConfig.getInstance().getSuperRepairMaxLevel(); + public static double superRepairMaxChance = AdvancedConfig.getInstance().getSuperRepairChanceMax(); - public static boolean arcaneForgingDowngrades = advancedConfig.getArcaneForgingDowngradeEnabled(); - public static boolean arcaneForgingEnchantLoss = advancedConfig.getArcaneForgingEnchantLossEnabled(); + public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled(); + public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled(); - public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled(); public static int anvilID = Config.getInstance().getRepairAnvilId(); - - /** - * Handle the Xp gain for repair events. - * - * @param mcMMOPlayer Player repairing the item - * @param durabilityBefore Durability of the item before repair - * @param modify Amount to modify the durability by - */ - protected static void xpHandler(McMMOPlayer mcMMOPlayer, short durabilityBefore, short durabilityAfter, double modify) { - short dif = (short) ((durabilityBefore - durabilityAfter) * modify); - Player player = mcMMOPlayer.getPlayer(); - - player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - mcMMOPlayer.beginXpGain(SkillType.REPAIR, dif * 10); - } + public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled(); /** * Get current Arcane Forging rank. @@ -61,16 +45,16 @@ public class Repair { public static int getArcaneForgingRank(PlayerProfile profile) { int skillLevel = profile.getSkillLevel(SkillType.REPAIR); - if (skillLevel >= advancedConfig.getArcaneForgingRankLevels4()) { + if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels4()) { return 4; } - else if (skillLevel >= advancedConfig.getArcaneForgingRankLevels3()) { + else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels3()) { return 3; } - else if (skillLevel >= advancedConfig.getArcaneForgingRankLevels2()) { + else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels2()) { return 2; } - else if (skillLevel >= advancedConfig.getArcaneForgingRankLevels1()) { + else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels1()) { return 1; } else { @@ -95,7 +79,7 @@ public class Repair { return; } - int rank = getArcaneForgingRank(Users.getPlayer(player).getProfile()); + int rank = getArcaneForgingRank(UserManager.getPlayer(player).getProfile()); if (rank == 0 || !Permissions.arcaneForging(player)) { for (Enchantment x : enchants.keySet()) { @@ -115,7 +99,7 @@ public class Repair { if (Misc.getRandom().nextInt(activationChance) <= getEnchantChance(rank)) { int enchantLevel = enchant.getValue(); - if (advancedConfig.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) { + if (arcaneForgingDowngrades && enchantLevel > 1) { if (Misc.getRandom().nextInt(activationChance) < getDowngradeChance(rank)) { is.addEnchantment(enchantment, --enchantLevel); downgraded = true; @@ -148,20 +132,20 @@ public class Repair { */ public static int getEnchantChance(int rank) { switch (rank) { - case 4: - return advancedConfig.getArcaneForgingKeepEnchantsChanceRank4(); + case 4: + return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); - case 3: - return advancedConfig.getArcaneForgingKeepEnchantsChanceRank3(); + case 3: + return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); - case 2: - return advancedConfig.getArcaneForgingKeepEnchantsChanceRank2(); + case 2: + return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); - case 1: - return advancedConfig.getArcaneForgingKeepEnchantsChanceRank1(); + case 1: + return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); - default: - return 0; + default: + return 0; } } @@ -173,58 +157,23 @@ public class Repair { */ public static int getDowngradeChance(int rank) { switch (rank) { - case 4: - return advancedConfig.getArcaneForgingDowngradeChanceRank4(); + case 4: + return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); - case 3: - return advancedConfig.getArcaneForgingDowngradeChanceRank3(); + case 3: + return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); - case 2: - return advancedConfig.getArcaneForgingDowngradeChanceRank2(); + case 2: + return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); - case 1: - return advancedConfig.getArcaneForgingDowngradeChanceRank1(); + case 1: + return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); - default: - return 100; + default: + return 100; } } - /** - * Computes repair bonuses. - * - * @param player The player repairing an item - * @param skillLevel the skillLevel of the player in Repair - * @param durability The durability of the item being repaired - * @param repairAmount The base amount of durability repaired to the item - * @return The final amount of durability repaired to the item - */ - protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) { - float bonus; - if (skillLevel >= REPAIR_MASTERY_MAX_BONUS_LEVEL) bonus = (float) (REPAIR_MASTERY_CHANCE_MAX / 100F); - else bonus = (((float) skillLevel) / ((float) REPAIR_MASTERY_MAX_BONUS_LEVEL)) * (float) ((REPAIR_MASTERY_CHANCE_MAX) / 100F); - - if (Permissions.repairMastery(player)) { - bonus = repairAmount * bonus; - repairAmount += (int) bonus; - } - - if (checkPlayerProcRepair(player)) { - repairAmount = (int) (repairAmount * 2D); - } - - if (repairAmount <= 0 || repairAmount > 32767) - repairAmount = 32767; - - durability -= repairAmount; - - if (durability < 0) { - durability = 0; - } - - return durability; - } - /** * Checks for Super Repair bonus. * @@ -232,10 +181,12 @@ public class Repair { * @return true if bonus granted, false otherwise */ public static boolean checkPlayerProcRepair(Player player) { - int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR); + int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR); - int chance = (int) ((SUPER_REPAIR_CHANCE_MAX / SUPER_REPAIR_MAX_BONUS_LEVEL) * skillLevel); - if (skillLevel >= SUPER_REPAIR_MAX_BONUS_LEVEL) chance = (int) SUPER_REPAIR_CHANCE_MAX; + int chance = (int) ((superRepairMaxChance / superRepairMaxBonusLevel) * skillLevel); + if (skillLevel >= superRepairMaxBonusLevel) { + chance = (int) superRepairMaxChance; + } int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.REPAIR); @@ -253,7 +204,7 @@ public class Repair { * @param anvilID The item ID of the anvil block */ public static void placedAnvilCheck(Player player, int anvilID) { - PlayerProfile profile = Users.getPlayer(player).getProfile(); + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); if (!profile.getPlacedAnvil()) { if (mcMMO.spoutEnabled) { @@ -271,4 +222,59 @@ public class Repair { profile.togglePlacedAnvil(); } } + + /** + * Handle the Xp gain for repair events. + * + * @param mcMMOPlayer Player repairing the item + * @param durabilityBefore Durability of the item before repair + * @param modify Amount to modify the durability by + */ + protected static void xpHandler(McMMOPlayer mcMMOPlayer, short durabilityBefore, short durabilityAfter, double modify) { + short dif = (short) ((durabilityBefore - durabilityAfter) * modify); + Player player = mcMMOPlayer.getPlayer(); + + player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + mcMMOPlayer.beginXpGain(SkillType.REPAIR, dif * 10); + } + + /** + * Computes repair bonuses. + * + * @param player The player repairing an item + * @param skillLevel the skillLevel of the player in Repair + * @param durability The durability of the item being repaired + * @param repairAmount The base amount of durability repaired to the item + * @return The final amount of durability repaired to the item + */ + protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) { + float bonus; + if (skillLevel >= repairMasteryMaxBonusLevel) { + bonus = (float) (repairMasteryMaxBonus / 100F); + } + else { + bonus = (((float) skillLevel) / ((float) repairMasteryMaxBonusLevel)) * (float) ((repairMasteryMaxBonus) / 100F); + } + + if (Permissions.repairMastery(player)) { + bonus = repairAmount * bonus; + repairAmount += (int) bonus; + } + + if (checkPlayerProcRepair(player)) { + repairAmount = (int) (repairAmount * 2D); + } + + if (repairAmount <= 0 || repairAmount > 32767) { + repairAmount = 32767; + } + + durability -= repairAmount; + + if (durability < 0) { + durability = 0; + } + + return durability; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java index ff7e438ce..96c62a56a 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java @@ -17,17 +17,17 @@ public enum RepairItemType { */ public boolean getPermissions(Player player) { switch (this) { - case ARMOR: - return Permissions.repairArmor(player); + case ARMOR: + return Permissions.repairArmor(player); - case TOOL: - return Permissions.repairTools(player); + case TOOL: + return Permissions.repairTools(player); - case OTHER: - return Permissions.repairOtherItems(player); + case OTHER: + return Permissions.repairOtherItems(player); - default: - return false; + default: + return false; } } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 6cd7f2e7e..f7a2007e4 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -4,7 +4,7 @@ import java.util.List; import org.bukkit.inventory.ItemStack; -import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; public interface RepairManager { /** diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java index cdf5c1553..e736c0aa8 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java @@ -22,32 +22,32 @@ public enum RepairMaterialType { */ public boolean getPermissions(Player player) { switch (this) { - case STRING: - return Permissions.repairString(player); + case STRING: + return Permissions.repairString(player); - case LEATHER: - return Permissions.repairLeather(player); + case LEATHER: + return Permissions.repairLeather(player); - case WOOD: - return Permissions.repairWood(player); + case WOOD: + return Permissions.repairWood(player); - case STONE: - return Permissions.repairStone(player); + case STONE: + return Permissions.repairStone(player); - case IRON: - return Permissions.repairIron(player); + case IRON: + return Permissions.repairIron(player); - case GOLD: - return Permissions.repairGold(player); + case GOLD: + return Permissions.repairGold(player); - case DIAMOND: - return Permissions.repairDiamond(player); + case DIAMOND: + return Permissions.repairDiamond(player); - case OTHER: - return Permissions.repairOtherMaterials(player); + case OTHER: + return Permissions.repairOtherMaterials(player); - default: - return false; + default: + return false; } } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java index a370ae606..fabd1146c 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -11,28 +11,26 @@ import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; public class Salvage { - private static Config configInstance = Config.getInstance(); public static int salvageUnlockLevel = Config.getInstance().getSalvageUnlockLevel(); public static int anvilID = Config.getInstance().getSalvageAnvilId(); public static void handleSalvage(final Player player, final Location location, final ItemStack item) { - if (!configInstance.getSalvageEnabled()) { + if (!Config.getInstance().getSalvageEnabled()) { return; } if (player.getGameMode() == GameMode.SURVIVAL) { - final int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR); - final int unlockLevel = configInstance.getSalvageUnlockLevel(); + final int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR); - if (skillLevel < unlockLevel) { + if (skillLevel < salvageUnlockLevel) { player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage")); return; } @@ -52,17 +50,16 @@ public class Salvage { player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability")); } } - } /** * Handles notifications for placing an anvil. - * + * * @param player The player placing the anvil * @param anvilID The item ID of the anvil block */ public static void placedAnvilCheck(final Player player, final int anvilID) { - final PlayerProfile profile = Users.getPlayer(player).getProfile(); + final PlayerProfile profile = UserManager.getPlayer(player).getProfile(); if (!profile.getPlacedSalvageAnvil()) { if (mcMMO.spoutEnabled) { @@ -81,26 +78,44 @@ public class Salvage { } } + /** + * Checks if the item is salvageable. + * + * @param is Item to check + * @return true if the item is salvageable, false otherwise + */ + public static boolean isSalvageable(final ItemStack is) { + if (Config.getInstance().getSalvageTools() && (ItemUtils.isMinecraftTool(is) || ItemUtils.isStringTool(is) || is.getType() == Material.BUCKET)) { + return true; + } + + if (Config.getInstance().getSalvageArmor() && ItemUtils.isMinecraftArmor(is)) { + return true; + } + + return false; + } + private static Material getSalvagedItem(final ItemStack inHand) { - if (ItemChecks.isDiamondTool(inHand) || ItemChecks.isDiamondArmor(inHand)) { + if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) { return Material.DIAMOND; } - else if (ItemChecks.isGoldTool(inHand) || ItemChecks.isGoldArmor(inHand)) { + else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) { return Material.GOLD_INGOT; } - else if (ItemChecks.isIronTool(inHand) || ItemChecks.isIronArmor(inHand)) { + else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) { return Material.IRON_INGOT; } - else if (ItemChecks.isStoneTool(inHand)) { + else if (ItemUtils.isStoneTool(inHand)) { return Material.COBBLESTONE; } - else if (ItemChecks.isWoodTool(inHand)) { + else if (ItemUtils.isWoodTool(inHand)) { return Material.WOOD; } - else if (ItemChecks.isLeatherArmor(inHand)) { + else if (ItemUtils.isLeatherArmor(inHand)) { return Material.LEATHER; } - else if (ItemChecks.isStringTool(inHand)) { + else if (ItemUtils.isStringTool(inHand)) { return Material.STRING; } else { @@ -109,44 +124,29 @@ public class Salvage { } private static int getSalvagedAmount(final ItemStack inHand) { - if (ItemChecks.isPickaxe(inHand) || ItemChecks.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) { + if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) { return 3; } - else if (ItemChecks.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) { + else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) { return 1; } - else if (ItemChecks.isSword(inHand) || ItemChecks.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) { + else if (ItemUtils.isSword(inHand) || ItemUtils.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) { return 2; } - else if (ItemChecks.isHelmet(inHand)) { + else if (ItemUtils.isHelmet(inHand)) { return 5; } - else if (ItemChecks.isChestplate(inHand)) { + else if (ItemUtils.isChestplate(inHand)) { return 8; } - else if (ItemChecks.isLeggings(inHand)) { + else if (ItemUtils.isLeggings(inHand)) { return 7; } - else if (ItemChecks.isBoots(inHand)) { + else if (ItemUtils.isBoots(inHand)) { return 4; } else { return 0; } } - /** - * Checks if the item is salvageable. - * - * @param is Item to check - * @return true if the item is salvageable, false otherwise - */ - public static boolean isSalvageable(final ItemStack is) { - if (configInstance.getSalvageTools() && (ItemChecks.isMinecraftTool(is) || ItemChecks.isStringTool(is) || is.getType() == Material.BUCKET)) { - return true; - } - if (configInstance.getSalvageArmor() && ItemChecks.isMinecraftArmor(is)) { - return true; - } - return false; - } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java index 1f7fb2935..bcdaca589 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java @@ -9,10 +9,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; @@ -194,11 +194,8 @@ public class SimpleRepairManager implements RepairManager { */ private int findInInventory(PlayerInventory inventory, int itemId, byte metadata) { int location = -1; - ItemStack[] contents = inventory.getContents(); - - for (int i = 0; i < contents.length; i++) { - ItemStack item = contents[i]; + for (ItemStack item : inventory.getContents()) { if (item == null) { continue; } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java index 457fad5af..05bd3f0d0 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java @@ -1,60 +1,60 @@ -package com.gmail.nossr50.skills.smelting; - -import org.bukkit.Material; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.skills.utilities.SkillType; - -public class Smelting { - // The order of the values is extremely important, a few methods depend on it to work properly - protected enum Tier { - FIVE(5) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Level();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Multiplier();}}, - FOUR(4) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Level();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Multiplier();}}, - THREE(3) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Level();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Multiplier();}}, - TWO(2) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Level();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Multiplier();}}, - ONE(1) { - @Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level();} - @Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Multiplier();}}; - - int numerical; - - private Tier(int numerical) { - this.numerical = numerical; - } - - public int toNumerical() { - return numerical; - } - - abstract protected int getLevel(); - abstract protected int getVanillaXPBoostModifier(); - } - - public static int burnModifierMaxLevel = AdvancedConfig.getInstance().getBurnModifierMaxLevel(); - public static double burnTimeMultiplier = AdvancedConfig.getInstance().getBurnTimeMultiplier(); - - public static double secondSmeltMaxChance = AdvancedConfig.getInstance().getSecondSmeltMaxChance(); - public static int secondSmeltMaxLevel = AdvancedConfig.getInstance().getSecondSmeltMaxLevel(); - - public static int fluxMiningUnlockLevel = AdvancedConfig.getInstance().getFluxMiningUnlockLevel(); - public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance(); - - protected static int getResourceXp(Material resourceType) { - int xp = Config.getInstance().getXp(SkillType.SMELTING, resourceType); - - if (resourceType == Material.GLOWING_REDSTONE_ORE) { - xp = Config.getInstance().getXp(SkillType.SMELTING, Material.REDSTONE_ORE); - } - - return xp; - } -} +package com.gmail.nossr50.skills.smelting; + +import org.bukkit.Material; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.skills.SkillType; + +public class Smelting { + // The order of the values is extremely important, a few methods depend on it to work properly + protected enum Tier { + FIVE(5) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Level(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Multiplier(); }}, + FOUR(4) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Level(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Multiplier(); }}, + THREE(3) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Level(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Multiplier(); }}, + TWO(2) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Level(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Multiplier(); }}, + ONE(1) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level(); } + @Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Multiplier(); }}; + + int numerical; + + private Tier(int numerical) { + this.numerical = numerical; + } + + public int toNumerical() { + return numerical; + } + + abstract protected int getLevel(); + abstract protected int getVanillaXPBoostModifier(); + } + + public static int burnModifierMaxLevel = AdvancedConfig.getInstance().getBurnModifierMaxLevel(); + public static double burnTimeMultiplier = AdvancedConfig.getInstance().getBurnTimeMultiplier(); + + public static int secondSmeltMaxLevel = AdvancedConfig.getInstance().getSecondSmeltMaxLevel(); + public static double secondSmeltMaxChance = AdvancedConfig.getInstance().getSecondSmeltMaxChance(); + + public static int fluxMiningUnlockLevel = AdvancedConfig.getInstance().getFluxMiningUnlockLevel(); + public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance(); + + protected static int getResourceXp(Material resourceType) { + int xp = Config.getInstance().getXp(SkillType.SMELTING, resourceType); + + if (resourceType == Material.GLOWING_REDSTONE_ORE) { + xp = Config.getInstance().getXp(SkillType.SMELTING, Material.REDSTONE_ORE); + } + + return xp; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index d44612021..3c55f721c 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -1,132 +1,132 @@ -package com.gmail.nossr50.skills.smelting; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.FurnaceBurnEvent; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.mining.Mining; -import com.gmail.nossr50.skills.smelting.Smelting.Tier; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.BlockChecks; -import com.gmail.nossr50.util.ItemChecks; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; - -public class SmeltingManager extends SkillManager { - public SmeltingManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.SMELTING); - } - - public boolean canUseFluxMining(BlockState blockState) { - Player player = getPlayer(); - ItemStack heldItem = player.getItemInHand(); - - return BlockChecks.affectedByFluxMining(blockState) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState); - } - - public boolean canUseVanillaXpBoost() { - Player player = getPlayer(); - - return SkillTools.unlockLevelReached(player, skill, Smelting.Tier.ONE.getLevel()) && Permissions.vanillaXpBoost(player, skill); - } - - /** - * Process the Flux Mining ability. - * - * @param blockState The {@link BlockState} to check ability activation for - * @return true if the ability was successful, false otherwise - */ - public boolean processFluxMining(BlockState blockState) { - Player player = getPlayer(); - - if (SkillTools.unlockLevelReached(player, skill, Smelting.fluxMiningUnlockLevel) && SkillTools.activationSuccessful(player, skill, Smelting.fluxMiningChance)) { - ItemStack item = null; - - switch (blockState.getType()) { - case IRON_ORE: - item = new ItemStack(Material.IRON_INGOT); - break; - - case GOLD_ORE: - item = new ItemStack(Material.GOLD_INGOT); - break; - - default: - break; - } - - if (item == null) { - return false; - } - - Location location = blockState.getLocation(); - - Misc.dropItem(location, item); - - if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { - Misc.dropItem(location, item); - } - - blockState.setRawData((byte) 0x0); - blockState.setType(Material.AIR); - player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success")); - return true; - } - - return false; - } - - /** - * Increases burn time for furnace fuel. - * - * @param burnTime The initial burn time from the {@link FurnaceBurnEvent} - */ - public int fuelEfficiency(int burnTime) { - double burnModifier = 1 + (((double) getSkillLevel() / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier); - - return (int) (burnTime * burnModifier); - } - - public ItemStack smeltProcessing(Material resourceType, ItemStack result) { - Player player = getPlayer(); - - applyXpGain(Smelting.getResourceXp(resourceType)); - - if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) { - ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1); - return newResult; - } - - return result; - } - - public int vanillaXPBoost(int experience) { - return experience * getVanillaXpMultiplier(); - } - - /** - * Gets the vanilla XP multiplier - * - * @return the vanilla XP multiplier - */ - protected int getVanillaXpMultiplier() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getVanillaXPBoostModifier(); - } - } - - return 0; - } -} +package com.gmail.nossr50.skills.smelting; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.FurnaceBurnEvent; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.mining.Mining; +import com.gmail.nossr50.skills.smelting.Smelting.Tier; +import com.gmail.nossr50.util.BlockUtils; +import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class SmeltingManager extends SkillManager { + public SmeltingManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.SMELTING); + } + + public boolean canUseFluxMining(BlockState blockState) { + Player player = getPlayer(); + ItemStack heldItem = player.getItemInHand(); + + return BlockUtils.affectedByFluxMining(blockState) && ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState); + } + + public boolean canUseVanillaXpBoost() { + Player player = getPlayer(); + + return SkillUtils.unlockLevelReached(player, skill, Smelting.Tier.ONE.getLevel()) && Permissions.vanillaXpBoost(player, skill); + } + + /** + * Process the Flux Mining ability. + * + * @param blockState The {@link BlockState} to check ability activation for + * @return true if the ability was successful, false otherwise + */ + public boolean processFluxMining(BlockState blockState) { + Player player = getPlayer(); + + if (SkillUtils.unlockLevelReached(player, skill, Smelting.fluxMiningUnlockLevel) && SkillUtils.activationSuccessful(player, skill, Smelting.fluxMiningChance)) { + ItemStack item = null; + + switch (blockState.getType()) { + case IRON_ORE: + item = new ItemStack(Material.IRON_INGOT); + break; + + case GOLD_ORE: + item = new ItemStack(Material.GOLD_INGOT); + break; + + default: + break; + } + + if (item == null) { + return false; + } + + Location location = blockState.getLocation(); + + Misc.dropItem(location, item); + + if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { + Misc.dropItem(location, item); + } + + blockState.setRawData((byte) 0x0); + blockState.setType(Material.AIR); + player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success")); + return true; + } + + return false; + } + + /** + * Increases burn time for furnace fuel. + * + * @param burnTime The initial burn time from the {@link FurnaceBurnEvent} + */ + public int fuelEfficiency(int burnTime) { + double burnModifier = 1 + (((double) getSkillLevel() / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier); + + return (int) (burnTime * burnModifier); + } + + public ItemStack smeltProcessing(Material resourceType, ItemStack result) { + Player player = getPlayer(); + + applyXpGain(Smelting.getResourceXp(resourceType)); + + if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) { + ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1); + return newResult; + } + + return result; + } + + public int vanillaXPBoost(int experience) { + return experience * getVanillaXpMultiplier(); + } + + /** + * Gets the vanilla XP multiplier + * + * @return the vanilla XP multiplier + */ + public int getVanillaXpMultiplier() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getVanillaXPBoostModifier(); + } + } + + return 0; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/swords/Swords.java b/src/main/java/com/gmail/nossr50/skills/swords/Swords.java index a84fc5936..b41f155b2 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/Swords.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/Swords.java @@ -1,18 +1,17 @@ -package com.gmail.nossr50.skills.swords; - -import com.gmail.nossr50.config.AdvancedConfig; - -public class Swords { - public static double bleedMaxChance = AdvancedConfig.getInstance().getBleedChanceMax(); - public static int bleedMaxBonusLevel = AdvancedConfig.getInstance().getBleedMaxBonusLevel(); - public static int bleedMaxTicks = AdvancedConfig.getInstance().getBleedMaxTicks(); - public static int bleedBaseTicks = AdvancedConfig.getInstance().getBleedBaseTicks(); - - public static double counterAttackMaxChance = AdvancedConfig.getInstance().getCounterChanceMax(); - public static int counterAttackMaxBonusLevel = AdvancedConfig.getInstance().getCounterMaxBonusLevel(); - public static int counterAttackModifier = AdvancedConfig.getInstance().getCounterModifier(); - - public static int serratedStrikesModifier = AdvancedConfig.getInstance().getSerratedStrikesModifier(); - public static int serratedStrikesBleedTicks = AdvancedConfig.getInstance().getSerratedStrikesTicks(); -} - +package com.gmail.nossr50.skills.swords; + +import com.gmail.nossr50.config.AdvancedConfig; + +public class Swords { + public static int bleedMaxBonusLevel = AdvancedConfig.getInstance().getBleedMaxBonusLevel(); + public static int bleedMaxTicks = AdvancedConfig.getInstance().getBleedMaxTicks(); + public static int bleedBaseTicks = AdvancedConfig.getInstance().getBleedBaseTicks(); + public static double bleedMaxChance = AdvancedConfig.getInstance().getBleedChanceMax(); + + public static int counterAttackMaxBonusLevel = AdvancedConfig.getInstance().getCounterMaxBonusLevel(); + public static int counterAttackModifier = AdvancedConfig.getInstance().getCounterModifier(); + public static double counterAttackMaxChance = AdvancedConfig.getInstance().getCounterChanceMax(); + + public static int serratedStrikesModifier = AdvancedConfig.getInstance().getSerratedStrikesModifier(); + public static int serratedStrikesBleedTicks = AdvancedConfig.getInstance().getSerratedStrikesTicks(); +} diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 3d72dd94b..51e359895 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -1,67 +1,67 @@ -package com.gmail.nossr50.skills.swords; - -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.utilities.CombatTools; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Users; - -public class SwordsManager extends SkillManager { - public SwordsManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.SWORDS); - } - - /** - * Check for Bleed effect. - * - * @param target The defending entity - */ - public void bleedCheck(LivingEntity target) { - Player player = getPlayer(); - - if (SkillTools.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) { - - if (getSkillLevel() >= Swords.bleedMaxBonusLevel) { - BleedTimer.add(target, Swords.bleedMaxTicks); - } - else { - BleedTimer.add(target, Swords.bleedBaseTicks); - } - - if (getProfile().useChatNotifications()) { - player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); - } - - if (target instanceof Player) { - Player defender = (Player) target; - - if (Users.getPlayer(defender).getProfile().useChatNotifications()) { - defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started")); - } - } - } - } - - public void counterAttackChecks(LivingEntity attacker, int damage) { - if (SkillTools.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) { - CombatTools.dealDamage(attacker, damage / Swords.counterAttackModifier); - - getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered")); - - if (attacker instanceof Player) { - ((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit")); - } - } - } - - public void serratedStrikes(LivingEntity target, int damage) { - CombatTools.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill); - BleedTimer.add(target, Swords.serratedStrikesBleedTicks); - } -} +package com.gmail.nossr50.skills.swords; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.runnables.skills.BleedTimerTask; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.CombatUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class SwordsManager extends SkillManager { + public SwordsManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.SWORDS); + } + + /** + * Check for Bleed effect. + * + * @param target The defending entity + */ + public void bleedCheck(LivingEntity target) { + Player player = getPlayer(); + + if (SkillUtils.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) { + + if (getSkillLevel() >= Swords.bleedMaxBonusLevel) { + BleedTimerTask.add(target, Swords.bleedMaxTicks); + } + else { + BleedTimerTask.add(target, Swords.bleedBaseTicks); + } + + if (getProfile().useChatNotifications()) { + player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); + } + + if (target instanceof Player) { + Player defender = (Player) target; + + if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) { + defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started")); + } + } + } + } + + public void counterAttackChecks(LivingEntity attacker, int damage) { + if (SkillUtils.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) { + CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier); + + getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered")); + + if (attacker instanceof Player) { + ((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit")); + } + } + } + + public void serratedStrikes(LivingEntity target, int damage) { + CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill); + BleedTimerTask.add(target, Swords.serratedStrikesBleedTicks); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java index d548dacca..35765fa3e 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java @@ -1,53 +1,54 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.AnimalTamer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Tameable; - -import com.gmail.nossr50.locale.LocaleLoader; - -public class BeastLoreEventHandler { - private Player player; - private LivingEntity livingEntity; - private Tameable beast; - - protected BeastLoreEventHandler(Player player, LivingEntity livingEntity) { - this.player = player; - this.livingEntity = livingEntity; - this.beast = (Tameable) livingEntity; - } - - protected void sendInspectMessage() { - if (player == null) - return; - - String message = LocaleLoader.getString("Combat.BeastLore") + " "; - - if (beast.isTamed()) { - message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", getOwnerName()) + " "); - } - - message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", livingEntity.getHealth(), livingEntity.getMaxHealth())); - player.sendMessage(message); - } - - /** - * Get the name of a tameable animal's owner. - * - * @return the name of the animal's owner - */ - private String getOwnerName() { - AnimalTamer tamer = beast.getOwner(); - - if (tamer instanceof Player) { - return ((Player) tamer).getName(); - } - else if (tamer instanceof OfflinePlayer) { - return ((OfflinePlayer) tamer).getName(); - } - - return "Unknown Master"; - } -} +package com.gmail.nossr50.skills.taming; + +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.AnimalTamer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; + +import com.gmail.nossr50.locale.LocaleLoader; + +public class BeastLoreEventHandler { + private Player player; + private LivingEntity livingEntity; + private Tameable beast; + + protected BeastLoreEventHandler(Player player, LivingEntity livingEntity) { + this.player = player; + this.livingEntity = livingEntity; + this.beast = (Tameable) livingEntity; + } + + protected void sendInspectMessage() { + if (player == null) { + return; + } + + String message = LocaleLoader.getString("Combat.BeastLore") + " "; + + if (beast.isTamed()) { + message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", getOwnerName()) + " "); + } + + message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", livingEntity.getHealth(), livingEntity.getMaxHealth())); + player.sendMessage(message); + } + + /** + * Get the name of a tameable animal's owner. + * + * @return the name of the animal's owner + */ + private String getOwnerName() { + AnimalTamer tamer = beast.getOwner(); + + if (tamer instanceof Player) { + return ((Player) tamer).getName(); + } + else if (tamer instanceof OfflinePlayer) { + return ((OfflinePlayer) tamer).getName(); + } + + return "Unknown Master"; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java index 02ad5a499..0aff2d7c8 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java @@ -1,102 +1,108 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Ocelot; -import org.bukkit.entity.Player; -import org.bukkit.entity.Tameable; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.StringUtils; - -public class CallOfTheWildEventHandler { - protected Player player; - protected ItemStack inHand; - protected EntityType type; - protected int summonAmount; - - protected CallOfTheWildEventHandler(Player player, EntityType type, int summonAmount) { - this.player = player; - this.inHand = player.getItemInHand(); - this.type = type; - this.summonAmount = summonAmount; - } - - protected void sendInsufficientAmountMessage() { - if (player == null) - return; - - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(inHand.getTypeId()))); - } - - protected boolean nearbyEntityExists() { - if (player == null) - return false; - - boolean entityExists = false; - - for (Entity entity : player.getNearbyEntities(40, 40, 40)) { - if (entity.getType() == type) { - entityExists = true; - break; - } - } - - return entityExists; - } - - protected void sendFailureMessage() { - if (player == null) - return; - - if (type == EntityType.OCELOT) { - player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot")); - } - else { - player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Wolf")); - } - } - - protected void spawnCreature() { - if (player == null) - return; - - LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type); - entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); - - ((Tameable) entity).setOwner(player); - - if (type == EntityType.OCELOT) { - ((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3))); - } - else { - entity.setHealth(entity.getMaxHealth()); - } - } - - protected void processResourceCost() { - if (player == null) - return; - - int newAmount = inHand.getAmount() - summonAmount; - - if (newAmount == 0) { - player.setItemInHand(new ItemStack(Material.AIR)); - } - else { - player.getItemInHand().setAmount(inHand.getAmount() - summonAmount); - } - } - - protected void sendSuccessMessage() { - if (player == null) - return; - - player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete")); - } -} +package com.gmail.nossr50.skills.taming; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Ocelot; +import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; + +public class CallOfTheWildEventHandler { + protected Player player; + protected ItemStack inHand; + protected EntityType type; + protected int summonAmount; + + protected CallOfTheWildEventHandler(Player player, EntityType type, int summonAmount) { + this.player = player; + this.inHand = player.getItemInHand(); + this.type = type; + this.summonAmount = summonAmount; + } + + protected void sendInsufficientAmountMessage() { + if (player == null) { + return; + } + + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(inHand.getTypeId()))); + } + + protected boolean nearbyEntityExists() { + if (player == null) { + return false; + } + + boolean entityExists = false; + + for (Entity entity : player.getNearbyEntities(40, 40, 40)) { + if (entity.getType() == type) { + entityExists = true; + break; + } + } + + return entityExists; + } + + protected void sendFailureMessage() { + if (player == null) { + return; + } + + if (type == EntityType.OCELOT) { + player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot")); + } + else { + player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Wolf")); + } + } + + protected void spawnCreature() { + if (player == null) { + return; + } + + LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type); + entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); + + ((Tameable) entity).setOwner(player); + + if (type == EntityType.OCELOT) { + ((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3))); + } + else { + entity.setHealth(entity.getMaxHealth()); + } + } + + protected void processResourceCost() { + if (player == null) { + return; + } + + int newAmount = inHand.getAmount() - summonAmount; + + if (newAmount == 0) { + player.setItemInHand(new ItemStack(Material.AIR)); + } + else { + player.getItemInHand().setAmount(inHand.getAmount() - summonAmount); + } + } + + protected void sendSuccessMessage() { + if (player == null) { + return; + } + + player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete")); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/FastFoodServiceEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/FastFoodServiceEventHandler.java index ccac0bef8..ecbd99dad 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/FastFoodServiceEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/FastFoodServiceEventHandler.java @@ -1,27 +1,27 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.entity.Wolf; - -public class FastFoodServiceEventHandler { - private Wolf wolf; - - public FastFoodServiceEventHandler (Wolf wolf) { - this.wolf = wolf; - } - - protected void modifyHealth(int damage) { - int health = wolf.getHealth(); - int maxHealth = wolf.getMaxHealth(); - - if (health < maxHealth) { - int newHealth = health + damage; - - if (newHealth <= maxHealth) { - wolf.setHealth(newHealth); - } - else { - wolf.setHealth(maxHealth); - } - } - } -} +package com.gmail.nossr50.skills.taming; + +import org.bukkit.entity.Wolf; + +public class FastFoodServiceEventHandler { + private Wolf wolf; + + public FastFoodServiceEventHandler(Wolf wolf) { + this.wolf = wolf; + } + + protected void modifyHealth(int damage) { + int health = wolf.getHealth(); + int maxHealth = wolf.getMaxHealth(); + + if (health < maxHealth) { + int newHealth = health + damage; + + if (newHealth <= maxHealth) { + wolf.setHealth(newHealth); + } + else { + wolf.setHealth(maxHealth); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/GoreEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/GoreEventHandler.java index ae069ba02..583425d75 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/GoreEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/GoreEventHandler.java @@ -1,44 +1,44 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.utilities.SkillTools; - -public class GoreEventHandler { - private TamingManager manager; - private EntityDamageEvent event; - private Entity entity; - protected int skillModifier; - - protected GoreEventHandler(TamingManager manager, EntityDamageEvent event) { - this.manager = manager; - this.event = event; - this.entity = event.getEntity(); - calculateSkillModifier(); - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Taming.goreMaxBonusLevel); - } - - protected void modifyEventDamage() { - event.setDamage(event.getDamage() * Taming.goreModifier); - } - - protected void sendAbilityMessage() { - if (entity instanceof Player) { - ((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore")); - } - - manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore")); - } - - protected void applyBleed() { - BleedTimer.add((LivingEntity) entity, Taming.goreBleedTicks); - } -} +package com.gmail.nossr50.skills.taming; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent; + +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.runnables.skills.BleedTimerTask; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class GoreEventHandler { + private TamingManager manager; + private EntityDamageEvent event; + private Entity entity; + protected int skillModifier; + + protected GoreEventHandler(TamingManager manager, EntityDamageEvent event) { + this.manager = manager; + this.event = event; + this.entity = event.getEntity(); + calculateSkillModifier(); + } + + protected void calculateSkillModifier() { + this.skillModifier = SkillUtils.skillCheck(manager.getSkillLevel(), Taming.goreMaxBonusLevel); + } + + protected void modifyEventDamage() { + event.setDamage(event.getDamage() * Taming.goreModifier); + } + + protected void sendAbilityMessage() { + if (entity instanceof Player) { + ((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore")); + } + + manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore")); + } + + protected void applyBleed() { + BleedTimerTask.add((LivingEntity) entity, Taming.goreBleedTicks); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/SharpenedClawsEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/SharpenedClawsEventHandler.java index 935cfb7d5..a7d20fe62 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/SharpenedClawsEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/SharpenedClawsEventHandler.java @@ -1,15 +1,15 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.event.entity.EntityDamageEvent; - -public class SharpenedClawsEventHandler { - private EntityDamageEvent event; - - public SharpenedClawsEventHandler (EntityDamageEvent event) { - this.event = event; - } - - protected void modifyEventDamage() { - event.setDamage(event.getDamage() + Taming.sharpenedClawsBonusDamage); - } -} +package com.gmail.nossr50.skills.taming; + +import org.bukkit.event.entity.EntityDamageEvent; + +public class SharpenedClawsEventHandler { + private EntityDamageEvent event; + + public SharpenedClawsEventHandler(EntityDamageEvent event) { + this.event = event; + } + + protected void modifyEventDamage() { + event.setDamage(event.getDamage() + Taming.sharpenedClawsBonusDamage); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java index 2de1e2c31..06ea2bb25 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java @@ -8,33 +8,33 @@ import org.bukkit.entity.Wolf; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.SkillUtils; public class Taming { public static int environmentallyAwareUnlockLevel = AdvancedConfig.getInstance().getEnviromentallyAwareUnlock(); - public static int holyHoundUnlockLevel = AdvancedConfig.getInstance().getHolyHoundUnlock(); + public static int holyHoundUnlockLevel = AdvancedConfig.getInstance().getHolyHoundUnlock(); + public static int fastFoodServiceUnlockLevel = AdvancedConfig.getInstance().getFastFoodUnlock(); public static double fastFoodServiceActivationChance = AdvancedConfig.getInstance().getFastFoodChance(); - public static int fastFoodServiceUnlockLevel = AdvancedConfig.getInstance().getFastFoodUnlock(); + public static int goreBleedTicks = AdvancedConfig.getInstance().getGoreBleedTicks(); + public static int goreMaxBonusLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel(); + public static int goreModifier = AdvancedConfig.getInstance().getGoreModifier(); public static double goreMaxChance = AdvancedConfig.getInstance().getGoreChanceMax(); - public static int goreBleedTicks = AdvancedConfig.getInstance().getGoreBleedTicks(); - public static int goreMaxBonusLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel(); - public static int goreModifier = AdvancedConfig.getInstance().getGoreModifier(); public static int sharpenedClawsUnlockLevel = AdvancedConfig.getInstance().getSharpenedClawsUnlock(); public static int sharpenedClawsBonusDamage = AdvancedConfig.getInstance().getSharpenedClawsBonus(); public static int shockProofUnlockLevel = AdvancedConfig.getInstance().getShockProofUnlock(); - public static int shockProofModifier = AdvancedConfig.getInstance().getShockProofModifier(); + public static int shockProofModifier = AdvancedConfig.getInstance().getShockProofModifier(); public static int thickFurUnlockLevel = AdvancedConfig.getInstance().getThickFurUnlock(); - public static int thickFurModifier = AdvancedConfig.getInstance().getThickFurModifier(); + public static int thickFurModifier = AdvancedConfig.getInstance().getThickFurModifier(); - public static int wolfXp = Config.getInstance().getTamingXPWolf(); + public static int wolfXp = Config.getInstance().getTamingXPWolf(); public static int ocelotXp = Config.getInstance().getTamingXPOcelot(); public static boolean canPreventDamage(Tameable pet, AnimalTamer owner) { @@ -42,19 +42,19 @@ public class Taming { } public static boolean canUseThickFur(Player player) { - return SkillTools.unlockLevelReached(player, SkillType.TAMING, thickFurUnlockLevel) && Permissions.thickFur(player); + return SkillUtils.unlockLevelReached(player, SkillType.TAMING, thickFurUnlockLevel) && Permissions.thickFur(player); } public static boolean canUseEnvironmentallyAware(Player player) { - return SkillTools.unlockLevelReached(player, SkillType.TAMING, environmentallyAwareUnlockLevel) && Permissions.environmentallyAware(player); + return SkillUtils.unlockLevelReached(player, SkillType.TAMING, environmentallyAwareUnlockLevel) && Permissions.environmentallyAware(player); } public static boolean canUseShockProof(Player player) { - return SkillTools.unlockLevelReached(player, SkillType.TAMING, shockProofUnlockLevel) && Permissions.shockProof(player); + return SkillUtils.unlockLevelReached(player, SkillType.TAMING, shockProofUnlockLevel) && Permissions.shockProof(player); } public static boolean canUseHolyHound(Player player) { - return SkillTools.unlockLevelReached(player, SkillType.TAMING, holyHoundUnlockLevel) && Permissions.holyHound(player); + return SkillUtils.unlockLevelReached(player, SkillType.TAMING, holyHoundUnlockLevel) && Permissions.holyHound(player); } public static int processThickFur(Wolf wolf, int damage) { 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 13c697da4..b907b5bdb 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -1,145 +1,145 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Wolf; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityTameEvent; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; - -public class TamingManager extends SkillManager { - public TamingManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.TAMING); - } - - /** - * Award XP for taming. - * - * @param event The event to award XP for - */ - public void awardTamingXP(LivingEntity entity) { - switch (entity.getType()) { - case WOLF: - applyXpGain(Taming.wolfXp); - return; - - case OCELOT: - applyXpGain(Taming.ocelotXp); - return; - - default: - return; - } - } - - /** - * Apply the Fast Food Service ability. - * - * @param wolf The wolf using the ability - * @param damage The damage being absorbed by the wolf - */ - public void fastFoodService(Wolf wolf, int damage) { - if (SkillTools.activationSuccessful(getPlayer(), skill, Taming.fastFoodServiceActivationChance)) { - - int health = wolf.getHealth(); - int maxHealth = wolf.getMaxHealth(); - - if (health < maxHealth) { - int newHealth = health + damage; - wolf.setHealth(Math.min(newHealth, maxHealth)); - } - } - } - - /** - * Apply the Sharpened Claws ability. - * - * @param event The event to modify - */ - public void sharpenedClaws(EntityDamageEvent event) { - SharpenedClawsEventHandler eventHandler = new SharpenedClawsEventHandler(event); - eventHandler.modifyEventDamage(); - } - - /** - * Apply the Gore ability. - * - * @param event The event to modify - */ - public void gore(EntityDamageEvent event) { - GoreEventHandler eventHandler = new GoreEventHandler(this, event); - - float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * getSkillLevel()); - if (chance > Taming.goreMaxChance) chance = (float) Taming.goreMaxChance; - - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.modifyEventDamage(); - eventHandler.applyBleed(); - eventHandler.sendAbilityMessage(); - } - } - - /** - * Summon an ocelot to your side. - */ - public void summonOcelot() { - callOfTheWild(EntityType.OCELOT, Config.getInstance().getTamingCOTWOcelotCost()); - } - - /** - * Summon a wolf to your side. - */ - public void summonWolf() { - callOfTheWild(EntityType.WOLF, Config.getInstance().getTamingCOTWWolfCost()); - } - - /** - * Handle the Beast Lore ability. - * - * @param livingEntity The entity to examine - */ - public void beastLore(LivingEntity livingEntity) { - BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(mcMMOPlayer.getPlayer(), livingEntity); - eventHandler.sendInspectMessage(); - } - - /** - * Handle the Call of the Wild ability. - * - * @param type The type of entity to summon. - * @param summonAmount The amount of material needed to summon the entity - */ - private void callOfTheWild(EntityType type, int summonAmount) { - if (!Permissions.callOfTheWild(mcMMOPlayer.getPlayer())) { - return; - } - - CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(mcMMOPlayer.getPlayer(), type, summonAmount); - - ItemStack inHand = eventHandler.inHand; - int inHandAmount = inHand.getAmount(); - - if (inHandAmount < summonAmount) { - eventHandler.sendInsufficientAmountMessage(); - return; - } - - if (eventHandler.nearbyEntityExists()) { - eventHandler.sendFailureMessage(); - } - else { - eventHandler.spawnCreature(); - eventHandler.processResourceCost(); - eventHandler.sendSuccessMessage(); - } - } -} +package com.gmail.nossr50.skills.taming; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Wolf; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class TamingManager extends SkillManager { + public TamingManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.TAMING); + } + + /** + * Award XP for taming. + * + * @param event The event to award XP for + */ + public void awardTamingXP(LivingEntity entity) { + switch (entity.getType()) { + case WOLF: + applyXpGain(Taming.wolfXp); + return; + + case OCELOT: + applyXpGain(Taming.ocelotXp); + return; + + default: + return; + } + } + + /** + * Apply the Fast Food Service ability. + * + * @param wolf The wolf using the ability + * @param damage The damage being absorbed by the wolf + */ + public void fastFoodService(Wolf wolf, int damage) { + if (SkillUtils.activationSuccessful(getPlayer(), skill, Taming.fastFoodServiceActivationChance)) { + + int health = wolf.getHealth(); + int maxHealth = wolf.getMaxHealth(); + + if (health < maxHealth) { + int newHealth = health + damage; + wolf.setHealth(Math.min(newHealth, maxHealth)); + } + } + } + + /** + * Apply the Sharpened Claws ability. + * + * @param event The event to modify + */ + public void sharpenedClaws(EntityDamageEvent event) { + SharpenedClawsEventHandler eventHandler = new SharpenedClawsEventHandler(event); + eventHandler.modifyEventDamage(); + } + + /** + * Apply the Gore ability. + * + * @param event The event to modify + */ + public void gore(EntityDamageEvent event) { + GoreEventHandler eventHandler = new GoreEventHandler(this, event); + + float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * getSkillLevel()); + if (chance > Taming.goreMaxChance) { + chance = (float) Taming.goreMaxChance; + } + + if (chance > Misc.getRandom().nextInt(activationChance)) { + eventHandler.modifyEventDamage(); + eventHandler.applyBleed(); + eventHandler.sendAbilityMessage(); + } + } + + /** + * Summon an ocelot to your side. + */ + public void summonOcelot() { + callOfTheWild(EntityType.OCELOT, Config.getInstance().getTamingCOTWOcelotCost()); + } + + /** + * Summon a wolf to your side. + */ + public void summonWolf() { + callOfTheWild(EntityType.WOLF, Config.getInstance().getTamingCOTWWolfCost()); + } + + /** + * Handle the Beast Lore ability. + * + * @param livingEntity The entity to examine + */ + public void beastLore(LivingEntity livingEntity) { + BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(mcMMOPlayer.getPlayer(), livingEntity); + eventHandler.sendInspectMessage(); + } + + /** + * Handle the Call of the Wild ability. + * + * @param type The type of entity to summon. + * @param summonAmount The amount of material needed to summon the entity + */ + private void callOfTheWild(EntityType type, int summonAmount) { + if (!Permissions.callOfTheWild(mcMMOPlayer.getPlayer())) { + return; + } + + CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(mcMMOPlayer.getPlayer(), type, summonAmount); + + ItemStack inHand = eventHandler.inHand; + int inHandAmount = inHand.getAmount(); + + if (inHandAmount < summonAmount) { + eventHandler.sendInsufficientAmountMessage(); + return; + } + + if (eventHandler.nearbyEntityExists()) { + eventHandler.sendFailureMessage(); + } + else { + eventHandler.spawnCreature(); + eventHandler.processResourceCost(); + eventHandler.sendSuccessMessage(); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java index 9c4611401..2078bfb9f 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java @@ -1,46 +1,46 @@ -package com.gmail.nossr50.skills.unarmed; - -import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.skills.utilities.SkillTools; - -public class Unarmed { - public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus(); - public static int ironArmIncreaseLevel = AdvancedConfig.getInstance().getIronArmIncreaseLevel(); - - public static double disarmMaxChance = AdvancedConfig.getInstance().getDisarmChanceMax() ; - public static int disarmMaxBonusLevel = AdvancedConfig.getInstance().getDisarmMaxBonusLevel(); - - public static double deflectMaxChance = AdvancedConfig.getInstance().getDeflectChanceMax(); - public static int deflectMaxBonusLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel(); - - public static double ironGripMaxChance = AdvancedConfig.getInstance().getIronGripChanceMax(); - public static int ironGripMaxBonusLevel = AdvancedConfig.getInstance().getIronGripMaxBonusLevel(); - - public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked(); - - public static double berserkDamageModifier = 1.5; - - public static boolean blockCracker(Player player, BlockState blockState) { - if (SkillTools.blockBreakSimulate(blockState.getBlock(), player, false)) { - Material type = blockState.getType(); - - switch (type) { - case SMOOTH_BRICK: - if (blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) { - blockState.setRawData((byte) 0x2); - } - return true; - - default: - return false; - } - } - - return false; - } -} \ No newline at end of file +package com.gmail.nossr50.skills.unarmed; + +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class Unarmed { + public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus(); + public static int ironArmIncreaseLevel = AdvancedConfig.getInstance().getIronArmIncreaseLevel(); + + public static int disarmMaxBonusLevel = AdvancedConfig.getInstance().getDisarmMaxBonusLevel(); + public static double disarmMaxChance = AdvancedConfig.getInstance().getDisarmChanceMax(); + + public static int deflectMaxBonusLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel(); + public static double deflectMaxChance = AdvancedConfig.getInstance().getDeflectChanceMax(); + + public static int ironGripMaxBonusLevel = AdvancedConfig.getInstance().getIronGripMaxBonusLevel(); + public static double ironGripMaxChance = AdvancedConfig.getInstance().getIronGripChanceMax(); + + public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked(); + + public static double berserkDamageModifier = 1.5; + + public static boolean blockCracker(Player player, BlockState blockState) { + if (SkillUtils.blockBreakSimulate(blockState.getBlock(), player, false)) { + Material type = blockState.getType(); + + switch (type) { + case SMOOTH_BRICK: + if (blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) { + blockState.setRawData((byte) 0x2); + } + return true; + + default: + return false; + } + } + + return false; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index 7da7d5c13..0212a533c 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -1,87 +1,87 @@ -package com.gmail.nossr50.skills.unarmed; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.events.skills.McMMOPlayerDisarmEvent; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; - -public class UnarmedManager extends SkillManager { - public UnarmedManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.UNARMED); - } - - /** - * Check for disarm. - * - * @param defender The defending player - */ - public void disarmCheck(Player defender) { - if (SkillTools.activationSuccessful(getPlayer(), skill, Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) { - McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender); - mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent); - - if (!disarmEvent.isCancelled()) { - Misc.dropItem(defender.getLocation(), defender.getItemInHand()); - - defender.setItemInHand(new ItemStack(Material.AIR)); - defender.sendMessage(LocaleLoader.getString("Skills.Disarmed")); - } - } - } - - /** - * Check for arrow deflection. - */ - public boolean deflectCheck() { - Player player = getPlayer(); - - if (SkillTools.activationSuccessful(player, skill, Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) { - player.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect")); - return true; - } - - return false; - } - - public int berserkDamage(int damage) { - return (int) (damage * Unarmed.berserkDamageModifier); - } - - /** - * Handle the effects of the Iron Arm ability - * - * @param damage The amount of damage initially dealt by the event - * @return the modified event damage - */ - public int ironArmCheck(int damage) { - int unarmedBonus = Math.min(3 + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage); - - return damage + unarmedBonus; - } - - /** - * Check Iron Grip ability success - * - * @param defender The defending player - * @return true if the defender was not disarmed, false otherwise - */ - private boolean hasIronGrip(Player defender) { - if (!Misc.isNPCEntity(defender) && Permissions.ironGrip(defender) && SkillTools.activationSuccessful(defender, skill, Unarmed.ironGripMaxChance, Unarmed.ironGripMaxBonusLevel)) { - defender.sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Defender")); - getPlayer().sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Attacker")); - - return true; - } - - return false; - } -} +package com.gmail.nossr50.skills.unarmed; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class UnarmedManager extends SkillManager { + public UnarmedManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.UNARMED); + } + + /** + * Check for disarm. + * + * @param defender The defending player + */ + public void disarmCheck(Player defender) { + if (SkillUtils.activationSuccessful(getPlayer(), skill, Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) { + McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender); + mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent); + + if (!disarmEvent.isCancelled()) { + Misc.dropItem(defender.getLocation(), defender.getItemInHand()); + + defender.setItemInHand(new ItemStack(Material.AIR)); + defender.sendMessage(LocaleLoader.getString("Skills.Disarmed")); + } + } + } + + /** + * Check for arrow deflection. + */ + public boolean deflectCheck() { + Player player = getPlayer(); + + if (SkillUtils.activationSuccessful(player, skill, Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) { + player.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect")); + return true; + } + + return false; + } + + public int berserkDamage(int damage) { + return (int) (damage * Unarmed.berserkDamageModifier); + } + + /** + * Handle the effects of the Iron Arm ability + * + * @param damage The amount of damage initially dealt by the event + * @return the modified event damage + */ + public int ironArmCheck(int damage) { + int unarmedBonus = Math.min(3 + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage); + + return damage + unarmedBonus; + } + + /** + * Check Iron Grip ability success + * + * @param defender The defending player + * @return true if the defender was not disarmed, false otherwise + */ + private boolean hasIronGrip(Player defender) { + if (!Misc.isNPCEntity(defender) && Permissions.ironGrip(defender) && SkillUtils.activationSuccessful(defender, skill, Unarmed.ironGripMaxChance, Unarmed.ironGripMaxBonusLevel)) { + defender.sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Defender")); + getPlayer().sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Attacker")); + + return true; + } + + return false; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java index 962c636d1..6e813f352 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java @@ -1,275 +1,276 @@ -package com.gmail.nossr50.skills.woodcutting; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.BlockState; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.Tree; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.mods.datatypes.CustomBlock; -import com.gmail.nossr50.skills.utilities.CombatTools; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod; -import com.gmail.nossr50.util.BlockChecks; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Users; - -public final class TreeFeller { - private static boolean treeFellerReachedThreshold = false; - - private TreeFeller() {} - - /** - * Begins Tree Feller - * - * @param mcMMOPlayer Player using Tree Feller - * @param blockState Block being broken - */ - protected static void processTreeFeller(BlockState blockState, Player player) { - List treeFellerBlocks = new ArrayList(); - - if(blockState.getTypeId() == 17 || blockState.getTypeId() == 99) - processRegularTrees(blockState, treeFellerBlocks); - else - processRedMushroomTrees(blockState, treeFellerBlocks); - - // If the player is trying to break too many blocks - if (treeFellerReachedThreshold) { - treeFellerReachedThreshold = false; - - player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold")); - return; - } - - // If the tool can't sustain the durability loss - if (!handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) { - player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter")); - - int health = player.getHealth(); - - if (health > 1) { - CombatTools.dealDamage(player, Misc.getRandom().nextInt(health - 1)); - } - - return; - } - - dropBlocks(treeFellerBlocks, player); - } - - /** - * Processes Tree Feller for generic Trees - * - * @param blockState Block being checked - * @param treeFellerBlocks List of blocks to be removed - */ - private static void processRegularTrees(BlockState blockState, List treeFellerBlocks) { - if (!BlockChecks.isLog(blockState)) { - return; - } - - List futureCenterBlocks = new ArrayList(); - World world = blockState.getWorld(); - - // Handle the blocks around 'block' - for (int y = 0; y <= 1; y++) { - for (int x = -1; x <= 1; x++) { - for (int z = -1; z <= 1; z++) { - BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState(); - - handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks); - - if (treeFellerReachedThreshold) { - return; - } - } - } - } - - // Recursive call for each log found - for (BlockState futureCenterBlock : futureCenterBlocks) { - if (treeFellerReachedThreshold) { - return; - } - - processRegularTrees(futureCenterBlock, treeFellerBlocks); - } - } - - /** - * Processes Tree Feller for Red Mushrooms (Dome Shaped) - * - * @param blockState Block being checked - * @param treeFellerBlocks List of blocks to be removed - */ - private static void processRedMushroomTrees(BlockState blockState, List treeFellerBlocks) { - if (!BlockChecks.isLog(blockState)) { - return; - } - - List futureCenterBlocks = new ArrayList(); - World world = blockState.getWorld(); - - // Handle the blocks around 'block' - for (int y = 0; y <= 1; y++) { - for (int x = -1; x <= 1; x++) { - for (int z = -1; z <= 1; z++) { - BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState(); - BlockState otherNextBlock = world.getBlockAt(blockState.getLocation().add(x, y-(y*2), z)).getState(); - - handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks); - handleBlock(otherNextBlock, futureCenterBlocks, treeFellerBlocks); - - if (treeFellerReachedThreshold) { - return; - } - } - } - } - - // Recursive call for each log found - for (BlockState futureCenterBlock : futureCenterBlocks) { - if (treeFellerReachedThreshold) { - return; - } - - processRedMushroomTrees(futureCenterBlock, treeFellerBlocks); - } - } - - /** - * Handle a block addition to the list of blocks to be removed - * and to the list of blocks used for future recursive calls of 'processRecursively()' - * - * @param blockState Block to be added - * @param futureCenterBlocks List of blocks that will be used to call 'processRecursively()' - * @param treeFellerBlocks List of blocks to be removed - */ - private static void handleBlock(BlockState blockState, List futureCenterBlocks, List treeFellerBlocks) { - if (!BlockChecks.affectedByTreeFeller(blockState) || mcMMO.placeStore.isTrue(blockState) || treeFellerBlocks.contains(blockState)) { - return; - } - - treeFellerBlocks.add(blockState); - - if (treeFellerBlocks.size() > Config.getInstance().getTreeFellerThreshold()) { - treeFellerReachedThreshold = true; - return; - } - - futureCenterBlocks.add(blockState); - } - - /** - * Handles the durability loss - * - * @param treeFellerBlocks List of blocks to be removed - * @param inHand tool being used - * @return True if the tool can sustain the durability loss - */ - private static boolean handleDurabilityLoss(List treeFellerBlocks, ItemStack inHand) { - Material inHandMaterial = inHand.getType(); - - if (inHandMaterial != Material.AIR) { - short durabilityLoss = 0; - int unbreakingLevel = inHand.getEnchantmentLevel(Enchantment.DURABILITY); - - for (BlockState blockState : treeFellerBlocks) { - if (BlockChecks.isLog(blockState) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) { - durabilityLoss += Config.getInstance().getAbilityToolDamage(); - } - } - - short finalDurability = (short) (inHand.getDurability() + durabilityLoss); - short maxDurability = ModChecks.isCustomTool(inHand) ? ModChecks.getToolFromItemStack(inHand).getDurability() : inHandMaterial.getMaxDurability(); - - if (finalDurability >= maxDurability) { - inHand.setDurability(maxDurability); - return false; - } - - inHand.setDurability(finalDurability); - } - - return true; - } - - /** - * Handles the dropping of blocks - * - * @param treeFellerBlocks List of blocks to be dropped - * @param player Player using the ability - */ - private static void dropBlocks(List treeFellerBlocks, Player player) { - int xp = 0; - - for (BlockState blockState : treeFellerBlocks) { - if (!SkillTools.blockBreakSimulate(blockState.getBlock(), player, true)) { - break; // TODO: Shouldn't we use continue instead? - } - - Material material = blockState.getType(); - - if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) { - xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); - - for (ItemStack drop : blockState.getBlock().getDrops()) { - Misc.dropItem(blockState.getLocation(), drop); - } - } - else if (ModChecks.isCustomLogBlock(blockState)) { - Woodcutting.checkForDoubleDrop(player, blockState); - - CustomBlock customBlock = ModChecks.getCustomBlock(blockState); - xp = customBlock.getXpGain(); - int minimumDropAmount = customBlock.getMinimumDropAmount(); - int maximumDropAmount = customBlock.getMaximumDropAmount(); - Location location = blockState.getLocation(); - ItemStack item = customBlock.getItemDrop();; - - Misc.dropItems(location, item, minimumDropAmount); - - if (minimumDropAmount < maximumDropAmount) { - Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount); - } - } - else if (ModChecks.isCustomLeafBlock(blockState)) { - Misc.randomDropItem(blockState.getLocation(), ModChecks.getCustomBlock(blockState).getItemDrop(), 10); - } - else { - Tree tree = (Tree) blockState.getData(); - switch (material) { - case LOG: - Woodcutting.checkForDoubleDrop(player, blockState); - xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); - Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData())); - break; - - case LEAVES: - Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10); - break; - - default: - break; - } - } - - blockState.setRawData((byte) 0x0); - blockState.setType(Material.AIR); - blockState.update(true); - } - - Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp); - } -} +package com.gmail.nossr50.skills.woodcutting; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.BlockState; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Tree; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.mods.CustomBlock; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod; +import com.gmail.nossr50.util.BlockUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.ModUtils; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.CombatUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public final class TreeFeller { + private static boolean treeFellerReachedThreshold = false; + + private TreeFeller() {} + + /** + * Begins Tree Feller + * + * @param mcMMOPlayer Player using Tree Feller + * @param blockState Block being broken + */ + protected static void processTreeFeller(BlockState blockState, Player player) { + List treeFellerBlocks = new ArrayList(); + + if (blockState.getTypeId() == 17 || blockState.getTypeId() == 99) { + processRegularTrees(blockState, treeFellerBlocks); + } + else { + processRedMushroomTrees(blockState, treeFellerBlocks); + } + + // If the player is trying to break too many blocks + if (treeFellerReachedThreshold) { + treeFellerReachedThreshold = false; + + player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold")); + return; + } + + // If the tool can't sustain the durability loss + if (!handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) { + player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter")); + + int health = player.getHealth(); + + if (health > 1) { + CombatUtils.dealDamage(player, Misc.getRandom().nextInt(health - 1)); + } + + return; + } + + dropBlocks(treeFellerBlocks, player); + } + + /** + * Processes Tree Feller for generic Trees + * + * @param blockState Block being checked + * @param treeFellerBlocks List of blocks to be removed + */ + private static void processRegularTrees(BlockState blockState, List treeFellerBlocks) { + if (!BlockUtils.isLog(blockState)) { + return; + } + + List futureCenterBlocks = new ArrayList(); + World world = blockState.getWorld(); + + // Handle the blocks around 'block' + for (int y = 0; y <= 1; y++) { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState(); + + handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks); + + if (treeFellerReachedThreshold) { + return; + } + } + } + } + + // Recursive call for each log found + for (BlockState futureCenterBlock : futureCenterBlocks) { + if (treeFellerReachedThreshold) { + return; + } + + processRegularTrees(futureCenterBlock, treeFellerBlocks); + } + } + + /** + * Processes Tree Feller for Red Mushrooms (Dome Shaped) + * + * @param blockState Block being checked + * @param treeFellerBlocks List of blocks to be removed + */ + private static void processRedMushroomTrees(BlockState blockState, List treeFellerBlocks) { + if (!BlockUtils.isLog(blockState)) { + return; + } + + List futureCenterBlocks = new ArrayList(); + World world = blockState.getWorld(); + + // Handle the blocks around 'block' + for (int y = 0; y <= 1; y++) { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState(); + BlockState otherNextBlock = world.getBlockAt(blockState.getLocation().add(x, y - (y * 2), z)).getState(); + + handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks); + handleBlock(otherNextBlock, futureCenterBlocks, treeFellerBlocks); + + if (treeFellerReachedThreshold) { + return; + } + } + } + } + + // Recursive call for each log found + for (BlockState futureCenterBlock : futureCenterBlocks) { + if (treeFellerReachedThreshold) { + return; + } + + processRedMushroomTrees(futureCenterBlock, treeFellerBlocks); + } + } + + /** + * Handle a block addition to the list of blocks to be removed and to the list of blocks used for future recursive calls of 'processRecursively()' + * + * @param blockState Block to be added + * @param futureCenterBlocks List of blocks that will be used to call 'processRecursively()' + * @param treeFellerBlocks List of blocks to be removed + */ + private static void handleBlock(BlockState blockState, List futureCenterBlocks, List treeFellerBlocks) { + if (!BlockUtils.affectedByTreeFeller(blockState) || mcMMO.placeStore.isTrue(blockState) || treeFellerBlocks.contains(blockState)) { + return; + } + + treeFellerBlocks.add(blockState); + + if (treeFellerBlocks.size() > Config.getInstance().getTreeFellerThreshold()) { + treeFellerReachedThreshold = true; + return; + } + + futureCenterBlocks.add(blockState); + } + + /** + * Handles the durability loss + * + * @param treeFellerBlocks List of blocks to be removed + * @param inHand tool being used + * @return True if the tool can sustain the durability loss + */ + private static boolean handleDurabilityLoss(List treeFellerBlocks, ItemStack inHand) { + Material inHandMaterial = inHand.getType(); + + if (inHandMaterial != Material.AIR) { + short durabilityLoss = 0; + int unbreakingLevel = inHand.getEnchantmentLevel(Enchantment.DURABILITY); + + for (BlockState blockState : treeFellerBlocks) { + if (BlockUtils.isLog(blockState) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) { + durabilityLoss += Config.getInstance().getAbilityToolDamage(); + } + } + + short finalDurability = (short) (inHand.getDurability() + durabilityLoss); + short maxDurability = ModUtils.isCustomTool(inHand) ? ModUtils.getToolFromItemStack(inHand).getDurability() : inHandMaterial.getMaxDurability(); + + if (finalDurability >= maxDurability) { + inHand.setDurability(maxDurability); + return false; + } + + inHand.setDurability(finalDurability); + } + + return true; + } + + /** + * Handles the dropping of blocks + * + * @param treeFellerBlocks List of blocks to be dropped + * @param player Player using the ability + */ + private static void dropBlocks(List treeFellerBlocks, Player player) { + int xp = 0; + + for (BlockState blockState : treeFellerBlocks) { + if (!SkillUtils.blockBreakSimulate(blockState.getBlock(), player, true)) { + break; // TODO: Shouldn't we use continue instead? + } + + Material material = blockState.getType(); + + if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) { + xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); + + for (ItemStack drop : blockState.getBlock().getDrops()) { + Misc.dropItem(blockState.getLocation(), drop); + } + } + else if (ModUtils.isCustomLogBlock(blockState)) { + Woodcutting.checkForDoubleDrop(player, blockState); + + CustomBlock customBlock = ModUtils.getCustomBlock(blockState); + xp = customBlock.getXpGain(); + int minimumDropAmount = customBlock.getMinimumDropAmount(); + int maximumDropAmount = customBlock.getMaximumDropAmount(); + Location location = blockState.getLocation(); + ItemStack item = customBlock.getItemDrop();; + + Misc.dropItems(location, item, minimumDropAmount); + + if (minimumDropAmount < maximumDropAmount) { + Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount); + } + } + else if (ModUtils.isCustomLeafBlock(blockState)) { + Misc.randomDropItem(blockState.getLocation(), ModUtils.getCustomBlock(blockState).getItemDrop(), 10); + } + else { + Tree tree = (Tree) blockState.getData(); + switch (material) { + case LOG: + Woodcutting.checkForDoubleDrop(player, blockState); + xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); + Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData())); + break; + + case LEAVES: + Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10); + break; + + default: + break; + } + } + + blockState.setRawData((byte) 0x0); + blockState.setType(Material.AIR); + blockState.update(true); + } + + UserManager.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index c0439b532..47df1d5c2 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -1,182 +1,182 @@ -package com.gmail.nossr50.skills.woodcutting; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.Tree; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.mods.datatypes.CustomBlock; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; - -public final class Woodcutting { - public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getWoodcuttingDoubleDropChance(); - public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel(); - - protected enum ExperienceGainMethod { - DEFAULT, - TREE_FELLER, - }; - - private Woodcutting() {} - - /** - * Begins the Tree Feller ability - * - * @param mcMMOPlayer Player using the ability - * @param block Block being broken - */ - public static void beginTreeFeller(BlockState blockState, Player player) { - TreeFeller.processTreeFeller(blockState, player); - } - - /** - * Begins the Leaf Blower ability - * - * @param player Player using the ability - * @param block Block being broken - */ - public static void beginLeafBlower(Player player, BlockState blockState) { - mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player)); - player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); - } - - /** - * Begins Woodcutting - * - * @param mcMMOPlayer Player breaking the block - * @param block Block being broken - */ - public static void beginWoodcutting(Player player, BlockState blockState) { - int xp = getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); - - if (Permissions.doubleDrops(player, SkillType.WOODCUTTING)) { - Material blockType = blockState.getType(); - - if (blockType != Material.HUGE_MUSHROOM_1 && blockType != Material.HUGE_MUSHROOM_2) { - checkForDoubleDrop(player, blockState); - } - } - - Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp); - } - - /** - * Retrieves the experience reward from a log - * - * @param blockState Log being broken - * @param experienceGainMethod How the log is being broken - * @return Amount of experience - */ - protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) { - // Mushrooms aren't trees so we could never get species data from them - switch (blockState.getType()) { - case HUGE_MUSHROOM_1: - return Config.getInstance().getWoodcuttingXPHugeBrownMushroom(); - - case HUGE_MUSHROOM_2: - return Config.getInstance().getWoodcuttingXPHugeRedMushroom(); - - default: - break; - } - - if (ModChecks.isCustomLogBlock(blockState)) { - return ModChecks.getCustomBlock(blockState).getXpGain(); - } - - switch (((Tree) blockState.getData()).getSpecies()) { - case GENERIC: - return Config.getInstance().getWoodcuttingXPOak(); - - case REDWOOD: - return Config.getInstance().getWoodcuttingXPSpruce(); - - case BIRCH: - return Config.getInstance().getWoodcuttingXPBirch(); - - case JUNGLE: - int xp = Config.getInstance().getWoodcuttingXPJungle(); - - if (experienceGainMethod == ExperienceGainMethod.TREE_FELLER) { - xp *= 0.5; - } - - return xp; - - default: - return 0; - } - } - - /** - * Checks for double drops - * - * @param mcMMOPlayer Player breaking the block - * @param blockState Block being broken - */ - protected static void checkForDoubleDrop(Player player, BlockState blockState) { - if (!SkillTools.activationSuccessful(player, SkillType.WOODCUTTING, doubleDropsMaxChance, doubleDropsMaxLevel)) { - return; - } - - if (ModChecks.isCustomLogBlock(blockState)) { - CustomBlock customBlock = ModChecks.getCustomBlock(blockState); - int minimumDropAmount = customBlock.getMinimumDropAmount(); - int maximumDropAmount = customBlock.getMaximumDropAmount(); - Location location = blockState.getLocation(); - ItemStack item = customBlock.getItemDrop(); - - Misc.dropItems(location, item, minimumDropAmount); - - if (minimumDropAmount != maximumDropAmount) { - Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount); - } - } - else { - Location location = blockState.getLocation(); - Tree tree = (Tree) blockState.getData(); - ItemStack item = new ItemStack(Material.LOG, 1, tree.getSpecies().getData()); - - switch (((Tree) blockState.getData()).getSpecies()) { - case GENERIC: - if (Config.getInstance().getOakDoubleDropsEnabled()) { - Misc.dropItem(location, item); - } - return; - - case REDWOOD: - if (Config.getInstance().getSpruceDoubleDropsEnabled()) { - Misc.dropItem(location, item); - } - return; - - case BIRCH: - if (Config.getInstance().getBirchDoubleDropsEnabled()) { - Misc.dropItem(location, item); - } - return; - - case JUNGLE: - if (Config.getInstance().getJungleDoubleDropsEnabled()) { - Misc.dropItem(location, item); - } - return; - - default: - return; - } - } - } -} +package com.gmail.nossr50.skills.woodcutting; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Tree; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.mods.CustomBlock; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.ModUtils; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public final class Woodcutting { + public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel(); + public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getWoodcuttingDoubleDropChance(); + + protected enum ExperienceGainMethod { + DEFAULT, + TREE_FELLER, + }; + + private Woodcutting() {} + + /** + * Begins the Tree Feller ability + * + * @param mcMMOPlayer Player using the ability + * @param block Block being broken + */ + public static void beginTreeFeller(BlockState blockState, Player player) { + TreeFeller.processTreeFeller(blockState, player); + } + + /** + * Begins the Leaf Blower ability + * + * @param player Player using the ability + * @param block Block being broken + */ + public static void beginLeafBlower(Player player, BlockState blockState) { + mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player)); + player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); + } + + /** + * Begins Woodcutting + * + * @param mcMMOPlayer Player breaking the block + * @param block Block being broken + */ + public static void beginWoodcutting(Player player, BlockState blockState) { + int xp = getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); + + if (Permissions.doubleDrops(player, SkillType.WOODCUTTING)) { + Material blockType = blockState.getType(); + + if (blockType != Material.HUGE_MUSHROOM_1 && blockType != Material.HUGE_MUSHROOM_2) { + checkForDoubleDrop(player, blockState); + } + } + + UserManager.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp); + } + + /** + * Retrieves the experience reward from a log + * + * @param blockState Log being broken + * @param experienceGainMethod How the log is being broken + * @return Amount of experience + */ + protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) { + // Mushrooms aren't trees so we could never get species data from them + switch (blockState.getType()) { + case HUGE_MUSHROOM_1: + return Config.getInstance().getWoodcuttingXPHugeBrownMushroom(); + + case HUGE_MUSHROOM_2: + return Config.getInstance().getWoodcuttingXPHugeRedMushroom(); + + default: + break; + } + + if (ModUtils.isCustomLogBlock(blockState)) { + return ModUtils.getCustomBlock(blockState).getXpGain(); + } + + switch (((Tree) blockState.getData()).getSpecies()) { + case GENERIC: + return Config.getInstance().getWoodcuttingXPOak(); + + case REDWOOD: + return Config.getInstance().getWoodcuttingXPSpruce(); + + case BIRCH: + return Config.getInstance().getWoodcuttingXPBirch(); + + case JUNGLE: + int xp = Config.getInstance().getWoodcuttingXPJungle(); + + if (experienceGainMethod == ExperienceGainMethod.TREE_FELLER) { + xp *= 0.5; + } + + return xp; + + default: + return 0; + } + } + + /** + * Checks for double drops + * + * @param mcMMOPlayer Player breaking the block + * @param blockState Block being broken + */ + protected static void checkForDoubleDrop(Player player, BlockState blockState) { + if (!SkillUtils.activationSuccessful(player, SkillType.WOODCUTTING, doubleDropsMaxChance, doubleDropsMaxLevel)) { + return; + } + + if (ModUtils.isCustomLogBlock(blockState)) { + CustomBlock customBlock = ModUtils.getCustomBlock(blockState); + int minimumDropAmount = customBlock.getMinimumDropAmount(); + int maximumDropAmount = customBlock.getMaximumDropAmount(); + Location location = blockState.getLocation(); + ItemStack item = customBlock.getItemDrop(); + + Misc.dropItems(location, item, minimumDropAmount); + + if (minimumDropAmount != maximumDropAmount) { + Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount); + } + } + else { + Location location = blockState.getLocation(); + Tree tree = (Tree) blockState.getData(); + ItemStack item = new ItemStack(Material.LOG, 1, tree.getSpecies().getData()); + + switch (((Tree) blockState.getData()).getSpecies()) { + case GENERIC: + if (Config.getInstance().getOakDoubleDropsEnabled()) { + Misc.dropItem(location, item); + } + return; + + case REDWOOD: + if (Config.getInstance().getSpruceDoubleDropsEnabled()) { + Misc.dropItem(location, item); + } + return; + + case BIRCH: + if (Config.getInstance().getBirchDoubleDropsEnabled()) { + Misc.dropItem(location, item); + } + return; + + case JUNGLE: + if (Config.getInstance().getJungleDoubleDropsEnabled()) { + Misc.dropItem(location, item); + } + return; + + default: + return; + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java b/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java deleted file mode 100644 index cc8a3c88c..000000000 --- a/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.gmail.nossr50.spout; - -import com.gmail.nossr50.config.ConfigLoader; -import com.gmail.nossr50.spout.huds.HudType; - -public class SpoutConfig extends ConfigLoader { - private static SpoutConfig instance; - public HudType defaultHudType; - - private SpoutConfig() { - super("spout.yml"); - loadKeys(); - } - - public static SpoutConfig getInstance() { - if (instance == null) { - instance = new SpoutConfig(); - } - - return instance; - } - - @Override - protected void loadKeys() { - // Setup default HUD - String temp = config.getString("Spout.HUD.Default", "STANDARD"); - - for (HudType hudType : HudType.values()) { - if (hudType.toString().equalsIgnoreCase(temp)) { - defaultHudType = hudType; - break; - } - } - - if (defaultHudType == null) { - defaultHudType = HudType.STANDARD; - } - } - - public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); } - public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); } - - /* XP Bar */ - public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); } - public void setXPBarEnabled(boolean enabled) { config.set("XP.Bar.Enabled", enabled); } - - public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); } - public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); } - public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); } - public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); } - public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); } - - /* HUD Colors */ - public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); } - public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); } - public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); } - public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); } - public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); } - public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); } - - public double getRetroHUDAcrobaticsRed() { return config.getDouble("HUD.Retro.Colors.Acrobatics.RED", 0.3); } - public double getRetroHUDAcrobaticsGreen() { return config.getDouble("HUD.Retro.Colors.Acrobatics.GREEN", 0.3); } - public double getRetroHUDAcrobaticsBlue() { return config.getDouble("HUD.Retro.Colors.Acrobatics.BLUE", 0.75); } - public double getRetroHUDArcheryRed() { return config.getDouble("HUD.Retro.Colors.Archery.RED", 0.3); } - public double getRetroHUDArcheryGreen() { return config.getDouble("HUD.Retro.Colors.Archery.GREEN", 0.3); } - public double getRetroHUDArcheryBlue() { return config.getDouble("HUD.Retro.Colors.Archery.BLUE", 0.75); } - public double getRetroHUDAxesRed() { return config.getDouble("HUD.Retro.Colors.Axes.RED", 0.3); } - public double getRetroHUDAxesGreen() { return config.getDouble("HUD.Retro.Colors.Axes.GREEN", 0.3); } - public double getRetroHUDAxesBlue() { return config.getDouble("HUD.Retro.Colors.Axes.BLUE", 0.75); } - public double getRetroHUDExcavationRed() { return config.getDouble("HUD.Retro.Colors.Excavation.RED", 0.3); } - public double getRetroHUDExcavationGreen() { return config.getDouble("HUD.Retro.Colors.Excavation.GREEN", 0.3); } - public double getRetroHUDExcavationBlue() { return config.getDouble("HUD.Retro.Colors.Excavation.BLUE", 0.75); } - public double getRetroHUDHerbalismRed() { return config.getDouble("HUD.Retro.Colors.Herbalism.RED", 0.3); } - public double getRetroHUDHerbalismGreen() { return config.getDouble("HUD.Retro.Colors.Herbalism.GREEN", 0.3); } - public double getRetroHUDHerbalismBlue() { return config.getDouble("HUD.Retro.Colors.Herbalism.BLUE", 0.75); } - public double getRetroHUDMiningRed() { return config.getDouble("HUD.Retro.Colors.Mining.RED", 0.3); } - public double getRetroHUDMiningGreen() { return config.getDouble("HUD.Retro.Colors.Mining.GREEN", 0.3); } - public double getRetroHUDMiningBlue() { return config.getDouble("HUD.Retro.Colors.Mining.BLUE", 0.75); } - public double getRetroHUDRepairRed() { return config.getDouble("HUD.Retro.Colors.Repair.RED", 0.3); } - public double getRetroHUDRepairGreen() { return config.getDouble("HUD.Retro.Colors.Repair.GREEN", 0.3); } - public double getRetroHUDRepairBlue() { return config.getDouble("HUD.Retro.Colors.Repair.BLUE", 0.75); } - public double getRetroHUDSwordsRed() { return config.getDouble("HUD.Retro.Colors.Swords.RED", 0.3); } - public double getRetroHUDSwordsGreen() { return config.getDouble("HUD.Retro.Colors.Swords.GREEN", 0.3); } - public double getRetroHUDSwordsBlue() { return config.getDouble("HUD.Retro.Colors.Swords.BLUE", 0.75); } - public double getRetroHUDTamingRed() { return config.getDouble("HUD.Retro.Colors.Taming.RED", 0.3); } - public double getRetroHUDTamingGreen() { return config.getDouble("HUD.Retro.Colors.Taming.GREEN", 0.3); } - public double getRetroHUDTamingBlue() { return config.getDouble("HUD.Retro.Colors.Taming.BLUE", 0.75); } - public double getRetroHUDUnarmedRed() { return config.getDouble("HUD.Retro.Colors.Unarmed.RED", 0.3); } - public double getRetroHUDUnarmedGreen() { return config.getDouble("HUD.Retro.Colors.Unarmed.GREEN", 0.3); } - public double getRetroHUDUnarmedBlue() { return config.getDouble("HUD.Retro.Colors.Unarmed.BLUE", 0.75); } - public double getRetroHUDWoodcuttingRed() { return config.getDouble("HUD.Retro.Colors.Woodcutting.RED", 0.3); } - public double getRetroHUDWoodcuttingGreen() { return config.getDouble("HUD.Retro.Colors.Woodcutting.GREEN", 0.3); } - public double getRetroHUDWoodcuttingBlue() { return config.getDouble("HUD.Retro.Colors.Woodcutting.BLUE", 0.75); } - public double getRetroHUDFishingRed() { return config.getDouble("HUD.Retro.Colors.Fishing.RED", 0.3); } - public double getRetroHUDFishingGreen() { return config.getDouble("HUD.Retro.Colors.Fishing.GREEN", 0.3); } - public double getRetroHUDFishingBlue() { return config.getDouble("HUD.Retro.Colors.Fishing.BLUE", 0.75); } -} diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java deleted file mode 100644 index 7265a1d11..000000000 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ /dev/null @@ -1,365 +0,0 @@ -package com.gmail.nossr50.util; - -import org.bukkit.CropState; -import org.bukkit.block.BlockState; -import org.bukkit.material.CocoaPlant; -import org.bukkit.material.CocoaPlant.CocoaPlantSize; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.mods.ModChecks; - -public final class BlockChecks { - private BlockChecks() {} - - /** - * Checks to see if a given block awards XP. - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block awards XP, false otherwise - */ - public static boolean shouldBeWatched(BlockState blockState) { - switch (blockState.getType()) { - case BROWN_MUSHROOM: - case CACTUS: - case CLAY: - case COAL_ORE: - case DIAMOND_ORE: - case DIRT: - case ENDER_STONE: - case GLOWING_REDSTONE_ORE: - case GLOWSTONE: - case GOLD_ORE: - case GRASS: - case GRAVEL: - case IRON_ORE: - case LAPIS_ORE: - case LOG: - case MELON_BLOCK: - case MOSSY_COBBLESTONE: - case MYCEL: - case NETHERRACK: - case OBSIDIAN: - case PUMPKIN: - case RED_MUSHROOM: - case RED_ROSE: - case REDSTONE_ORE: - case SAND: - case SANDSTONE: - case SOUL_SAND: - case STONE: - case SUGAR_CANE_BLOCK: - case VINE: - case WATER_LILY: - case YELLOW_FLOWER: - case COCOA: - case EMERALD_ORE: - case CARROT: - case POTATO: - return true; - - default: - return ModChecks.getCustomBlock(blockState) != null; - } - } - - /** - * Check if a given block should allow for the activation of abilities - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block should allow ability activation, false otherwise - */ - public static boolean canActivateAbilities(BlockState blockState) { - switch (blockState.getType()) { - case BED_BLOCK: - case BREWING_STAND: - case BOOKSHELF: - case BURNING_FURNACE: - case CAKE_BLOCK: - case CHEST: - case DISPENSER: - case ENCHANTMENT_TABLE: - case ENDER_CHEST: - case FENCE_GATE: - case FURNACE: - case IRON_DOOR_BLOCK: - case JUKEBOX: - case LEVER: - case NOTE_BLOCK: - case STONE_BUTTON: - case WOOD_BUTTON: - case TRAP_DOOR: - case WALL_SIGN: - case WOODEN_DOOR: - case WORKBENCH: - case BEACON: - case ANVIL: - return false; - - default: - int blockId = blockState.getTypeId(); - - if (blockId == Config.getInstance().getRepairAnvilId() || blockId == Config.getInstance().getSalvageAnvilId()) { - return false; - } - - if (ModChecks.isCustomAbilityBlock(blockState)) { - return false; - } - - return true; - } - } - - /** - * Check if a given block is an ore - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block is an ore, false otherwise - */ - public static boolean isOre(BlockState blockState) { - switch (blockState.getType()) { - case COAL_ORE: - case DIAMOND_ORE: - case GLOWING_REDSTONE_ORE: - case GOLD_ORE: - case IRON_ORE: - case LAPIS_ORE: - case REDSTONE_ORE: - case EMERALD_ORE: - return true; - - default: - return ModChecks.isCustomOreBlock(blockState); - } - } - - /** - * Determine if a given block can be made mossy - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block can be made mossy, false otherwise - */ - public static boolean canMakeMossy(BlockState blockState) { - switch (blockState.getType()) { - case COBBLESTONE: - case DIRT: - return true; - - case SMOOTH_BRICK: - case COBBLE_WALL: - return blockState.getRawData() == (byte) 0x0; - - default: - return false; - } - } - - /** - * Determine if a given block should be affected by Green Terra - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block should affected by Green Terra, false otherwise - */ - public static boolean affectedByGreenTerra(BlockState blockState) { - switch (blockState.getType()) { - case BROWN_MUSHROOM: - case CACTUS: - case MELON_BLOCK: - case PUMPKIN: - case RED_MUSHROOM: - case RED_ROSE: - case SUGAR_CANE_BLOCK: - case VINE: - case WATER_LILY: - case YELLOW_FLOWER: - return true; - - case CARROT: - case CROPS: - case POTATO: - return blockState.getRawData() == CropState.RIPE.getData(); - - case NETHER_WARTS: - return blockState.getRawData() == (byte) 0x3; - - case COCOA: - return ((CocoaPlant) blockState.getData()).getSize() == CocoaPlantSize.LARGE; - - default: - return ModChecks.isCustomHerbalismBlock(blockState); - } - } - - /** - * Determine if a given block should be affected by Super Breaker - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block should affected by Super Breaker, false otherwise - */ - public static Boolean affectedBySuperBreaker(BlockState blockState) { - switch (blockState.getType()) { - case COAL_ORE: - case DIAMOND_ORE: - case ENDER_STONE: - case GLOWING_REDSTONE_ORE: - case GLOWSTONE: - case GOLD_ORE: - case IRON_ORE: - case LAPIS_ORE: - case MOSSY_COBBLESTONE: - case NETHERRACK: - case OBSIDIAN: - case REDSTONE_ORE: - case SANDSTONE: - case STONE: - case EMERALD_ORE: - return true; - - default: - return ModChecks.isCustomMiningBlock(blockState); - } - } - - /** - * Determine if a given block should be affected by Giga Drill Breaker - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block should affected by Giga Drill Breaker, false otherwise - */ - public static boolean affectedByGigaDrillBreaker(BlockState blockState) { - switch (blockState.getType()) { - case CLAY: - case DIRT: - case GRASS: - case GRAVEL: - case MYCEL: - case SAND: - case SOUL_SAND: - return true; - - default: - return ModChecks.isCustomExcavationBlock(blockState); - } - } - - /** - * Determine if a given block should be affected by Tree Feller - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block should affected by Tree Feller, false otherwise - */ - public static boolean affectedByTreeFeller(BlockState blockState) { - switch (blockState.getType()) { - case LOG: - case LEAVES: - case HUGE_MUSHROOM_1: - case HUGE_MUSHROOM_2: - return true; - - default: - return ModChecks.isCustomWoodcuttingBlock(blockState); - } - } - - /** - * Check if a given block is a log - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block is a log, false otherwise - */ - public static boolean isLog(BlockState blockState) { - switch (blockState.getType()) { - case LOG: - case HUGE_MUSHROOM_1: - case HUGE_MUSHROOM_2: - return true; - - default: - return ModChecks.isCustomLogBlock(blockState); - } - } - - /** - * Check if a given block is a leaf - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block is a leaf, false otherwise - */ - public static boolean isLeaves(BlockState blockState) { - switch (blockState.getType()) { - case LEAVES: - return true; - - default: - return ModChecks.isCustomLeafBlock(blockState); - } - } - - /** - * Determine if a given block should be affected by Flux Mining - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block should affected by Flux Mining, false otherwise - */ - public static boolean affectedByFluxMining(BlockState blockState) { - switch (blockState.getType()) { - case IRON_ORE: - case GOLD_ORE: - return true; - - default: - return false; - } - } - - /** - * Determine if a given block can activate Herbalism abilities - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block can be activate Herbalism abilities, false otherwise - */ - public static boolean canActivateHerbalism(BlockState blockState) { - switch (blockState.getType()) { - case DIRT: - case GRASS: - case SOIL: - return false; - - default: - return true; - } - } - - /** - * Determine if a given block should be affected by Block Cracker - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block should affected by Block Cracker, false otherwise - */ - public static boolean affectedByBlockCracker(BlockState blockState) { - switch (blockState.getType()) { - case SMOOTH_BRICK: - return blockState.getRawData() == (byte) 0x0; - - default: - return false; - } - } - - /** - * Determine if a given block can be made into Mycelium - * - * @param blockState The {@link BlockState} of the block to check - * @return true if the block can be made in Mycelium, false otherwise - */ - public static boolean canMakeShroomy(BlockState blockState) { - switch (blockState.getType()) { - case DIRT: - case GRASS: - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java new file mode 100644 index 000000000..3edd77b6a --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -0,0 +1,364 @@ +package com.gmail.nossr50.util; + +import org.bukkit.CropState; +import org.bukkit.block.BlockState; +import org.bukkit.material.CocoaPlant; +import org.bukkit.material.CocoaPlant.CocoaPlantSize; + +import com.gmail.nossr50.config.Config; + +public final class BlockUtils { + private BlockUtils() {} + + /** + * Checks to see if a given block awards XP. + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block awards XP, false otherwise + */ + public static boolean shouldBeWatched(BlockState blockState) { + switch (blockState.getType()) { + case BROWN_MUSHROOM: + case CACTUS: + case CLAY: + case COAL_ORE: + case DIAMOND_ORE: + case DIRT: + case ENDER_STONE: + case GLOWING_REDSTONE_ORE: + case GLOWSTONE: + case GOLD_ORE: + case GRASS: + case GRAVEL: + case IRON_ORE: + case LAPIS_ORE: + case LOG: + case MELON_BLOCK: + case MOSSY_COBBLESTONE: + case MYCEL: + case NETHERRACK: + case OBSIDIAN: + case PUMPKIN: + case RED_MUSHROOM: + case RED_ROSE: + case REDSTONE_ORE: + case SAND: + case SANDSTONE: + case SOUL_SAND: + case STONE: + case SUGAR_CANE_BLOCK: + case VINE: + case WATER_LILY: + case YELLOW_FLOWER: + case COCOA: + case EMERALD_ORE: + case CARROT: + case POTATO: + return true; + + default: + return ModUtils.getCustomBlock(blockState) != null; + } + } + + /** + * Check if a given block should allow for the activation of abilities + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should allow ability activation, false otherwise + */ + public static boolean canActivateAbilities(BlockState blockState) { + switch (blockState.getType()) { + case BED_BLOCK: + case BREWING_STAND: + case BOOKSHELF: + case BURNING_FURNACE: + case CAKE_BLOCK: + case CHEST: + case DISPENSER: + case ENCHANTMENT_TABLE: + case ENDER_CHEST: + case FENCE_GATE: + case FURNACE: + case IRON_DOOR_BLOCK: + case JUKEBOX: + case LEVER: + case NOTE_BLOCK: + case STONE_BUTTON: + case WOOD_BUTTON: + case TRAP_DOOR: + case WALL_SIGN: + case WOODEN_DOOR: + case WORKBENCH: + case BEACON: + case ANVIL: + return false; + + default: + int blockId = blockState.getTypeId(); + + if (blockId == Config.getInstance().getRepairAnvilId() || blockId == Config.getInstance().getSalvageAnvilId()) { + return false; + } + + if (ModUtils.isCustomAbilityBlock(blockState)) { + return false; + } + + return true; + } + } + + /** + * Check if a given block is an ore + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block is an ore, false otherwise + */ + public static boolean isOre(BlockState blockState) { + switch (blockState.getType()) { + case COAL_ORE: + case DIAMOND_ORE: + case GLOWING_REDSTONE_ORE: + case GOLD_ORE: + case IRON_ORE: + case LAPIS_ORE: + case REDSTONE_ORE: + case EMERALD_ORE: + return true; + + default: + return ModUtils.isCustomOreBlock(blockState); + } + } + + /** + * Determine if a given block can be made mossy + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block can be made mossy, false otherwise + */ + public static boolean canMakeMossy(BlockState blockState) { + switch (blockState.getType()) { + case COBBLESTONE: + case DIRT: + return true; + + case SMOOTH_BRICK: + case COBBLE_WALL: + return blockState.getRawData() == (byte) 0x0; + + default: + return false; + } + } + + /** + * Determine if a given block should be affected by Green Terra + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Green Terra, false otherwise + */ + public static boolean affectedByGreenTerra(BlockState blockState) { + switch (blockState.getType()) { + case BROWN_MUSHROOM: + case CACTUS: + case MELON_BLOCK: + case PUMPKIN: + case RED_MUSHROOM: + case RED_ROSE: + case SUGAR_CANE_BLOCK: + case VINE: + case WATER_LILY: + case YELLOW_FLOWER: + return true; + + case CARROT: + case CROPS: + case POTATO: + return blockState.getRawData() == CropState.RIPE.getData(); + + case NETHER_WARTS: + return blockState.getRawData() == (byte) 0x3; + + case COCOA: + return ((CocoaPlant) blockState.getData()).getSize() == CocoaPlantSize.LARGE; + + default: + return ModUtils.isCustomHerbalismBlock(blockState); + } + } + + /** + * Determine if a given block should be affected by Super Breaker + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Super Breaker, false otherwise + */ + public static Boolean affectedBySuperBreaker(BlockState blockState) { + switch (blockState.getType()) { + case COAL_ORE: + case DIAMOND_ORE: + case ENDER_STONE: + case GLOWING_REDSTONE_ORE: + case GLOWSTONE: + case GOLD_ORE: + case IRON_ORE: + case LAPIS_ORE: + case MOSSY_COBBLESTONE: + case NETHERRACK: + case OBSIDIAN: + case REDSTONE_ORE: + case SANDSTONE: + case STONE: + case EMERALD_ORE: + return true; + + default: + return ModUtils.isCustomMiningBlock(blockState); + } + } + + /** + * Determine if a given block should be affected by Giga Drill Breaker + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Giga Drill Breaker, false otherwise + */ + public static boolean affectedByGigaDrillBreaker(BlockState blockState) { + switch (blockState.getType()) { + case CLAY: + case DIRT: + case GRASS: + case GRAVEL: + case MYCEL: + case SAND: + case SOUL_SAND: + return true; + + default: + return ModUtils.isCustomExcavationBlock(blockState); + } + } + + /** + * Determine if a given block should be affected by Tree Feller + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Tree Feller, false otherwise + */ + public static boolean affectedByTreeFeller(BlockState blockState) { + switch (blockState.getType()) { + case LOG: + case LEAVES: + case HUGE_MUSHROOM_1: + case HUGE_MUSHROOM_2: + return true; + + default: + return ModUtils.isCustomWoodcuttingBlock(blockState); + } + } + + /** + * Check if a given block is a log + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block is a log, false otherwise + */ + public static boolean isLog(BlockState blockState) { + switch (blockState.getType()) { + case LOG: + case HUGE_MUSHROOM_1: + case HUGE_MUSHROOM_2: + return true; + + default: + return ModUtils.isCustomLogBlock(blockState); + } + } + + /** + * Check if a given block is a leaf + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block is a leaf, false otherwise + */ + public static boolean isLeaves(BlockState blockState) { + switch (blockState.getType()) { + case LEAVES: + return true; + + default: + return ModUtils.isCustomLeafBlock(blockState); + } + } + + /** + * Determine if a given block should be affected by Flux Mining + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Flux Mining, false otherwise + */ + public static boolean affectedByFluxMining(BlockState blockState) { + switch (blockState.getType()) { + case IRON_ORE: + case GOLD_ORE: + return true; + + default: + return false; + } + } + + /** + * Determine if a given block can activate Herbalism abilities + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block can be activate Herbalism abilities, false otherwise + */ + public static boolean canActivateHerbalism(BlockState blockState) { + switch (blockState.getType()) { + case DIRT: + case GRASS: + case SOIL: + return false; + + default: + return true; + } + } + + /** + * Determine if a given block should be affected by Block Cracker + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block should affected by Block Cracker, false otherwise + */ + public static boolean affectedByBlockCracker(BlockState blockState) { + switch (blockState.getType()) { + case SMOOTH_BRICK: + return blockState.getRawData() == (byte) 0x0; + + default: + return false; + } + } + + /** + * Determine if a given block can be made into Mycelium + * + * @param blockState The {@link BlockState} of the block to check + * @return true if the block can be made in Mycelium, false otherwise + */ + public static boolean canMakeShroomy(BlockState blockState) { + switch (blockState.getType()) { + case DIRT: + case GRASS: + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index cce1946ba..8ddd8d101 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -6,10 +6,11 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.util.metrics.MetricsManager; +import com.gmail.nossr50.metrics.MetricsManager; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; public final class ChimaeraWing { private ChimaeraWing() {} @@ -26,13 +27,13 @@ public final class ChimaeraWing { return; } - PlayerProfile profile = Users.getPlayer(player).getProfile(); + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); Block block = player.getLocation().getBlock(); int amount = inHand.getAmount(); long recentlyHurt = profile.getRecentlyHurt(); if (Permissions.chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) { - if (SkillTools.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) { + if (SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) { player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost())); for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) { @@ -53,8 +54,8 @@ public final class ChimaeraWing { MetricsManager.chimeraWingUsed(); player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass")); } - else if (!SkillTools.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) { - player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillTools.calculateTimeLeft(recentlyHurt, 60, player))); + else if (!SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) { + player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt, 60, player))); } else if (amount <= Config.getInstance().getChimaeraCost()) { player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Config.getInstance().getChimaeraItemId()))); diff --git a/src/main/java/com/gmail/nossr50/util/Hardcore.java b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java similarity index 83% rename from src/main/java/com/gmail/nossr50/util/Hardcore.java rename to src/main/java/com/gmail/nossr50/util/HardcoreManager.java index 7fd8b4500..8170b8b3a 100644 --- a/src/main/java/com/gmail/nossr50/util/Hardcore.java +++ b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java @@ -3,12 +3,13 @@ package com.gmail.nossr50.util; import org.bukkit.entity.Player; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.util.player.UserManager; -public final class Hardcore { - private Hardcore() {} +public final class HardcoreManager { + private HardcoreManager() {} public static void invokeStatPenalty(Player player) { double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage(); @@ -17,7 +18,7 @@ public final class Hardcore { return; } - PlayerProfile playerProfile = Users.getPlayer(player).getProfile(); + PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); int totalLost = 0; for (SkillType skillType : SkillType.values()) { @@ -37,7 +38,7 @@ public final class Hardcore { playerProfile.modifySkill(skillType, playerSkillLevel - levelsLost); } - player.sendMessage(LocaleLoader.getString("Hardcore.Player.Loss", new Object[] {totalLost})); + player.sendMessage(LocaleLoader.getString("Hardcore.Player.Loss", totalLost)); } public static void invokeVampirism(Player killer, Player victim) { @@ -47,8 +48,8 @@ public final class Hardcore { return; } - PlayerProfile killerProfile = Users.getPlayer(killer).getProfile(); - PlayerProfile victimProfile = Users.getPlayer(victim).getProfile(); + PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile(); + PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile(); int totalStolen = 0; for (SkillType skillType : SkillType.values()) { @@ -79,4 +80,4 @@ public final class Hardcore { victim.sendMessage(LocaleLoader.getString("Vampirism.Victim.Failure", killer.getName())); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/util/Anniversary.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java similarity index 88% rename from src/main/java/com/gmail/nossr50/util/Anniversary.java rename to src/main/java/com/gmail/nossr50/util/HolidayManager.java index 0a0a9ee4b..42a72ae81 100644 --- a/src/main/java/com/gmail/nossr50/util/Anniversary.java +++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java @@ -25,22 +25,24 @@ import org.bukkit.inventory.meta.FireworkMeta; import com.gmail.nossr50.mcMMO; -public final class Anniversary { +public final class HolidayManager { public static ArrayList hasCelebrated; - private Anniversary() {} + private HolidayManager() {} - //This gets called onEnable + // This gets called onEnable public static void createAnniversaryFile() { File anniversaryFile = new File(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary"); if (!anniversaryFile.exists()) { try { anniversaryFile.createNewFile(); - } catch (IOException ex) { + } + catch (IOException ex) { mcMMO.p.getLogger().severe(ex.toString()); } } + hasCelebrated = new ArrayList(); try { @@ -54,12 +56,13 @@ public final class Anniversary { } reader.close(); - } catch (Exception ex) { + } + catch (Exception ex) { mcMMO.p.getLogger().severe(ex.toString()); } } - //This gets called onDisable + // This gets called onDisable public static void saveAnniversaryFiles() { try { BufferedWriter writer = new BufferedWriter(new FileWriter(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary")); @@ -74,7 +77,7 @@ public final class Anniversary { } } - //This gets called from /mcmmo command + // This gets called from /mcmmo command public static void anniversaryCheck(final CommandSender sender) { if (sender instanceof Player) { GregorianCalendar anniversaryStart = new GregorianCalendar(2013, Calendar.FEBRUARY, 3); @@ -115,12 +118,27 @@ public final class Anniversary { int power = (int) (Math.random() * 3) + 1; int type = (int) (Math.random() * 5) + 1; - Type typen = Type.BALL; - if (type == 1) typen = Type.BALL; - if (type == 2) typen = Type.BALL_LARGE; - if (type == 3) typen = Type.BURST; - if (type == 4) typen = Type.CREEPER; - if (type == 5) typen = Type.STAR; + Type typen; + switch (type) { + case 2: + typen = Type.BALL_LARGE; + break; + + case 3: + typen = Type.BURST; + break; + + case 4: + typen = Type.CREEPER; + break; + + case 5: + typen = Type.STAR; + break; + + default: + typen = Type.BALL; + } Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK); FireworkMeta fireworkmeta = fireworks.getFireworkMeta(); diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java deleted file mode 100644 index 39c556dc5..000000000 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ /dev/null @@ -1,650 +0,0 @@ -package com.gmail.nossr50.util; - -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.api.SpoutToolsAPI; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.mods.config.CustomArmorConfig; -import com.gmail.nossr50.mods.config.CustomToolsConfig; - -public class ItemChecks { - private static Config configInstance = Config.getInstance(); - private static boolean customToolsEnabled = configInstance.getToolModsEnabled(); - private static boolean customArmorEnabled = configInstance.getArmorModsEnabled(); - - /** - * Checks if the item is a sword. - * - * @param is Item to check - * @return true if the item is a sword, false otherwise - */ - public static boolean isSword(ItemStack is) { - switch (is.getType()) { - case DIAMOND_SWORD: - case GOLD_SWORD: - case IRON_SWORD: - case STONE_SWORD: - case WOOD_SWORD: - return true; - - default: - if (customToolsEnabled && CustomToolsConfig.getInstance().customSwordIDs.contains(is.getTypeId())) { - return true; - } - else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutSwords.contains(is)) { - return true; - } - else { - return false; - } - } - } - - /** - * Checks if the item is a hoe. - * - * @param is Item to check - * @return true if the item is a hoe, false otherwise - */ - public static boolean isHoe(ItemStack is) { - switch (is.getType()) { - case DIAMOND_HOE: - case GOLD_HOE: - case IRON_HOE: - case STONE_HOE: - case WOOD_HOE: - return true; - - default: - if (customToolsEnabled && CustomToolsConfig.getInstance().customHoeIDs.contains(is.getTypeId())) { - return true; - } - else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutHoes.contains(is)) { - return true; - } - else { - return false; - } - } - } - - /** - * Checks if the item is a shovel. - * - * @param is Item to check - * @return true if the item is a shovel, false otherwise - */ - public static boolean isShovel(ItemStack is) { - switch (is.getType()) { - case DIAMOND_SPADE: - case GOLD_SPADE: - case IRON_SPADE: - case STONE_SPADE: - case WOOD_SPADE: - return true; - - default: - if (customToolsEnabled && CustomToolsConfig.getInstance().customShovelIDs.contains(is.getTypeId())) { - return true; - } - else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutShovels.contains(is)) { - return true; - } - else { - return false; - } - } - } - - /** - * Checks if the item is an axe. - * - * @param is Item to check - * @return true if the item is an axe, false otherwise - */ - public static boolean isAxe(ItemStack is) { - switch (is.getType()) { - case DIAMOND_AXE: - case GOLD_AXE: - case IRON_AXE: - case STONE_AXE: - case WOOD_AXE: - return true; - - default: - if (customToolsEnabled && CustomToolsConfig.getInstance().customAxeIDs.contains(is.getTypeId())) { - return true; - } - else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutAxes.contains(is)) { - return true; - } - else { - return false; - } - } - } - - /** - * Checks if the item is a pickaxe. - * - * @param is Item to check - * @return true if the item is a pickaxe, false otherwise - */ - public static boolean isPickaxe(ItemStack is) { - switch (is.getType()) { - case DIAMOND_PICKAXE: - case GOLD_PICKAXE: - case IRON_PICKAXE: - case STONE_PICKAXE: - case WOOD_PICKAXE: - return true; - - default: - if (customToolsEnabled && CustomToolsConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) { - return true; - } - else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutPickaxes.contains(is)) { - return true; - } - else { - return false; - } - } - } - - /** - * Checks if the item is a helmet. - * - * @param is Item to check - * @return true if the item is a helmet, false otherwise - */ - public static boolean isHelmet(ItemStack is) { - switch (is.getType()) { - case DIAMOND_HELMET: - case GOLD_HELMET: - case IRON_HELMET: - case LEATHER_HELMET: - return true; - - default: - if (customArmorEnabled && CustomArmorConfig.getInstance().customHelmetIDs.contains(is.getTypeId())) { - return true; - } - - return false; - } - } - - /** - * Checks if the item is a chestplate. - * - * @param is Item to check - * @return true if the item is a chestplate, false otherwise - */ - public static boolean isChestplate(ItemStack is) { - switch (is.getType()) { - case DIAMOND_CHESTPLATE: - case GOLD_CHESTPLATE: - case IRON_CHESTPLATE: - case LEATHER_CHESTPLATE: - return true; - - default: - if (customArmorEnabled && CustomArmorConfig.getInstance().customChestplateIDs.contains(is.getTypeId())) { - return true; - } - - return false; - } - } - - /** - * Checks if the item is a pair of pants. - * - * @param is Item to check - * @return true if the item is a pair of pants, false otherwise - */ - public static boolean isLeggings(ItemStack is) { - switch (is.getType()) { - case DIAMOND_LEGGINGS: - case GOLD_LEGGINGS: - case IRON_LEGGINGS: - case LEATHER_LEGGINGS: - return true; - - default: - if (customArmorEnabled && CustomArmorConfig.getInstance().customLeggingIDs.contains(is.getTypeId())) { - return true; - } - - return false; - } - } - - /** - * Checks if the item is a pair of boots. - * - * @param is Item to check - * @return true if the item is a pair of boots, false otherwise - */ - public static boolean isBoots(ItemStack is) { - switch (is.getType()) { - case DIAMOND_BOOTS: - case GOLD_BOOTS: - case IRON_BOOTS: - case LEATHER_BOOTS: - return true; - - default: - if (customArmorEnabled && CustomArmorConfig.getInstance().customBootIDs.contains(is.getTypeId())) { - return true; - } - - return false; - } - } - - /** - * Checks to see if an item is a wearable armor piece. - * - * @param is Item to check - * @return true if the item is armor, false otherwise - */ - public static boolean isArmor(ItemStack is) { - return isHelmet(is) || isChestplate(is) || isLeggings(is) || isBoots(is); - } - - /** - * Checks to see if an item is a wearable armor piece. - * - * @param is Item to check - * @return true if the item is armor, false otherwise - */ - public static boolean isMinecraftArmor(ItemStack is) { - return isDiamondArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is); - } - - /** - * Checks to see if an item is a leather armor piece. - * - * @param is Item to check - * @return true if the item is leather armor, false otherwise - */ - public static boolean isLeatherArmor(ItemStack is) { - switch (is.getType()) { - case LEATHER_BOOTS: - case LEATHER_CHESTPLATE: - case LEATHER_HELMET: - case LEATHER_LEGGINGS: - return true; - - default: - return false; - } - } - - /** - * Checks to see if an item is a gold armor piece. - * - * @param is Item to check - * @return true if the item is gold armor, false otherwise - */ - public static boolean isGoldArmor(ItemStack is) { - switch (is.getType()) { - case GOLD_BOOTS: - case GOLD_CHESTPLATE: - case GOLD_HELMET: - case GOLD_LEGGINGS: - return true; - - default: - return false; - } - } - - /** - * Checks to see if an item is an iron armor piece. - * - * @param is Item to check - * @return true if the item is iron armor, false otherwise - */ - public static boolean isIronArmor(ItemStack is) { - switch (is.getType()) { - case IRON_BOOTS: - case IRON_CHESTPLATE: - case IRON_HELMET: - case IRON_LEGGINGS: - return true; - - default: - return false; - } - } - - /** - * Checks to see if an item is a diamond armor piece. - * - * @param is Item to check - * @return true if the item is diamond armor, false otherwise - */ - public static boolean isDiamondArmor(ItemStack is) { - switch (is.getType()) { - case DIAMOND_BOOTS: - case DIAMOND_CHESTPLATE: - case DIAMOND_HELMET: - case DIAMOND_LEGGINGS: - return true; - - default: - return false; - } - } - - /** - * Checks to see if an item is a tool. - * - * @param is Item to check - * @return true if the item is a tool, false otherwise - */ - public static boolean isMinecraftTool(ItemStack is) { - return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is); - } - - /** - * Checks to see if an item is a stone tool. - * - * @param is Item to check - * @return true if the item is a stone tool, false otherwise - */ - public static boolean isStoneTool(ItemStack is) { - switch (is.getType()) { - case STONE_AXE: - case STONE_HOE: - case STONE_PICKAXE: - case STONE_SPADE: - case STONE_SWORD: - return true; - - default: - return false; - } - } - - /** - * Checks to see if an item is a wooden tool. - * - * @param is Item to check - * @return true if the item is a wooden tool, false otherwise - */ - public static boolean isWoodTool(ItemStack is) { - switch (is.getType()) { - case WOOD_AXE: - case WOOD_HOE: - case WOOD_PICKAXE: - case WOOD_SPADE: - case WOOD_SWORD: - return true; - - default: - return false; - } - } - - /** - * Checks to see if an item is a string tool. - * - * @param is Item to check - * @return true if the item is a string tool, false otherwise - */ - public static boolean isStringTool(ItemStack is) { - switch (is.getType()) { - case BOW: - case CARROT_STICK: - case FISHING_ROD: - return true; - - default: - return false; - } - } - - - /** - * Checks to see if an item is a gold tool. - * - * @param is Item to check - * @return true if the item is a stone tool, false otherwise - */ - public static boolean isGoldTool(ItemStack is) { - switch (is.getType()) { - case GOLD_AXE: - case GOLD_HOE: - case GOLD_PICKAXE: - case GOLD_SPADE: - case GOLD_SWORD: - return true; - - default: - return false; - } - } - - /** - * Checks to see if an item is an iron tool. - * - * @param is Item to check - * @return true if the item is an iron tool, false otherwise - */ - public static boolean isIronTool(ItemStack is) { - switch (is.getType()) { - case BUCKET: - case FLINT_AND_STEEL: - case IRON_AXE: - case IRON_HOE: - case IRON_PICKAXE: - case IRON_SPADE: - case IRON_SWORD: - case SHEARS: - return true; - - default: - return false; - } - } - - /** - * Checks to see if an item is a diamond tool. - * - * @param is Item to check - * @return true if the item is a diamond tool, false otherwise - */ - public static boolean isDiamondTool(ItemStack is) { - switch (is.getType()) { - case DIAMOND_AXE: - case DIAMOND_HOE: - case DIAMOND_PICKAXE: - case DIAMOND_SPADE: - case DIAMOND_SWORD: - return true; - - default: - return false; - } - } - - /** - * Checks to see if an item is enchantable. - * - * @param is Item to check - * @return true if the item is enchantable, false otherwise - */ - public static boolean isEnchantable(ItemStack is) { - Material type = is.getType(); - return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) || - type == Material.SHEARS || type == Material.FISHING_ROD || type == Material.CARROT_STICK || - type == Material.FLINT_AND_STEEL || type == Material.BOW; - } - - public static boolean isSmeltable(ItemStack itemStack) { - switch (itemStack.getType()) { - case COAL_ORE: - case DIAMOND_ORE: - case GLOWING_REDSTONE_ORE: - case GOLD_ORE: - case IRON_ORE: - case LAPIS_ORE: - case REDSTONE_ORE: - case EMERALD_ORE: - return true; - - default: - return false; - } - } - - public static boolean isSmelted(ItemStack itemStack) { - switch (itemStack.getType()) { - case COAL: - case DIAMOND: - case REDSTONE: - case GOLD_INGOT: - case IRON_INGOT: - case EMERALD: - return true; - - case INK_SACK: - if (itemStack.getData().getData() == DyeColor.BLUE.getDyeData()) { - return true; - } - - return false; - - default: - return false; - } - } - - /** - * Check if an item is sharable. - * - * @param item Item that will get shared - * @return True if the item can be shared. - */ - public static boolean isShareable(ItemStack is) { - return isMiningDrop(is) || isWoodcuttingDrop(is) || isMobDrop(is) || isHerbalismDrop(is); - } - - /** - * Checks to see if an item is a mining drop. - * - * @param is Item to check - * @return true if the item is a mining drop, false otherwise - */ - public static boolean isMiningDrop(ItemStack is) { - switch (is.getType()) { - case COAL: - case COAL_ORE: - case DIAMOND: - case DIAMOND_ORE: - case EMERALD: - case EMERALD_ORE: - case GOLD_ORE: - case IRON_ORE: - case LAPIS_ORE: - case REDSTONE_ORE: - case REDSTONE: - case GLOWSTONE_DUST: - return true; - - case INK_SACK: - if (is.getData().getData() == DyeColor.BLUE.getDyeData()) { - return true; - } - - return false; - - default: - return false; - } - } - - public static boolean isHerbalismDrop(ItemStack is) { - switch (is.getType()) { - case WHEAT: - case SEEDS: - case CARROT: - case POTATO: - case COCOA: - case NETHER_WARTS: - case BROWN_MUSHROOM: - case RED_MUSHROOM: - case RED_ROSE: - case YELLOW_FLOWER: - case CACTUS: - case SUGAR_CANE: - case MELON: - case PUMPKIN: - case WATER_LILY: - case VINE: - return true; - - case INK_SACK: - return is.getData().getData() == DyeColor.BROWN.getDyeData(); - - default: - return false; - } - } - - public static boolean isMobDrop(ItemStack is) { - switch (is.getType()) { - case STRING: - case FEATHER: - case RAW_CHICKEN: - case COOKED_CHICKEN: - case LEATHER: - case RAW_BEEF: - case COOKED_BEEF: - case PORK: - case GRILLED_PORK: - case WOOL: - case RED_ROSE: - case IRON_INGOT: - case SNOW_BALL: - case BLAZE_ROD: - case SPIDER_EYE: - case SULPHUR: - case ENDER_PEARL: - case GHAST_TEAR: - case MAGMA_CREAM: - case BONE: - case ARROW: - case SLIME_BALL: - case NETHER_STAR: - case COAL: - case ROTTEN_FLESH: - case GOLD_NUGGET: - case EGG: - return true; - - default: - return false; - } - } - - public static boolean isWoodcuttingDrop(ItemStack is) { - switch (is.getType()) { - case LOG: - case LEAVES: - case SAPLING: - case APPLE: - return true; - - default: - return false; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java new file mode 100644 index 000000000..94266a1fb --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -0,0 +1,647 @@ +package com.gmail.nossr50.util; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.api.SpoutToolsAPI; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.mods.CustomArmorConfig; +import com.gmail.nossr50.config.mods.CustomToolConfig; + +public class ItemUtils { + private static Config configInstance = Config.getInstance(); + private static boolean customToolsEnabled = configInstance.getToolModsEnabled(); + private static boolean customArmorEnabled = configInstance.getArmorModsEnabled(); + + /** + * Checks if the item is a sword. + * + * @param is Item to check + * @return true if the item is a sword, false otherwise + */ + public static boolean isSword(ItemStack is) { + switch (is.getType()) { + case DIAMOND_SWORD: + case GOLD_SWORD: + case IRON_SWORD: + case STONE_SWORD: + case WOOD_SWORD: + return true; + + default: + if (customToolsEnabled && CustomToolConfig.getInstance().customSwordIDs.contains(is.getTypeId())) { + return true; + } + else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutSwords.contains(is)) { + return true; + } + else { + return false; + } + } + } + + /** + * Checks if the item is a hoe. + * + * @param is Item to check + * @return true if the item is a hoe, false otherwise + */ + public static boolean isHoe(ItemStack is) { + switch (is.getType()) { + case DIAMOND_HOE: + case GOLD_HOE: + case IRON_HOE: + case STONE_HOE: + case WOOD_HOE: + return true; + + default: + if (customToolsEnabled && CustomToolConfig.getInstance().customHoeIDs.contains(is.getTypeId())) { + return true; + } + else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutHoes.contains(is)) { + return true; + } + else { + return false; + } + } + } + + /** + * Checks if the item is a shovel. + * + * @param is Item to check + * @return true if the item is a shovel, false otherwise + */ + public static boolean isShovel(ItemStack is) { + switch (is.getType()) { + case DIAMOND_SPADE: + case GOLD_SPADE: + case IRON_SPADE: + case STONE_SPADE: + case WOOD_SPADE: + return true; + + default: + if (customToolsEnabled && CustomToolConfig.getInstance().customShovelIDs.contains(is.getTypeId())) { + return true; + } + else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutShovels.contains(is)) { + return true; + } + else { + return false; + } + } + } + + /** + * Checks if the item is an axe. + * + * @param is Item to check + * @return true if the item is an axe, false otherwise + */ + public static boolean isAxe(ItemStack is) { + switch (is.getType()) { + case DIAMOND_AXE: + case GOLD_AXE: + case IRON_AXE: + case STONE_AXE: + case WOOD_AXE: + return true; + + default: + if (customToolsEnabled && CustomToolConfig.getInstance().customAxeIDs.contains(is.getTypeId())) { + return true; + } + else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutAxes.contains(is)) { + return true; + } + else { + return false; + } + } + } + + /** + * Checks if the item is a pickaxe. + * + * @param is Item to check + * @return true if the item is a pickaxe, false otherwise + */ + public static boolean isPickaxe(ItemStack is) { + switch (is.getType()) { + case DIAMOND_PICKAXE: + case GOLD_PICKAXE: + case IRON_PICKAXE: + case STONE_PICKAXE: + case WOOD_PICKAXE: + return true; + + default: + if (customToolsEnabled && CustomToolConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) { + return true; + } + else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutPickaxes.contains(is)) { + return true; + } + else { + return false; + } + } + } + + /** + * Checks if the item is a helmet. + * + * @param is Item to check + * @return true if the item is a helmet, false otherwise + */ + public static boolean isHelmet(ItemStack is) { + switch (is.getType()) { + case DIAMOND_HELMET: + case GOLD_HELMET: + case IRON_HELMET: + case LEATHER_HELMET: + return true; + + default: + if (customArmorEnabled && CustomArmorConfig.getInstance().customHelmetIDs.contains(is.getTypeId())) { + return true; + } + + return false; + } + } + + /** + * Checks if the item is a chestplate. + * + * @param is Item to check + * @return true if the item is a chestplate, false otherwise + */ + public static boolean isChestplate(ItemStack is) { + switch (is.getType()) { + case DIAMOND_CHESTPLATE: + case GOLD_CHESTPLATE: + case IRON_CHESTPLATE: + case LEATHER_CHESTPLATE: + return true; + + default: + if (customArmorEnabled && CustomArmorConfig.getInstance().customChestplateIDs.contains(is.getTypeId())) { + return true; + } + + return false; + } + } + + /** + * Checks if the item is a pair of pants. + * + * @param is Item to check + * @return true if the item is a pair of pants, false otherwise + */ + public static boolean isLeggings(ItemStack is) { + switch (is.getType()) { + case DIAMOND_LEGGINGS: + case GOLD_LEGGINGS: + case IRON_LEGGINGS: + case LEATHER_LEGGINGS: + return true; + + default: + if (customArmorEnabled && CustomArmorConfig.getInstance().customLeggingIDs.contains(is.getTypeId())) { + return true; + } + + return false; + } + } + + /** + * Checks if the item is a pair of boots. + * + * @param is Item to check + * @return true if the item is a pair of boots, false otherwise + */ + public static boolean isBoots(ItemStack is) { + switch (is.getType()) { + case DIAMOND_BOOTS: + case GOLD_BOOTS: + case IRON_BOOTS: + case LEATHER_BOOTS: + return true; + + default: + if (customArmorEnabled && CustomArmorConfig.getInstance().customBootIDs.contains(is.getTypeId())) { + return true; + } + + return false; + } + } + + /** + * Checks to see if an item is a wearable armor piece. + * + * @param is Item to check + * @return true if the item is armor, false otherwise + */ + public static boolean isArmor(ItemStack is) { + return isHelmet(is) || isChestplate(is) || isLeggings(is) || isBoots(is); + } + + /** + * Checks to see if an item is a wearable armor piece. + * + * @param is Item to check + * @return true if the item is armor, false otherwise + */ + public static boolean isMinecraftArmor(ItemStack is) { + return isDiamondArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is); + } + + /** + * Checks to see if an item is a leather armor piece. + * + * @param is Item to check + * @return true if the item is leather armor, false otherwise + */ + public static boolean isLeatherArmor(ItemStack is) { + switch (is.getType()) { + case LEATHER_BOOTS: + case LEATHER_CHESTPLATE: + case LEATHER_HELMET: + case LEATHER_LEGGINGS: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is a gold armor piece. + * + * @param is Item to check + * @return true if the item is gold armor, false otherwise + */ + public static boolean isGoldArmor(ItemStack is) { + switch (is.getType()) { + case GOLD_BOOTS: + case GOLD_CHESTPLATE: + case GOLD_HELMET: + case GOLD_LEGGINGS: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is an iron armor piece. + * + * @param is Item to check + * @return true if the item is iron armor, false otherwise + */ + public static boolean isIronArmor(ItemStack is) { + switch (is.getType()) { + case IRON_BOOTS: + case IRON_CHESTPLATE: + case IRON_HELMET: + case IRON_LEGGINGS: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is a diamond armor piece. + * + * @param is Item to check + * @return true if the item is diamond armor, false otherwise + */ + public static boolean isDiamondArmor(ItemStack is) { + switch (is.getType()) { + case DIAMOND_BOOTS: + case DIAMOND_CHESTPLATE: + case DIAMOND_HELMET: + case DIAMOND_LEGGINGS: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is a tool. + * + * @param is Item to check + * @return true if the item is a tool, false otherwise + */ + public static boolean isMinecraftTool(ItemStack is) { + return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is); + } + + /** + * Checks to see if an item is a stone tool. + * + * @param is Item to check + * @return true if the item is a stone tool, false otherwise + */ + public static boolean isStoneTool(ItemStack is) { + switch (is.getType()) { + case STONE_AXE: + case STONE_HOE: + case STONE_PICKAXE: + case STONE_SPADE: + case STONE_SWORD: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is a wooden tool. + * + * @param is Item to check + * @return true if the item is a wooden tool, false otherwise + */ + public static boolean isWoodTool(ItemStack is) { + switch (is.getType()) { + case WOOD_AXE: + case WOOD_HOE: + case WOOD_PICKAXE: + case WOOD_SPADE: + case WOOD_SWORD: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is a string tool. + * + * @param is Item to check + * @return true if the item is a string tool, false otherwise + */ + public static boolean isStringTool(ItemStack is) { + switch (is.getType()) { + case BOW: + case CARROT_STICK: + case FISHING_ROD: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is a gold tool. + * + * @param is Item to check + * @return true if the item is a stone tool, false otherwise + */ + public static boolean isGoldTool(ItemStack is) { + switch (is.getType()) { + case GOLD_AXE: + case GOLD_HOE: + case GOLD_PICKAXE: + case GOLD_SPADE: + case GOLD_SWORD: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is an iron tool. + * + * @param is Item to check + * @return true if the item is an iron tool, false otherwise + */ + public static boolean isIronTool(ItemStack is) { + switch (is.getType()) { + case BUCKET: + case FLINT_AND_STEEL: + case IRON_AXE: + case IRON_HOE: + case IRON_PICKAXE: + case IRON_SPADE: + case IRON_SWORD: + case SHEARS: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is a diamond tool. + * + * @param is Item to check + * @return true if the item is a diamond tool, false otherwise + */ + public static boolean isDiamondTool(ItemStack is) { + switch (is.getType()) { + case DIAMOND_AXE: + case DIAMOND_HOE: + case DIAMOND_PICKAXE: + case DIAMOND_SPADE: + case DIAMOND_SWORD: + return true; + + default: + return false; + } + } + + /** + * Checks to see if an item is enchantable. + * + * @param is Item to check + * @return true if the item is enchantable, false otherwise + */ + public static boolean isEnchantable(ItemStack is) { + Material type = is.getType(); + return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) || type == Material.SHEARS || type == Material.FISHING_ROD || type == Material.CARROT_STICK || type == Material.FLINT_AND_STEEL || type == Material.BOW; + } + + public static boolean isSmeltable(ItemStack itemStack) { + switch (itemStack.getType()) { + case COAL_ORE: + case DIAMOND_ORE: + case GLOWING_REDSTONE_ORE: + case GOLD_ORE: + case IRON_ORE: + case LAPIS_ORE: + case REDSTONE_ORE: + case EMERALD_ORE: + return true; + + default: + return false; + } + } + + public static boolean isSmelted(ItemStack itemStack) { + switch (itemStack.getType()) { + case COAL: + case DIAMOND: + case REDSTONE: + case GOLD_INGOT: + case IRON_INGOT: + case EMERALD: + return true; + + case INK_SACK: + if (itemStack.getData().getData() == DyeColor.BLUE.getDyeData()) { + return true; + } + + return false; + + default: + return false; + } + } + + /** + * Check if an item is sharable. + * + * @param item Item that will get shared + * @return True if the item can be shared. + */ + public static boolean isShareable(ItemStack is) { + return isMiningDrop(is) || isWoodcuttingDrop(is) || isMobDrop(is) || isHerbalismDrop(is); + } + + /** + * Checks to see if an item is a mining drop. + * + * @param is Item to check + * @return true if the item is a mining drop, false otherwise + */ + public static boolean isMiningDrop(ItemStack is) { + switch (is.getType()) { + case COAL: + case COAL_ORE: + case DIAMOND: + case DIAMOND_ORE: + case EMERALD: + case EMERALD_ORE: + case GOLD_ORE: + case IRON_ORE: + case LAPIS_ORE: + case REDSTONE_ORE: + case REDSTONE: + case GLOWSTONE_DUST: + return true; + + case INK_SACK: + if (is.getData().getData() == DyeColor.BLUE.getDyeData()) { + return true; + } + + return false; + + default: + return false; + } + } + + public static boolean isHerbalismDrop(ItemStack is) { + switch (is.getType()) { + case WHEAT: + case SEEDS: + case CARROT: + case POTATO: + case COCOA: + case NETHER_WARTS: + case BROWN_MUSHROOM: + case RED_MUSHROOM: + case RED_ROSE: + case YELLOW_FLOWER: + case CACTUS: + case SUGAR_CANE: + case MELON: + case PUMPKIN: + case WATER_LILY: + case VINE: + return true; + + case INK_SACK: + return is.getData().getData() == DyeColor.BROWN.getDyeData(); + + default: + return false; + } + } + + public static boolean isMobDrop(ItemStack is) { + switch (is.getType()) { + case STRING: + case FEATHER: + case RAW_CHICKEN: + case COOKED_CHICKEN: + case LEATHER: + case RAW_BEEF: + case COOKED_BEEF: + case PORK: + case GRILLED_PORK: + case WOOL: + case RED_ROSE: + case IRON_INGOT: + case SNOW_BALL: + case BLAZE_ROD: + case SPIDER_EYE: + case SULPHUR: + case ENDER_PEARL: + case GHAST_TEAR: + case MAGMA_CREAM: + case BONE: + case ARROW: + case SLIME_BALL: + case NETHER_STAR: + case COAL: + case ROTTEN_FLESH: + case GOLD_NUGGET: + case EGG: + return true; + + default: + return false; + } + } + + public static boolean isWoodcuttingDrop(ItemStack is) { + switch (is.getType()) { + case LOG: + case LEAVES: + case SAPLING: + case APPLE: + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 2f4fac3f2..e19eebde6 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -11,7 +11,6 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; -import com.gmail.nossr50.mods.ModChecks; public final class Misc { private static Random random = new Random(); @@ -19,13 +18,14 @@ public final class Misc { public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5; public static final int TIME_CONVERSION_FACTOR = 1000; public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0; - //Sound Pitches & Volumes from CB - public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values + + // Sound Pitches & Volumes from CB + public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values public static final float ANVIL_USE_VOLUME = 1.0F; // Not in CB directly, I went off the place sound values - public static final float FIZZ_PITCH = 2.6F + (Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.8F; - public static final float FIZZ_VOLUME = 0.5F; - public static final float POP_PITCH = ((getRandom().nextFloat() - getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F; - public static final float POP_VOLUME = 0.2F; + public static final float FIZZ_PITCH = 2.6F + (Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.8F; + public static final float FIZZ_VOLUME = 0.5F; + public static final float POP_PITCH = ((getRandom().nextFloat() - getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F; + public static final float POP_VOLUME = 0.2F; private Misc() {}; @@ -46,23 +46,23 @@ public final class Misc { public static int getTier(ItemStack inHand) { int tier = 0; - if (ItemChecks.isWoodTool(inHand)) { + if (ItemUtils.isWoodTool(inHand)) { tier = 1; } - else if (ItemChecks.isStoneTool(inHand)) { + else if (ItemUtils.isStoneTool(inHand)) { tier = 2; } - else if (ItemChecks.isIronTool(inHand)) { + else if (ItemUtils.isIronTool(inHand)) { tier = 3; } - else if (ItemChecks.isGoldTool(inHand)) { + else if (ItemUtils.isGoldTool(inHand)) { tier = 1; } - else if (ItemChecks.isDiamondTool(inHand)) { + else if (ItemUtils.isDiamondTool(inHand)) { tier = 4; } - else if (ModChecks.isCustomTool(inHand)) { - tier = ModChecks.getToolFromItemStack(inHand).getTier(); + else if (ModUtils.isCustomTool(inHand)) { + tier = ModUtils.getToolFromItemStack(inHand).getTier(); } return tier; @@ -147,8 +147,9 @@ public final class Misc { McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack); mcMMO.p.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) + if (event.isCancelled()) { return; + } Item newItem = location.getWorld().dropItemNaturally(location, itemStack); diff --git a/src/main/java/com/gmail/nossr50/mods/ModChecks.java b/src/main/java/com/gmail/nossr50/util/ModUtils.java similarity index 74% rename from src/main/java/com/gmail/nossr50/mods/ModChecks.java rename to src/main/java/com/gmail/nossr50/util/ModUtils.java index e793bf518..34dee45b5 100644 --- a/src/main/java/com/gmail/nossr50/mods/ModChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ModUtils.java @@ -1,293 +1,294 @@ -package com.gmail.nossr50.mods; - -import org.bukkit.block.BlockState; -import org.bukkit.entity.Entity; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.mods.config.CustomArmorConfig; -import com.gmail.nossr50.mods.config.CustomBlocksConfig; -import com.gmail.nossr50.mods.config.CustomEntityConfig; -import com.gmail.nossr50.mods.config.CustomToolsConfig; -import com.gmail.nossr50.mods.datatypes.CustomBlock; -import com.gmail.nossr50.mods.datatypes.CustomEntity; -import com.gmail.nossr50.mods.datatypes.CustomItem; -import com.gmail.nossr50.mods.datatypes.CustomTool; - -public final class ModChecks { - private static Config configInstance = Config.getInstance(); - private static boolean customToolsEnabled = configInstance.getToolModsEnabled(); - private static boolean customArmorEnabled = configInstance.getArmorModsEnabled(); - private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled(); - private static boolean customEntitiesEnabled = configInstance.getEntityModsEnabled(); - - private ModChecks() {} - - /** - * Get the custom armor associated with an item. - * - * @param item The item to check - * @return the armor if it exists, null otherwise - */ - public static CustomItem getArmorFromItemStack(ItemStack item) { - return CustomArmorConfig.getInstance().customArmor.get(item.getTypeId()); - } - - /** - * Get the custom tool associated with an item. - * - * @param item The item to check - * @return the tool if it exists, null otherwise - */ - public static CustomTool getToolFromItemStack(ItemStack item) { - return CustomToolsConfig.getInstance().customTools.get(item.getTypeId()); - } - - /** - * Get the custom block associated with an block. - * - * @param blockState The block to check - * @return the block if it exists, null otherwise - */ - public static CustomBlock getCustomBlock(BlockState blockState) { - if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); - - if (CustomBlocksConfig.getInstance().customItems.contains(item)) { - for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { - if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { - return block; - } - } - } - } - - return null; - } - - public static CustomEntity getCustomEntity(Entity entity) { - if (!CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId()) && !CustomEntityConfig.getInstance().customEntityTypes.contains(entity.getType())) { - return null; - } - - for (CustomEntity customEntity : CustomEntityConfig.getInstance().customEntities) { - if ((customEntity.getEntityID() == entity.getEntityId()) && (customEntity.getEntityType() == entity.getType())) { - return customEntity; - } - } - - return null; - } - - /** - * Check if a custom block is a woodcutting block. - * - * @param block The block to check - * @return true if the block represents a log, false otherwise - */ - public static boolean isCustomWoodcuttingBlock(BlockState blockState) { - if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); - - if (CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(item)) { - for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { - if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { - return true; - } - } - } - } - - return false; - } - - /** - * Check if a custom block should not activate abilites. - * - * @param block The block to check - * @return true if the block represents an ability block, false otherwise - */ - public static boolean isCustomAbilityBlock(BlockState blockState) { - if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); - - if (CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) { - for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { - if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { - return true; - } - } - } - } - - return false; - } - - /** - * Check if a custom block is a mining block. - * - * @param block The block to check - * @return true if the block is custom, false otherwise - */ - public static boolean isCustomMiningBlock(BlockState blockState) { - if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); - - if (CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) { - for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { - if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { - return true; - } - } - } - } - - return false; - } - - /** - * Check if a custom block is an excavation block. - * - * @param block The block to check - * @return true if the block is custom, false otherwise - */ - public static boolean isCustomExcavationBlock(BlockState blockState) { - if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); - - if (CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) { - for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { - if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { - return true; - } - } - } - } - - return false; - } - - /** - * Check if a custom block is an herbalism block. - * - * @param blockState The block to check - * @return true if the block is custom, false otherwise - */ - public static boolean isCustomHerbalismBlock(BlockState blockState) { - if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); - - if (CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) { - for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { - if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { - return true; - } - } - } - } - - return false; - } - - /** - * Check if a custom block is a leaf block. - * - * @param block The block to check - * @return true if the block represents leaves, false otherwise - */ - public static boolean isCustomLeafBlock(BlockState blockState) { - if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); - - if (CustomBlocksConfig.getInstance().customLeaves.contains(item)) { - for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { - if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { - return true; - } - } - } - } - - return false; - } - - /** - * Check if a custom block is a log block. - * - * @param block The block to check - * @return true if the block represents a log, false otherwise - */ - public static boolean isCustomLogBlock(BlockState blockState) { - if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); - - if (CustomBlocksConfig.getInstance().customLogs.contains(item)) { - for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { - if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { - return true; - } - } - } - } - - return false; - } - - /** - * Check if a custom block is an ore block. - * - * @param blockState The block to check - * @return true if the block represents an ore, false otherwise - */ - public static boolean isCustomOreBlock(BlockState blockState) { - if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); - - if (CustomBlocksConfig.getInstance().customOres.contains(item)) { - for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) { - if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { - return true; - } - } - } - } - - return false; - } - - /** - * Checks to see if an item is a custom tool. - * - * @param item Item to check - * @return true if the item is a custom tool, false otherwise - */ - public static boolean isCustomTool(ItemStack item) { - if (customToolsEnabled && CustomToolsConfig.getInstance().customTools.containsKey(item.getTypeId())) { - return true; - } - - return false; - } - - /** - * Checks to see if an item is custom armor. - * - * @param item Item to check - * @return true if the item is custom armor, false otherwise - */ - public static boolean isCustomArmor(ItemStack item) { - if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.containsKey(item.getTypeId())) { - return true; - } - - return false; - } - - public static boolean isCustomEntity(Entity entity) { - if (customEntitiesEnabled && CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId())) { - return true; - } - - return false; - } -} +package com.gmail.nossr50.util; + +import org.bukkit.block.BlockState; +import org.bukkit.entity.Entity; +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.mods.CustomArmorConfig; +import com.gmail.nossr50.config.mods.CustomBlockConfig; +import com.gmail.nossr50.config.mods.CustomEntityConfig; +import com.gmail.nossr50.config.mods.CustomToolConfig; +import com.gmail.nossr50.datatypes.mods.CustomBlock; +import com.gmail.nossr50.datatypes.mods.CustomEntity; +import com.gmail.nossr50.datatypes.mods.CustomItem; +import com.gmail.nossr50.datatypes.mods.CustomTool; + +public final class ModUtils { + private static Config configInstance = Config.getInstance(); + + private static boolean customToolsEnabled = configInstance.getToolModsEnabled(); + private static boolean customArmorEnabled = configInstance.getArmorModsEnabled(); + private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled(); + private static boolean customEntitiesEnabled = configInstance.getEntityModsEnabled(); + + private ModUtils() {} + + /** + * Get the custom armor associated with an item. + * + * @param item The item to check + * @return the armor if it exists, null otherwise + */ + public static CustomItem getArmorFromItemStack(ItemStack item) { + return CustomArmorConfig.getInstance().customArmor.get(item.getTypeId()); + } + + /** + * Get the custom tool associated with an item. + * + * @param item The item to check + * @return the tool if it exists, null otherwise + */ + public static CustomTool getToolFromItemStack(ItemStack item) { + return CustomToolConfig.getInstance().customTools.get(item.getTypeId()); + } + + /** + * Get the custom block associated with an block. + * + * @param blockState The block to check + * @return the block if it exists, null otherwise + */ + public static CustomBlock getCustomBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlockConfig.getInstance().customItems.contains(item)) { + for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return block; + } + } + } + } + + return null; + } + + public static CustomEntity getCustomEntity(Entity entity) { + if (!CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId()) && !CustomEntityConfig.getInstance().customEntityTypes.contains(entity.getType())) { + return null; + } + + for (CustomEntity customEntity : CustomEntityConfig.getInstance().customEntities) { + if ((customEntity.getEntityID() == entity.getEntityId()) && (customEntity.getEntityType() == entity.getType())) { + return customEntity; + } + } + + return null; + } + + /** + * Check if a custom block is a woodcutting block. + * + * @param block The block to check + * @return true if the block represents a log, false otherwise + */ + public static boolean isCustomWoodcuttingBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) { + for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block should not activate abilites. + * + * @param block The block to check + * @return true if the block represents an ability block, false otherwise + */ + public static boolean isCustomAbilityBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) { + for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block is a mining block. + * + * @param block The block to check + * @return true if the block is custom, false otherwise + */ + public static boolean isCustomMiningBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) { + for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block is an excavation block. + * + * @param block The block to check + * @return true if the block is custom, false otherwise + */ + public static boolean isCustomExcavationBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) { + for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block is an herbalism block. + * + * @param blockState The block to check + * @return true if the block is custom, false otherwise + */ + public static boolean isCustomHerbalismBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) { + for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block is a leaf block. + * + * @param block The block to check + * @return true if the block represents leaves, false otherwise + */ + public static boolean isCustomLeafBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlockConfig.getInstance().customLeaves.contains(item)) { + for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block is a log block. + * + * @param block The block to check + * @return true if the block represents a log, false otherwise + */ + public static boolean isCustomLogBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlockConfig.getInstance().customLogs.contains(item)) { + for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Check if a custom block is an ore block. + * + * @param blockState The block to check + * @return true if the block represents an ore, false otherwise + */ + public static boolean isCustomOreBlock(BlockState blockState) { + if (customBlocksEnabled) { + ItemStack item = blockState.getData().toItemStack(); + + if (CustomBlockConfig.getInstance().customOres.contains(item)) { + for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { + if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) { + return true; + } + } + } + } + + return false; + } + + /** + * Checks to see if an item is a custom tool. + * + * @param item Item to check + * @return true if the item is a custom tool, false otherwise + */ + public static boolean isCustomTool(ItemStack item) { + if (customToolsEnabled && CustomToolConfig.getInstance().customTools.containsKey(item.getTypeId())) { + return true; + } + + return false; + } + + /** + * Checks to see if an item is custom armor. + * + * @param item Item to check + * @return true if the item is custom armor, false otherwise + */ + public static boolean isCustomArmor(ItemStack item) { + if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.containsKey(item.getTypeId())) { + return true; + } + + return false; + } + + public static boolean isCustomEntity(Entity entity) { + if (customEntitiesEnabled && CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId())) { + return true; + } + + return false; + } +} diff --git a/src/main/java/com/gmail/nossr50/util/Motd.java b/src/main/java/com/gmail/nossr50/util/Motd.java index 13a9239f3..55474f2d7 100644 --- a/src/main/java/com/gmail/nossr50/util/Motd.java +++ b/src/main/java/com/gmail/nossr50/util/Motd.java @@ -1,115 +1,122 @@ -package com.gmail.nossr50.util; - -import java.text.DecimalFormat; - -import org.bukkit.entity.Player; -import org.bukkit.plugin.PluginDescriptionFile; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.PerksUtils; -import com.gmail.nossr50.skills.utilities.SkillType; - -public final class Motd { - private static final String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix"); - private static final PluginDescriptionFile pluginDescription = mcMMO.p.getDescription(); - - private Motd() {} - - public static void displayAll(Player player) { - displayVersion(player, pluginDescription.getVersion()); - displayHardcoreSettings(player); - displayXpPerks(player); - displayCooldownPerks(player); - displayActivationPerks(player); - displayLuckyPerks(player); - displayWebsite(player, pluginDescription.getWebsite()); - } - - /** - * Display version info. - * @param player Target player - * @param version Plugin version - */ - public static void displayVersion(Player player, String version) { - player.sendMessage(LocaleLoader.getString("MOTD.Version", version)); - } - - /** - * Display Hardcore Mode settings. - * @param player Target player - */ - public static void displayHardcoreSettings(Player player) { - if (Config.getInstance().getHardcoreEnabled()) { - if (Config.getInstance().getHardcoreVampirismEnabled()) { - player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOn")); - player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", Config.getInstance().getHardcoreDeathStatPenaltyPercentage())); - player.sendMessage(LocaleLoader.getString("MOTD.Vampire.Stats", Config.getInstance().getHardcoreVampirismStatLeechPercentage())); - } - else { - player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOff")); - player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", Config.getInstance().getHardcoreDeathStatPenaltyPercentage())); - } - } - } - - /** - * Display XP perks. - * @param player Target player - */ - public static void displayXpPerks(Player player) { - int perkAmount = PerksUtils.handleXpPerks(player, 1); - - if (perkAmount > 1) { - player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", perkAmount))); - } - } - - /** - * Display cooldown perks. - * @param player Target player - */ - public static void displayCooldownPerks(Player player) { - double cooldownReduction = 1 - (PerksUtils.handleCooldownPerks(player, 12) / 12.0); - - if (cooldownReduction > 0.0) { - DecimalFormat percent = new DecimalFormat("##0.00%"); - player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", percent.format(cooldownReduction)))); - } - } - - /** - * Display activiation perks. - * @param player Target player - */ - public static void displayActivationPerks(Player player) { - int perkAmount = PerksUtils.handleActivationPerks(player, 0, 0); - - if (perkAmount > 0) { - player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", perkAmount))); - } - } - - /** - * Display "lucky" perks. - * @param player Target player - */ - public static void displayLuckyPerks(Player player) { - for (SkillType skill : SkillType.values()) { - if (Permissions.lucky(player, skill)) { - player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login"))); - return; - } - } - } - - /** - * Display website info. - * @param player Target player - * @param website Plugin website - */ - public static void displayWebsite(Player player, String website) { - player.sendMessage(LocaleLoader.getString("MOTD.Website", website)); - } -} +package com.gmail.nossr50.util; + +import java.text.DecimalFormat; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.PluginDescriptionFile; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.skills.PerksUtils; + +public final class Motd { + private static final String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix"); + private static final PluginDescriptionFile pluginDescription = mcMMO.p.getDescription(); + + private Motd() {} + + public static void displayAll(Player player) { + displayVersion(player, pluginDescription.getVersion()); + displayHardcoreSettings(player); + displayXpPerks(player); + displayCooldownPerks(player); + displayActivationPerks(player); + displayLuckyPerks(player); + displayWebsite(player, pluginDescription.getWebsite()); + } + + /** + * Display version info. + * + * @param player Target player + * @param version Plugin version + */ + public static void displayVersion(Player player, String version) { + player.sendMessage(LocaleLoader.getString("MOTD.Version", version)); + } + + /** + * Display Hardcore Mode settings. + * + * @param player Target player + */ + public static void displayHardcoreSettings(Player player) { + if (Config.getInstance().getHardcoreEnabled()) { + if (Config.getInstance().getHardcoreVampirismEnabled()) { + player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOn")); + player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", Config.getInstance().getHardcoreDeathStatPenaltyPercentage())); + player.sendMessage(LocaleLoader.getString("MOTD.Vampire.Stats", Config.getInstance().getHardcoreVampirismStatLeechPercentage())); + } + else { + player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOff")); + player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", Config.getInstance().getHardcoreDeathStatPenaltyPercentage())); + } + } + } + + /** + * Display XP perks. + * + * @param player Target player + */ + public static void displayXpPerks(Player player) { + int perkAmount = PerksUtils.handleXpPerks(player, 1); + + if (perkAmount > 1) { + player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", perkAmount))); + } + } + + /** + * Display cooldown perks. + * + * @param player Target player + */ + public static void displayCooldownPerks(Player player) { + double cooldownReduction = 1 - (PerksUtils.handleCooldownPerks(player, 12) / 12.0); + + if (cooldownReduction > 0.0) { + DecimalFormat percent = new DecimalFormat("##0.00%"); + player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", percent.format(cooldownReduction)))); + } + } + + /** + * Display activiation perks. + * + * @param player Target player + */ + public static void displayActivationPerks(Player player) { + int perkAmount = PerksUtils.handleActivationPerks(player, 0, 0); + + if (perkAmount > 0) { + player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", perkAmount))); + } + } + + /** + * Display "lucky" perks. + * + * @param player Target player + */ + public static void displayLuckyPerks(Player player) { + for (SkillType skill : SkillType.values()) { + if (Permissions.lucky(player, skill)) { + player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login"))); + return; + } + } + } + + /** + * Display website info. + * + * @param player Target player + * @param website Plugin website + */ + public static void displayWebsite(Player player, String website) { + player.sendMessage(LocaleLoader.getString("MOTD.Website", website)); + } +} diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index bf687c293..e4bba0500 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -9,8 +9,8 @@ import org.bukkit.permissions.PermissionDefault; import org.bukkit.plugin.PluginManager; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.commands.PartySubcommandType; -import com.gmail.nossr50.skills.utilities.SkillType; +import com.gmail.nossr50.commands.party.PartySubcommandType; +import com.gmail.nossr50.datatypes.skills.SkillType; public final class Permissions { private Permissions() {} diff --git a/src/main/java/com/gmail/nossr50/util/StringUtils.java b/src/main/java/com/gmail/nossr50/util/StringUtils.java index 2d324cf5d..9e5a08487 100644 --- a/src/main/java/com/gmail/nossr50/util/StringUtils.java +++ b/src/main/java/com/gmail/nossr50/util/StringUtils.java @@ -1,136 +1,135 @@ -package com.gmail.nossr50.util; - -import org.bukkit.Material; -import org.bukkit.entity.EntityType; - -public class StringUtils { - - /** - * Gets a capitalized version of the target string. - * - * @param target String to capitalize - * @return the capitalized string - */ - public static String getCapitalized(String target) { - String firstLetter = target.substring(0,1); - String remainder = target.substring(1); - String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase(); - - return capitalized; - } - - /** - * Gets a nicely formatted string version of an item name from a given item ID. - * - * @param itemID The ID of the item to convert to string. - * @return the nicely formatted string - */ - public static String getPrettyItemString(int itemID) { - return createPrettyEnumString(Material.getMaterial(itemID).toString()); - } - - public static String getPrettyItemString(Material material) { - return createPrettyEnumString(material.toString()); - } - - public static String getPrettyEntityTypeString(EntityType entity) { - return createPrettyEnumString(entity.toString()); - } - - private static String createPrettyEnumString(String baseString) { - String[] substrings = baseString.split("_"); - String prettyString = ""; - int size = 1; - - for (String string : substrings) { - prettyString = prettyString.concat(getCapitalized(string)); - - if (size < substrings.length) { - prettyString = prettyString.concat(" "); - } - - size++; - } - - return prettyString; - } - - /** - * Gets the int represented by this string. - * - * @param string The string to parse - * @return the int represented by this string - */ - public static int getInt(String string) { - try { - return Integer.parseInt(string); - } - catch (NumberFormatException nFE) { - return 0; - } - } - - /** - * Gets the long represented by this string. - * - * @param string The string to parse - * @return the long represented by this string - */ - public static long getLong(String string) { - try { - return Long.parseLong(string); - } - catch (NumberFormatException nFE) { - return 0; - } - } - - /** - * Determine if a string represents an Integer - * - * @param string String to check - * @return true if the string is an Integer, false otherwise - */ - public static boolean isInt(String string) { - try { - Integer.parseInt(string); - return true; - } - catch (NumberFormatException nFE) { - return false; - } - } - - /** - * Determine if a string represents a Long - * - * @param string String to check - * @return true if the string is a Long, false otherwise - */ - public static boolean isLong(String string) { - try { - Long.parseLong(string); - return true; - } - catch (NumberFormatException nFE) { - return false; - } - } - - /** - * Determine if a string represents a Double - * - * @param string String to check - * @return true if the string is a Double, false otherwise - */ - public static boolean isDouble(String string) { - try { - Double.parseDouble(string); - return true; - } - catch (NumberFormatException nFE) { - return false; - } - } - -} +package com.gmail.nossr50.util; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +public class StringUtils { + /** + * Gets a capitalized version of the target string. + * + * @param target String to capitalize + * @return the capitalized string + */ + public static String getCapitalized(String target) { + String firstLetter = target.substring(0, 1); + String remainder = target.substring(1); + String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase(); + + return capitalized; + } + + /** + * Gets a nicely formatted string version of an item name from a given item ID. + * + * @param itemID The ID of the item to convert to string. + * @return the nicely formatted string + */ + public static String getPrettyItemString(int itemID) { + return createPrettyEnumString(Material.getMaterial(itemID).toString()); + } + + public static String getPrettyItemString(Material material) { + return createPrettyEnumString(material.toString()); + } + + public static String getPrettyEntityTypeString(EntityType entity) { + return createPrettyEnumString(entity.toString()); + } + + private static String createPrettyEnumString(String baseString) { + String[] substrings = baseString.split("_"); + String prettyString = ""; + int size = 1; + + for (String string : substrings) { + prettyString = prettyString.concat(getCapitalized(string)); + + if (size < substrings.length) { + prettyString = prettyString.concat(" "); + } + + size++; + } + + return prettyString; + } + + /** + * Gets the int represented by this string. + * + * @param string The string to parse + * @return the int represented by this string + */ + public static int getInt(String string) { + try { + return Integer.parseInt(string); + } + catch (NumberFormatException nFE) { + return 0; + } + } + + /** + * Gets the long represented by this string. + * + * @param string The string to parse + * @return the long represented by this string + */ + public static long getLong(String string) { + try { + return Long.parseLong(string); + } + catch (NumberFormatException nFE) { + return 0; + } + } + + /** + * Determine if a string represents an Integer + * + * @param string String to check + * @return true if the string is an Integer, false otherwise + */ + public static boolean isInt(String string) { + try { + Integer.parseInt(string); + return true; + } + catch (NumberFormatException nFE) { + return false; + } + } + + /** + * Determine if a string represents a Long + * + * @param string String to check + * @return true if the string is a Long, false otherwise + */ + public static boolean isLong(String string) { + try { + Long.parseLong(string); + return true; + } + catch (NumberFormatException nFE) { + return false; + } + } + + /** + * Determine if a string represents a Double + * + * @param string String to check + * @return true if the string is a Double, false otherwise + */ + public static boolean isDouble(String string) { + try { + Double.parseDouble(string); + return true; + } + catch (NumberFormatException nFE) { + return false; + } + } + +} diff --git a/src/main/java/com/gmail/nossr50/util/UpdateCheck.java b/src/main/java/com/gmail/nossr50/util/UpdateChecker.java similarity index 90% rename from src/main/java/com/gmail/nossr50/util/UpdateCheck.java rename to src/main/java/com/gmail/nossr50/util/UpdateChecker.java index 9a7e75a61..ea57f3ea9 100644 --- a/src/main/java/com/gmail/nossr50/util/UpdateCheck.java +++ b/src/main/java/com/gmail/nossr50/util/UpdateChecker.java @@ -11,8 +11,8 @@ import org.json.simple.parser.ParseException; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -public class UpdateCheck { - private UpdateCheck() {} +public class UpdateChecker { + private UpdateChecker() {} public static boolean updateAvailable() throws Exception { String checkType = "release"; @@ -20,11 +20,12 @@ public class UpdateCheck { checkType = "latest"; } String version = mcMMO.p.getDescription().getVersion(); - URL url = new URL("http://api.bukget.org/api2/bukkit/plugin/mcmmo/"+checkType); + URL url = new URL("http://api.bukget.org/api2/bukkit/plugin/mcmmo/" + checkType); InputStreamReader isr; try { isr = new InputStreamReader(url.openStream()); - } catch (UnknownHostException e) { + } + catch (UnknownHostException e) { return false; } @@ -54,7 +55,8 @@ public class UpdateCheck { } } return false; - } catch (ParseException e) { + } + catch (ParseException e) { isr.close(); return false; } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java index 7a1d2b7cf..e3e3d0b2e 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java @@ -6,7 +6,7 @@ import org.bukkit.block.Block; public interface ChunkletManager { /** * Loads a specific chunklet - * + * * @param cx Chunklet X coordinate that needs to be loaded * @param cy Chunklet Y coordinate that needs to be loaded * @param cz Chunklet Z coordinate that needs to be loaded diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index c97af7c02..8b60c6f19 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -22,11 +22,17 @@ public class HashChunkletManager implements ChunkletManager { public void loadChunklet(int cx, int cy, int cz, World world) { File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); File cxDir = new File(dataDir, "" + cx); - if (!cxDir.exists()) return; + if (!cxDir.exists()) { + return; + } File czDir = new File(cxDir, "" + cz); - if (!czDir.exists()) return; + if (!czDir.exists()) { + return; + } File yFile = new File(czDir, "" + cy); - if (!yFile.exists()) return; + if (!yFile.exists()) { + return; + } ChunkletStore in = deserializeChunkletStore(yFile); if (in != null) { @@ -39,9 +45,13 @@ public class HashChunkletManager implements ChunkletManager { File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); if (store.containsKey(world.getName() + "," + cx + "," + cz + "," + cy)) { File cxDir = new File(dataDir, "" + cx); - if (!cxDir.exists()) cxDir.mkdir(); + if (!cxDir.exists()) { + cxDir.mkdir(); + } File czDir = new File(cxDir, "" + cz); - if (!czDir.exists()) czDir.mkdir(); + if (!czDir.exists()) { + czDir.mkdir(); + } File yFile = new File(czDir, "" + cy); ChunkletStore out = store.get(world.getName() + "," + cx + "," + cz + "," + cy); @@ -54,9 +64,13 @@ public class HashChunkletManager implements ChunkletManager { public void loadChunk(int cx, int cz, World world) { File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); File cxDir = new File(dataDir, "" + cx); - if (!cxDir.exists()) return; + if (!cxDir.exists()) { + return; + } File czDir = new File(cxDir, "" + cz); - if (!czDir.exists()) return; + if (!czDir.exists()) { + return; + } for (int y = 0; y < 4; y++) { File yFile = new File(czDir, "" + y); @@ -78,9 +92,13 @@ public class HashChunkletManager implements ChunkletManager { for (int y = 0; y < 4; y++) { if (store.containsKey(world.getName() + "," + cx + "," + cz + "," + y)) { File cxDir = new File(dataDir, "" + cx); - if (!cxDir.exists()) cxDir.mkdir(); + if (!cxDir.exists()) { + cxDir.mkdir(); + } File czDir = new File(cxDir, "" + cz); - if (!czDir.exists()) czDir.mkdir(); + if (!czDir.exists()) { + czDir.mkdir(); + } File yFile = new File(czDir, "" + y); ChunkletStore out = store.get(world.getName() + "," + cx + "," + cz + "," + y); @@ -104,16 +122,21 @@ public class HashChunkletManager implements ChunkletManager { public void saveWorld(World world) { String worldName = world.getName(); File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); - if (!dataDir.exists()) + if (!dataDir.exists()) { dataDir.mkdirs(); + } for (String key : store.keySet()) { String[] info = key.split(","); if (worldName.equals(info[0])) { File cxDir = new File(dataDir, "" + info[1]); - if (!cxDir.exists()) cxDir.mkdir(); + if (!cxDir.exists()) { + cxDir.mkdir(); + } File czDir = new File(cxDir, "" + info[2]); - if (!czDir.exists()) czDir.mkdir(); + if (!czDir.exists()) { + czDir.mkdir(); + } File yFile = new File(czDir, "" + info[3]); serializeChunkletStore(store.get(key), yFile); @@ -139,7 +162,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void loadWorld(World world) { //for (Chunk chunk : world.getLoadedChunks()) { - // this.chunkLoaded(chunk.getX(), chunk.getZ(), world); + // this.chunkLoaded(chunk.getX(), chunk.getZ(), world); //} } @@ -237,7 +260,7 @@ public class HashChunkletManager implements ChunkletManager { ChunkletStore cStore = store.get(key); if (cStore == null) { - return; //No need to make a store for something we will be setting to false + return; // No need to make a store for something we will be setting to false } cStore.setFalse(ix, iy, iz); @@ -256,16 +279,24 @@ public class HashChunkletManager implements ChunkletManager { File dataDir = new File(Bukkit.getWorld(info[0]).getWorldFolder(), "mcmmo_data"); File cxDir = new File(dataDir, "" + info[1]); - if (!cxDir.exists()) continue; + if (!cxDir.exists()) { + continue; + } File czDir = new File(cxDir, "" + info[2]); - if (!czDir.exists()) continue; + if (!czDir.exists()) { + continue; + } File yFile = new File(czDir, "" + info[3]); yFile.delete(); - //Delete empty directories - if (czDir.list().length == 0) czDir.delete(); - if (cxDir.list().length == 0) cxDir.delete(); + // Delete empty directories + if (czDir.list().length == 0) { + czDir.delete(); + } + if (cxDir.list().length == 0) { + cxDir.delete(); + } } } } @@ -279,8 +310,9 @@ public class HashChunkletManager implements ChunkletManager { ObjectOutputStream objOut = null; try { - if (!location.exists()) + if (!location.exists()) { location.createNewFile(); + } fileOut = new FileOutputStream(location); objOut = new ObjectOutputStream(fileOut); objOut.writeObject(cStore); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java index 64a149049..8dfe3cb8d 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java @@ -26,7 +26,9 @@ public class PrimitiveChunkletStore implements ChunkletStore { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < 64; y++) { - if (store[x][z][y]) return false; + if (store[x][z][y]) { + return false; + } } } } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStore.java index 6644fdd9a..187ad0dff 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStore.java @@ -31,7 +31,9 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < 64; y++) { - if (store[x][z][y]) return false; + if (store[x][z][y]) { + return false; + } } } } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java index 1c304d493..de2e5305b 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java @@ -9,13 +9,16 @@ import org.bukkit.entity.Entity; public interface ChunkManager { public void closeAll(); + public ChunkStore readChunkStore(World world, int x, int z) throws IOException; + public void writeChunkStore(World world, int x, int z, ChunkStore data); + public void closeChunkStore(World world, int x, int z); /** * Loads a specific chunklet - * + * * @param cx Chunklet X coordinate that needs to be loaded * @param cy Chunklet Y coordinate that needs to be loaded * @param cz Chunklet Z coordinate that needs to be loaded diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java index efb3847ed..2b4d90349 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java @@ -12,4 +12,4 @@ public class ChunkManagerFactory { return new NullChunkManager(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java index fbc331231..2956558ba 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java @@ -14,24 +14,28 @@ public interface ChunkStore extends Serializable { * @return true if the has been modified since it was last saved */ public boolean isDirty(); + /** * Checks the chunk's save state * * @param dirty the save state of the current chunk */ public void setDirty(boolean dirty); + /** * Checks the chunk's x coordinate * * @return the chunk's x coordinate. */ public int getChunkX(); + /** * Checks the chunk's z coordinate * * @return the chunk's z coordinate. */ public int getChunkZ(); + /** * Checks the value at the given coordinates * @@ -71,4 +75,4 @@ public interface ChunkStore extends Serializable { * @param otherStore Another ChunkletStore that this one should copy all data from */ public void copyFrom(ChunkletStore otherStore); -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStoreFactory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStoreFactory.java index 2ca5d5032..53528ab66 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStoreFactory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStoreFactory.java @@ -7,4 +7,4 @@ public class ChunkStoreFactory { // TODO: Add in loading from config what type of store we want. return new PrimitiveChunkStore(world, x, z); } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index 940763694..c6f2daa5f 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -16,12 +16,11 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; -import org.getspout.spoutapi.chunkstore.mcMMOSimpleRegionFile; import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory; public class HashChunkManager implements ChunkManager { - private HashMap> regionFiles = new HashMap>(); + private HashMap> regionFiles = new HashMap>(); public HashMap store = new HashMap(); public ArrayList converters = new ArrayList(); private HashMap oldData = new HashMap(); @@ -29,9 +28,9 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized void closeAll() { for (UUID uid : regionFiles.keySet()) { - HashMap worldRegions = regionFiles.get(uid); - for (Iterator worldRegionIterator = worldRegions.values().iterator(); worldRegionIterator.hasNext();) { - mcMMOSimpleRegionFile rf = worldRegionIterator.next(); + HashMap worldRegions = regionFiles.get(uid); + for (Iterator worldRegionIterator = worldRegions.values().iterator(); worldRegionIterator.hasNext();) { + McMMOSimpleRegionFile rf = worldRegionIterator.next(); if (rf != null) { rf.close(); worldRegionIterator.remove(); @@ -43,7 +42,7 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized ChunkStore readChunkStore(World world, int x, int z) throws IOException { - mcMMOSimpleRegionFile rf = getSimpleRegionFile(world, x, z); + McMMOSimpleRegionFile rf = getSimpleRegionFile(world, x, z); InputStream in = rf.getInputStream(x, z); if (in == null) { return null; @@ -56,11 +55,13 @@ public class HashChunkManager implements ChunkManager { } throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z); - } catch (IOException e) { + } + catch (IOException e) { // Assume the format changed return null; //throw new RuntimeException("Unable to process chunk meta data for " + x + ", " + z, e); - } catch (ClassNotFoundException e) { + } + catch (ClassNotFoundException e) { // Assume the format changed //System.out.println("[SpoutPlugin] is Unable to find serialized class for " + x + ", " + z + ", " + e.getMessage()); return null; @@ -77,36 +78,37 @@ public class HashChunkManager implements ChunkManager { return; } try { - mcMMOSimpleRegionFile rf = getSimpleRegionFile(world, x, z); + McMMOSimpleRegionFile rf = getSimpleRegionFile(world, x, z); ObjectOutputStream objectStream = new ObjectOutputStream(rf.getOutputStream(x, z)); objectStream.writeObject(data); objectStream.flush(); objectStream.close(); data.setDirty(false); - } catch (IOException e) { + } + catch (IOException e) { throw new RuntimeException("Unable to write chunk meta data for " + x + ", " + z, e); } } @Override public synchronized void closeChunkStore(World world, int x, int z) { - mcMMOSimpleRegionFile rf = getSimpleRegionFile(world, x, z); + McMMOSimpleRegionFile rf = getSimpleRegionFile(world, x, z); if (rf != null) { rf.close(); } } - private synchronized mcMMOSimpleRegionFile getSimpleRegionFile(World world, int x, int z) { + private synchronized McMMOSimpleRegionFile getSimpleRegionFile(World world, int x, int z) { File directory = new File(world.getWorldFolder(), "mcmmo_regions"); directory.mkdirs(); UUID key = world.getUID(); - HashMap worldRegions = regionFiles.get(key); + HashMap worldRegions = regionFiles.get(key); if (worldRegions == null) { - worldRegions = new HashMap(); + worldRegions = new HashMap(); regionFiles.put(key, worldRegions); } @@ -115,11 +117,11 @@ public class HashChunkManager implements ChunkManager { long key2 = (((long) rx) << 32) | ((rz) & 0xFFFFFFFFL); - mcMMOSimpleRegionFile regionFile = worldRegions.get(key2); + McMMOSimpleRegionFile regionFile = worldRegions.get(key2); if (regionFile == null) { File file = new File(directory, "mcmmo_" + rx + "_" + rz + "_.mcm"); - regionFile = new mcMMOSimpleRegionFile(file, rx, rz); + regionFile = new McMMOSimpleRegionFile(file, rx, rz); worldRegions.put(key2, regionFile); } @@ -138,8 +140,9 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized void loadChunk(int cx, int cz, World world, Entity[] entities) { - if (world == null || store.containsKey(world.getName() + "," + cx + "," + cz)) + if (world == null || store.containsKey(world.getName() + "," + cx + "," + cz)) { return; + } UUID key = world.getUID(); @@ -147,8 +150,9 @@ public class HashChunkManager implements ChunkManager { oldData.put(key, (new File(world.getWorldFolder(), "mcmmo_data")).exists()); } else if (oldData.get(key)) { - if (convertChunk(new File(world.getWorldFolder(), "mcmmo_data"), cx, cz, world, true)) + if (convertChunk(new File(world.getWorldFolder(), "mcmmo_data"), cx, cz, world, true)) { return; + } } ChunkStore chunkStore = null; @@ -158,8 +162,9 @@ public class HashChunkManager implements ChunkManager { } catch (Exception e) {} - if (chunkStore == null) + if (chunkStore == null) { return; + } store.put(world.getName() + "," + cx + "," + cz, chunkStore); } @@ -171,22 +176,24 @@ public class HashChunkManager implements ChunkManager { if (store.containsKey(world.getName() + "," + cx + "," + cz)) { store.remove(world.getName() + "," + cx + "," + cz); - // closeChunkStore(world, cx, cz); + //closeChunkStore(world, cx, cz); } } @Override public synchronized void saveChunk(int cx, int cz, World world) { - if (world == null) + if (world == null) { return; + } String key = world.getName() + "," + cx + "," + cz; if (store.containsKey(key)) { ChunkStore out = store.get(world.getName() + "," + cx + "," + cz); - if (!out.isDirty()) + if (!out.isDirty()) { return; + } writeChunkStore(world, cx, cz, out); } @@ -194,8 +201,9 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized boolean isChunkLoaded(int cx, int cz, World world) { - if (world == null) + if (world == null) { return false; + } return store.containsKey(world.getName() + "," + cx + "," + cz); } @@ -205,16 +213,18 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized void chunkUnloaded(int cx, int cz, World world) { - if (world == null) + if (world == null) { return; + } unloadChunk(cx, cz, world); } @Override public synchronized void saveWorld(World world) { - if (world == null) + if (world == null) { return; + } closeAll(); String worldName = world.getName(); @@ -230,7 +240,7 @@ public class HashChunkManager implements ChunkManager { cx = Integer.parseInt(info[1]); cz = Integer.parseInt(info[2]); } - catch(Exception e) { + catch (Exception e) { continue; } saveChunk(cx, cz, world); @@ -240,8 +250,9 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized void unloadWorld(World world) { - if (world == null) + if (world == null) { return; + } closeAll(); String worldName = world.getName(); @@ -257,7 +268,7 @@ public class HashChunkManager implements ChunkManager { cx = Integer.parseInt(info[1]); cz = Integer.parseInt(info[2]); } - catch(Exception e) { + catch (Exception e) { continue; } unloadChunk(cx, cz, world); @@ -288,8 +299,9 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized boolean isTrue(int x, int y, int z, World world) { - if (world == null) + if (world == null) { return false; + } int cx = x / 16; int cz = z / 16; @@ -312,8 +324,9 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized boolean isTrue(Block block) { - if (block == null) + if (block == null) { return false; + } return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld()); } @@ -329,8 +342,9 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized void setTrue(int x, int y, int z, World world) { - if (world == null) + if (world == null) { return; + } int cx = x / 16; int cz = z / 16; @@ -356,24 +370,27 @@ public class HashChunkManager implements ChunkManager { @Override public synchronized void setTrue(Block block) { - if (block == null) + if (block == null) { return; + } setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld()); } @Override public void setTrue(BlockState blockState) { - if (blockState == null) + if (blockState == null) { return; + } setTrue(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld()); } @Override public synchronized void setFalse(int x, int y, int z, World world) { - if (world == null) + if (world == null) { return; + } int cx = x / 16; int cz = z / 16; @@ -390,7 +407,7 @@ public class HashChunkManager implements ChunkManager { ChunkStore cStore = store.get(key); if (cStore == null) { - return; //No need to make a store for something we will be setting to false + return; // No need to make a store for something we will be setting to false } cStore.setFalse(ix, y, iz); @@ -422,22 +439,30 @@ public class HashChunkManager implements ChunkManager { } public synchronized boolean convertChunk(File dataDir, int cx, int cz, World world, boolean actually) { - if (!actually) + if (!actually || !dataDir.exists()) { return false; - if (!dataDir.exists()) return false; + } + File cxDir = new File(dataDir, "" + cx); - if (!cxDir.exists()) return false; + if (!cxDir.exists()) { + return false; + } + File czDir = new File(cxDir, "" + cz); - if (!czDir.exists()) return false; + if (!czDir.exists()) { + return false; + } boolean conversionSet = false; for (BlockStoreConversionZDirectory converter : this.converters) { - if (converter == null) + if (converter == null) { continue; + } - if (converter.taskID >= 0) + if (converter.taskID >= 0) { continue; + } converter.start(world, cxDir, czDir); conversionSet = true; diff --git a/src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleChunkBuffer.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleChunkBuffer.java old mode 100755 new mode 100644 similarity index 83% rename from src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleChunkBuffer.java rename to src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleChunkBuffer.java index bb0657a3f..c2f158b95 --- a/src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleChunkBuffer.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleChunkBuffer.java @@ -17,16 +17,16 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ -package org.getspout.spoutapi.chunkstore; +package com.gmail.nossr50.util.blockmeta.chunkmeta; import java.io.ByteArrayOutputStream; import java.io.IOException; -public class mcMMOSimpleChunkBuffer extends ByteArrayOutputStream { - final mcMMOSimpleRegionFile rf; +public class McMMOSimpleChunkBuffer extends ByteArrayOutputStream { + final McMMOSimpleRegionFile rf; final int index; - mcMMOSimpleChunkBuffer(mcMMOSimpleRegionFile rf, int index) { + McMMOSimpleChunkBuffer(McMMOSimpleRegionFile rf, int index) { super(1024); this.rf = rf; this.index = index; @@ -36,4 +36,4 @@ public class mcMMOSimpleChunkBuffer extends ByteArrayOutputStream { public void close() throws IOException { rf.write(index, buf, count); } -} \ No newline at end of file +} diff --git a/src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleRegionFile.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java old mode 100755 new mode 100644 similarity index 93% rename from src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleRegionFile.java rename to src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java index bbfb30261..b960af433 --- a/src/main/java/org/getspout/spoutapi/chunkstore/mcMMOSimpleRegionFile.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java @@ -17,7 +17,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ -package org.getspout.spoutapi.chunkstore; +package com.gmail.nossr50.util.blockmeta.chunkmeta; import java.io.ByteArrayInputStream; import java.io.DataInputStream; @@ -29,7 +29,7 @@ import java.util.ArrayList; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; -public class mcMMOSimpleRegionFile { +public class McMMOSimpleRegionFile { private RandomAccessFile file; private final int[] dataStart = new int[1024]; private final int[] dataActualLength = new int[1024]; @@ -46,11 +46,11 @@ public class mcMMOSimpleRegionFile { @SuppressWarnings("unused") private static long TIMEOUT_TIME = 300000; // 5 min - public mcMMOSimpleRegionFile(File f, int rx, int rz) { + public McMMOSimpleRegionFile(File f, int rx, int rz) { this(f, rx, rz, 10); } - public mcMMOSimpleRegionFile(File f, int rx, int rz, int defaultSegmentSize) { + public McMMOSimpleRegionFile(File f, int rx, int rz, int defaultSegmentSize) { this.rx = rx; this.rz = rz; this.defaultSegmentSize = defaultSegmentSize; @@ -96,7 +96,8 @@ public class mcMMOSimpleRegionFile { } extendFile(); - } catch (IOException fnfe) { + } + catch (IOException fnfe) { throw new RuntimeException(fnfe); } } @@ -143,7 +144,8 @@ public class mcMMOSimpleRegionFile { } extendFile(); - } catch (IOException fnfe) { + } + catch (IOException fnfe) { throw new RuntimeException(fnfe); } } @@ -151,24 +153,28 @@ public class mcMMOSimpleRegionFile { } public synchronized boolean testCloseTimeout() { - /*if (System.currentTimeMillis() - TIMEOUT_TIME > lastAccessTime) { - close(); - return true; - }*/ + /* + if (System.currentTimeMillis() - TIMEOUT_TIME > lastAccessTime) { + close(); + return true; + } + */ return false; } public synchronized DataOutputStream getOutputStream(int x, int z) { int index = getChunkIndex(x, z); - return new DataOutputStream(new DeflaterOutputStream(new mcMMOSimpleChunkBuffer(this, index))); + return new DataOutputStream(new DeflaterOutputStream(new McMMOSimpleChunkBuffer(this, index))); } public synchronized DataInputStream getInputStream(int x, int z) throws IOException { int index = getChunkIndex(x, z); int actualLength = dataActualLength[index]; + if (actualLength == 0) { return null; } + byte[] data = new byte[actualLength]; getFile().seek(dataStart[index] << segmentSize); @@ -194,8 +200,10 @@ public class mcMMOSimpleRegionFile { file.seek(4096 * 2); file.close(); } + file = null; - } catch (IOException ioe) { + } + catch (IOException ioe) { throw new RuntimeException("Unable to close file", ioe); } } @@ -212,6 +220,7 @@ public class mcMMOSimpleRegionFile { while (i > inuse.size() - 1) { inuse.add(false); } + Boolean old = inuse.set(i, used); if (old != null && old == used) { if (old) { @@ -257,9 +266,11 @@ public class mcMMOSimpleRegionFile { if (inuse.get(end)) { end++; start = end; - } else { + } + else { end++; } + if (end - start >= segments) { return start; } @@ -297,4 +308,4 @@ public class mcMMOSimpleRegionFile { getFile().writeInt(dataActualLength[i]); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/NullChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/NullChunkManager.java index 0862f61e0..e68ace750 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/NullChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/NullChunkManager.java @@ -99,4 +99,4 @@ public class NullChunkManager implements ChunkManager { @Override public void cleanUp() {} -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/PrimitiveChunkStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/PrimitiveChunkStore.java index ec6dd588b..6e47c4924 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/PrimitiveChunkStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/PrimitiveChunkStore.java @@ -72,7 +72,9 @@ public class PrimitiveChunkStore implements ChunkStore { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < this.worldHeight; y++) { - if (store[x][z][y]) return false; + if (store[x][z][y]) { + return false; + } } } } @@ -108,7 +110,7 @@ public class PrimitiveChunkStore implements ChunkStore { int magic = in.readInt(); // Can be used to determine the format of the file int fileVersionNumber = in.readInt(); - + if (magic != MAGIC_NUMBER) { fileVersionNumber = 0; } @@ -141,9 +143,9 @@ public class PrimitiveChunkStore implements ChunkStore { try { store[x][z][y] = temp[x][y][z]; } - catch(Exception e) {} + catch (Exception e) {} } } } } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java index 77a298e49..e1ddd4b2f 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java @@ -24,8 +24,9 @@ public class BlockStoreConversionMain implements Runnable { } public void start() { - if (this.taskID >= 0) + if (this.taskID >= 0) { return; + } this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); return; diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java index 061724f1b..89465df4d 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java @@ -79,4 +79,4 @@ public class BlockStoreConversionXDirectory implements Runnable { this.scheduler = null; this.converters = null; } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java index 91f018246..5b183b6dc 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java @@ -5,12 +5,12 @@ import java.io.File; import org.bukkit.scheduler.BukkitScheduler; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.blockmeta.chunkmeta.HashChunkManager; -import com.gmail.nossr50.util.blockmeta.chunkmeta.PrimitiveChunkStore; import com.gmail.nossr50.util.blockmeta.ChunkletStore; import com.gmail.nossr50.util.blockmeta.HashChunkletManager; import com.gmail.nossr50.util.blockmeta.PrimitiveChunkletStore; import com.gmail.nossr50.util.blockmeta.PrimitiveExChunkletStore; +import com.gmail.nossr50.util.blockmeta.chunkmeta.HashChunkManager; +import com.gmail.nossr50.util.blockmeta.chunkmeta.PrimitiveChunkStore; public class BlockStoreConversionZDirectory implements Runnable { public int taskID, cx, cz, x, y, z, y2, xPos, zPos, cxPos, czPos; @@ -74,7 +74,7 @@ public class BlockStoreConversionZDirectory implements Runnable { this.cx = Integer.parseInt(this.cxs); this.cz = Integer.parseInt(this.czs); } - catch(Exception e) { + catch (Exception e) { this.dataDir.delete(); stop(); return; @@ -117,7 +117,7 @@ public class BlockStoreConversionZDirectory implements Runnable { this.newManager.setTrue(this.cxPos, this.y2, this.czPos, this.world); } - catch(Exception e) {} + catch (Exception e) {} } } } @@ -171,8 +171,9 @@ public class BlockStoreConversionZDirectory implements Runnable { } public void stop() { - if (this.taskID < 0) + if (this.taskID < 0) { return; + } this.scheduler.cancelTask(taskID); this.taskID = -1; @@ -189,4 +190,4 @@ public class BlockStoreConversionZDirectory implements Runnable { this.primitiveExChunklet = null; this.currentChunk = null; } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java similarity index 80% rename from src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java rename to src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java index 7664f3667..080c44ab1 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -1,368 +1,369 @@ -package com.gmail.nossr50.commands; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.command.PluginCommand; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.chat.commands.AdminChatCommand; -import com.gmail.nossr50.chat.commands.PartyChatCommand; -import com.gmail.nossr50.commands.admin.AddlevelsCommand; -import com.gmail.nossr50.commands.admin.AddxpCommand; -import com.gmail.nossr50.commands.admin.HardcoreCommand; -import com.gmail.nossr50.commands.admin.McgodCommand; -import com.gmail.nossr50.commands.admin.McrefreshCommand; -import com.gmail.nossr50.commands.admin.MmoeditCommand; -import com.gmail.nossr50.commands.admin.SkillresetCommand; -import com.gmail.nossr50.commands.admin.VampirismCommand; -import com.gmail.nossr50.commands.admin.XprateCommand; -import com.gmail.nossr50.commands.player.InspectCommand; -import com.gmail.nossr50.commands.player.McabilityCommand; -import com.gmail.nossr50.commands.player.McmmoCommand; -import com.gmail.nossr50.commands.player.McnotifyCommand; -import com.gmail.nossr50.commands.player.McrankCommand; -import com.gmail.nossr50.commands.player.McstatsCommand; -import com.gmail.nossr50.commands.player.MctopCommand; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.database.commands.McpurgeCommand; -import com.gmail.nossr50.database.commands.McremoveCommand; -import com.gmail.nossr50.database.commands.MmoupdateCommand; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.commands.PartyCommand; -import com.gmail.nossr50.party.commands.PtpCommand; -import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand; -import com.gmail.nossr50.skills.archery.ArcheryCommand; -import com.gmail.nossr50.skills.axes.AxesCommand; -import com.gmail.nossr50.skills.excavation.ExcavationCommand; -import com.gmail.nossr50.skills.fishing.FishingCommand; -import com.gmail.nossr50.skills.herbalism.HerbalismCommand; -import com.gmail.nossr50.skills.mining.MiningCommand; -import com.gmail.nossr50.skills.repair.RepairCommand; -import com.gmail.nossr50.skills.smelting.SmeltingCommand; -import com.gmail.nossr50.skills.swords.SwordsCommand; -import com.gmail.nossr50.skills.taming.TamingCommand; -import com.gmail.nossr50.skills.unarmed.UnarmedCommand; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.skills.woodcutting.WoodcuttingCommand; -import com.gmail.nossr50.spout.commands.MchudCommand; -import com.gmail.nossr50.spout.commands.XplockCommand; -import com.gmail.nossr50.util.StringUtils; - -public final class CommandRegistrationHelper { - private CommandRegistrationHelper() {}; - private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission"); - - public static void registerSkillCommands() { - for (SkillType skill : SkillType.values()) { - String commandName = skill.toString().toLowerCase(); - String localizedName = SkillTools.getSkillName(skill); - - PluginCommand command; - - command = mcMMO.p.getCommand(commandName); - command.setDescription(LocaleLoader.getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName))); - command.setPermission("mcmmo.commands." + commandName); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", localizedName)); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.2", localizedName, "?", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]")); - - switch (skill) { - case ACROBATICS: - command.setExecutor(new AcrobaticsCommand()); - break; - - case ARCHERY: - command.setExecutor(new ArcheryCommand()); - break; - - case AXES: - command.setExecutor(new AxesCommand()); - break; - - case EXCAVATION: - command.setExecutor(new ExcavationCommand()); - break; - - case FISHING: - command.setExecutor(new FishingCommand()); - break; - - case HERBALISM: - command.setExecutor(new HerbalismCommand()); - break; - - case MINING: - command.setExecutor(new MiningCommand()); - break; - - case REPAIR: - command.setExecutor(new RepairCommand()); - break; - - case SMELTING: - command.setExecutor(new SmeltingCommand()); - break; - - case SWORDS: - command.setExecutor(new SwordsCommand()); - break; - - case TAMING: - command.setExecutor(new TamingCommand()); - break; - - case UNARMED: - command.setExecutor(new UnarmedCommand()); - break; - - case WOODCUTTING: - command.setExecutor(new WoodcuttingCommand()); - break; - - default: - break; - } - } - } - - public static void registerAddlevelsCommand() { - PluginCommand command = mcMMO.p.getCommand("addlevels"); - command.setDescription(LocaleLoader.getString("Commands.Description.addlevels")); - command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">")); - command.setExecutor(new AddlevelsCommand()); - } - - public static void registerAddxpCommand() { - PluginCommand command = mcMMO.p.getCommand("addxp"); - command.setDescription(LocaleLoader.getString("Commands.Description.addxp")); - command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">")); - command.setExecutor(new AddxpCommand()); - } - - public static void registerMcgodCommand() { - PluginCommand command = mcMMO.p.getCommand("mcgod"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcgod")); - command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcgod", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); - command.setExecutor(new McgodCommand()); - } - - public static void registerMcrefreshCommand() { - PluginCommand command = mcMMO.p.getCommand("mcrefresh"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh")); - command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); - command.setExecutor(new McrefreshCommand()); - } - - public static void registerMmoeditCommand() { - PluginCommand command = mcMMO.p.getCommand("mmoedit"); - command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit")); - command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.3", "mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">")); - command.setExecutor(new MmoeditCommand()); - } - - public static void registerSkillresetCommand() { - PluginCommand command = mcMMO.p.getCommand("skillreset"); - command.setDescription(LocaleLoader.getString("Commands.Description.skillreset")); - command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.2", "skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">")); - command.setExecutor(new SkillresetCommand()); - } - - public static void registerXprateCommand() { - List aliasList = new ArrayList(); - aliasList.add("mcxprate"); - - PluginCommand command = mcMMO.p.getCommand("xprate"); - command.setDescription(LocaleLoader.getString("Commands.Description.xprate")); - command.setPermission("mcmmo.commands.xprate;mcmmo.commands.xprate.reset;mcmmo.commands.xprate.set"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.2", "xprate", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">", "")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xprate", "reset")); - command.setAliases(aliasList); - command.setExecutor(new XprateCommand()); - } - - public static void registerInspectCommand() { - PluginCommand command = mcMMO.p.getCommand("inspect"); - command.setDescription(LocaleLoader.getString("Commands.Description.inspect")); - command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "inspect", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); - command.setExecutor(new InspectCommand()); - } - - public static void registerMcabilityCommand() { - PluginCommand command = mcMMO.p.getCommand("mcability"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcability")); - command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcability", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); - command.setExecutor(new McabilityCommand()); - } - - public static void registerMcmmoCommand() { - PluginCommand command = mcMMO.p.getCommand("mcmmo"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo")); - command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmo")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "help")); - command.setExecutor(new McmmoCommand()); - } - - public static void registerMcrankCommand() { - PluginCommand command = mcMMO.p.getCommand("mcrank"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcrank")); - command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrank", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); - command.setExecutor(new McrankCommand()); - } - - public static void registerMcstatsCommand() { - PluginCommand command = mcMMO.p.getCommand("mcstats"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcstats")); - command.setPermission("mcmmo.commands.mcstats"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcstats")); - command.setExecutor(new McstatsCommand()); - } - - public static void registerMctopCommand() { - PluginCommand command = mcMMO.p.getCommand("mctop"); - command.setDescription(LocaleLoader.getString("Commands.Description.mctop")); - command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.2", "mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]")); - command.setExecutor(new MctopCommand()); - } - - public static void registerMcpurgeCommand() { - PluginCommand command = mcMMO.p.getCommand("mcpurge"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff())); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge")); - command.setExecutor(new McpurgeCommand()); - } - - public static void registerMcremoveCommand() { - PluginCommand command = mcMMO.p.getCommand("mcremove"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcremove")); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); - command.setExecutor(new McremoveCommand()); - } - - public static void registerMmoupdateCommand() { - PluginCommand command = mcMMO.p.getCommand("mmoupdate"); - command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate")); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate")); - command.setExecutor(new MmoupdateCommand()); - } - - public static void registerAdminChatCommand() { - PluginCommand command = mcMMO.p.getCommand("adminchat"); - command.setDescription(LocaleLoader.getString("Commands.Description.adminchat")); - command.setPermission("mcmmo.chat.adminchat"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "adminchat")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">")); - command.setExecutor(new AdminChatCommand()); - } - - public static void registerPartyChatCommand() { - PluginCommand command = mcMMO.p.getCommand("partychat"); - command.setDescription(LocaleLoader.getString("Commands.Description.partychat")); - command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "partychat")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">")); - command.setExecutor(new PartyChatCommand()); - } - - public static void registerMchudCommand() { - PluginCommand command = mcMMO.p.getCommand("mchud"); - command.setDescription(LocaleLoader.getString("Commands.Description.mchud")); - command.setPermission("mcmmo.commands.mchud"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mchud", "")); - command.setExecutor(new MchudCommand()); - } - - public static void registerXplockCommand() { - PluginCommand command = mcMMO.p.getCommand("xplock"); - command.setDescription(LocaleLoader.getString("Commands.Description.xplock")); - command.setPermission("mcmmo.commands.xplock"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "xplock")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xplock", "")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xplock", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">")); - command.setExecutor(new XplockCommand()); - } - - public static void registerPartyCommand() { - PluginCommand command = mcMMO.p.getCommand("party"); - command.setDescription(LocaleLoader.getString("Commands.Description.party")); - command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" + - "mcmmo.commands.party.expshare;mcmmo.commands.party.invite;mcmmo.commands.party.itemshare;mcmmo.commands.party.join;" + - "mcmmo.commands.party.kick;mcmmo.commands.party.lock;mcmmo.commands.party.owner;mcmmo.commands.party.password;" + - "mcmmo.commands.party.quit;mcmmo.commands.party.rename;mcmmo.commands.party.unlock"); - command.setPermissionMessage(permissionsMessage); - command.setExecutor(new PartyCommand()); - } - - public static void registerPtpCommand() { - PluginCommand command = mcMMO.p.getCommand("ptp"); - command.setDescription(LocaleLoader.getString("Commands.Description.ptp")); - command.setPermission("mcmmo.commands.ptp;mcmmo.commands.ptp.accept;mcmmo.commands.ptp.acceptall;mcmmo.commands.ptp.toggle"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "ptp", "")); - command.setExecutor(new PtpCommand()); - } - - public static void registerHardcoreCommand() { - PluginCommand command = mcMMO.p.getCommand("hardcore"); - command.setDescription(LocaleLoader.getString("Commands.Description.hardcore")); - command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "hardcore", "[on|off]")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "hardcore", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">")); - command.setExecutor(new HardcoreCommand()); - } - - public static void registerVampirismCommand() { - PluginCommand command = mcMMO.p.getCommand("vampirism"); - command.setDescription(LocaleLoader.getString("Commands.Description.vampirism")); - command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "vampirism", "[on|off]")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">")); - command.setExecutor(new VampirismCommand()); - } - - public static void registerMcnotifyCommand() { - PluginCommand command = mcMMO.p.getCommand("mcnotify"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify")); - command.setPermission("mcmmo.commands.mcnotify"); - command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcnotify")); - command.setExecutor(new McnotifyCommand()); - } -} +package com.gmail.nossr50.util.commands; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.command.PluginCommand; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.commands.McabilityCommand; +import com.gmail.nossr50.commands.McgodCommand; +import com.gmail.nossr50.commands.McmmoCommand; +import com.gmail.nossr50.commands.McnotifyCommand; +import com.gmail.nossr50.commands.McrefreshCommand; +import com.gmail.nossr50.commands.XprateCommand; +import com.gmail.nossr50.commands.chat.AdminChatCommand; +import com.gmail.nossr50.commands.chat.PartyChatCommand; +import com.gmail.nossr50.commands.database.McpurgeCommand; +import com.gmail.nossr50.commands.database.McremoveCommand; +import com.gmail.nossr50.commands.database.MmoupdateCommand; +import com.gmail.nossr50.commands.experience.AddlevelsCommand; +import com.gmail.nossr50.commands.experience.AddxpCommand; +import com.gmail.nossr50.commands.experience.MmoeditCommand; +import com.gmail.nossr50.commands.experience.SkillresetCommand; +import com.gmail.nossr50.commands.hardcore.HardcoreCommand; +import com.gmail.nossr50.commands.hardcore.VampirismCommand; +import com.gmail.nossr50.commands.party.PartyCommand; +import com.gmail.nossr50.commands.party.PtpCommand; +import com.gmail.nossr50.commands.player.InspectCommand; +import com.gmail.nossr50.commands.player.McrankCommand; +import com.gmail.nossr50.commands.player.McstatsCommand; +import com.gmail.nossr50.commands.player.MctopCommand; +import com.gmail.nossr50.commands.skills.AcrobaticsCommand; +import com.gmail.nossr50.commands.skills.ArcheryCommand; +import com.gmail.nossr50.commands.skills.AxesCommand; +import com.gmail.nossr50.commands.skills.ExcavationCommand; +import com.gmail.nossr50.commands.skills.FishingCommand; +import com.gmail.nossr50.commands.skills.HerbalismCommand; +import com.gmail.nossr50.commands.skills.MiningCommand; +import com.gmail.nossr50.commands.skills.RepairCommand; +import com.gmail.nossr50.commands.skills.SmeltingCommand; +import com.gmail.nossr50.commands.skills.SwordsCommand; +import com.gmail.nossr50.commands.skills.TamingCommand; +import com.gmail.nossr50.commands.skills.UnarmedCommand; +import com.gmail.nossr50.commands.skills.WoodcuttingCommand; +import com.gmail.nossr50.commands.spout.MchudCommand; +import com.gmail.nossr50.commands.spout.XplockCommand; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public final class CommandRegistrationManager { + private CommandRegistrationManager() {}; + + private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission"); + + public static void registerSkillCommands() { + for (SkillType skill : SkillType.values()) { + String commandName = skill.toString().toLowerCase(); + String localizedName = SkillUtils.getSkillName(skill); + + PluginCommand command; + + command = mcMMO.p.getCommand(commandName); + command.setDescription(LocaleLoader.getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName))); + command.setPermission("mcmmo.commands." + commandName); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", localizedName)); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.2", localizedName, "?", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]")); + + switch (skill) { + case ACROBATICS: + command.setExecutor(new AcrobaticsCommand()); + break; + + case ARCHERY: + command.setExecutor(new ArcheryCommand()); + break; + + case AXES: + command.setExecutor(new AxesCommand()); + break; + + case EXCAVATION: + command.setExecutor(new ExcavationCommand()); + break; + + case FISHING: + command.setExecutor(new FishingCommand()); + break; + + case HERBALISM: + command.setExecutor(new HerbalismCommand()); + break; + + case MINING: + command.setExecutor(new MiningCommand()); + break; + + case REPAIR: + command.setExecutor(new RepairCommand()); + break; + + case SMELTING: + command.setExecutor(new SmeltingCommand()); + break; + + case SWORDS: + command.setExecutor(new SwordsCommand()); + break; + + case TAMING: + command.setExecutor(new TamingCommand()); + break; + + case UNARMED: + command.setExecutor(new UnarmedCommand()); + break; + + case WOODCUTTING: + command.setExecutor(new WoodcuttingCommand()); + break; + + default: + break; + } + } + } + + public static void registerAddlevelsCommand() { + PluginCommand command = mcMMO.p.getCommand("addlevels"); + command.setDescription(LocaleLoader.getString("Commands.Description.addlevels")); + command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">")); + command.setExecutor(new AddlevelsCommand()); + } + + public static void registerAddxpCommand() { + PluginCommand command = mcMMO.p.getCommand("addxp"); + command.setDescription(LocaleLoader.getString("Commands.Description.addxp")); + command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">")); + command.setExecutor(new AddxpCommand()); + } + + public static void registerMcgodCommand() { + PluginCommand command = mcMMO.p.getCommand("mcgod"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcgod")); + command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcgod", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + command.setExecutor(new McgodCommand()); + } + + public static void registerMcrefreshCommand() { + PluginCommand command = mcMMO.p.getCommand("mcrefresh"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh")); + command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + command.setExecutor(new McrefreshCommand()); + } + + public static void registerMmoeditCommand() { + PluginCommand command = mcMMO.p.getCommand("mmoedit"); + command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit")); + command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.3", "mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">")); + command.setExecutor(new MmoeditCommand()); + } + + public static void registerSkillresetCommand() { + PluginCommand command = mcMMO.p.getCommand("skillreset"); + command.setDescription(LocaleLoader.getString("Commands.Description.skillreset")); + command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.2", "skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">")); + command.setExecutor(new SkillresetCommand()); + } + + public static void registerXprateCommand() { + List aliasList = new ArrayList(); + aliasList.add("mcxprate"); + + PluginCommand command = mcMMO.p.getCommand("xprate"); + command.setDescription(LocaleLoader.getString("Commands.Description.xprate")); + command.setPermission("mcmmo.commands.xprate;mcmmo.commands.xprate.reset;mcmmo.commands.xprate.set"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.2", "xprate", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">", "")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xprate", "reset")); + command.setAliases(aliasList); + command.setExecutor(new XprateCommand()); + } + + public static void registerInspectCommand() { + PluginCommand command = mcMMO.p.getCommand("inspect"); + command.setDescription(LocaleLoader.getString("Commands.Description.inspect")); + command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "inspect", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + command.setExecutor(new InspectCommand()); + } + + public static void registerMcabilityCommand() { + PluginCommand command = mcMMO.p.getCommand("mcability"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcability")); + command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcability", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + command.setExecutor(new McabilityCommand()); + } + + public static void registerMcmmoCommand() { + PluginCommand command = mcMMO.p.getCommand("mcmmo"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo")); + command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmo")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "help")); + command.setExecutor(new McmmoCommand()); + } + + public static void registerMcrankCommand() { + PluginCommand command = mcMMO.p.getCommand("mcrank"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcrank")); + command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrank", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + command.setExecutor(new McrankCommand()); + } + + public static void registerMcstatsCommand() { + PluginCommand command = mcMMO.p.getCommand("mcstats"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcstats")); + command.setPermission("mcmmo.commands.mcstats"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcstats")); + command.setExecutor(new McstatsCommand()); + } + + public static void registerMctopCommand() { + PluginCommand command = mcMMO.p.getCommand("mctop"); + command.setDescription(LocaleLoader.getString("Commands.Description.mctop")); + command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.2", "mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]")); + command.setExecutor(new MctopCommand()); + } + + public static void registerMcpurgeCommand() { + PluginCommand command = mcMMO.p.getCommand("mcpurge"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff())); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge")); + command.setExecutor(new McpurgeCommand()); + } + + public static void registerMcremoveCommand() { + PluginCommand command = mcMMO.p.getCommand("mcremove"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcremove")); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + command.setExecutor(new McremoveCommand()); + } + + public static void registerMmoupdateCommand() { + PluginCommand command = mcMMO.p.getCommand("mmoupdate"); + command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate")); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate")); + command.setExecutor(new MmoupdateCommand()); + } + + public static void registerAdminChatCommand() { + PluginCommand command = mcMMO.p.getCommand("adminchat"); + command.setDescription(LocaleLoader.getString("Commands.Description.adminchat")); + command.setPermission("mcmmo.chat.adminchat"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "adminchat")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">")); + command.setExecutor(new AdminChatCommand()); + } + + public static void registerPartyChatCommand() { + PluginCommand command = mcMMO.p.getCommand("partychat"); + command.setDescription(LocaleLoader.getString("Commands.Description.partychat")); + command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "partychat")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">")); + command.setExecutor(new PartyChatCommand()); + } + + public static void registerMchudCommand() { + PluginCommand command = mcMMO.p.getCommand("mchud"); + command.setDescription(LocaleLoader.getString("Commands.Description.mchud")); + command.setPermission("mcmmo.commands.mchud"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mchud", "")); + command.setExecutor(new MchudCommand()); + } + + public static void registerXplockCommand() { + PluginCommand command = mcMMO.p.getCommand("xplock"); + command.setDescription(LocaleLoader.getString("Commands.Description.xplock")); + command.setPermission("mcmmo.commands.xplock"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "xplock")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xplock", "")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xplock", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">")); + command.setExecutor(new XplockCommand()); + } + + public static void registerPartyCommand() { + PluginCommand command = mcMMO.p.getCommand("party"); + command.setDescription(LocaleLoader.getString("Commands.Description.party")); + command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" + + "mcmmo.commands.party.expshare;mcmmo.commands.party.invite;mcmmo.commands.party.itemshare;mcmmo.commands.party.join;" + + "mcmmo.commands.party.kick;mcmmo.commands.party.lock;mcmmo.commands.party.owner;mcmmo.commands.party.password;" + + "mcmmo.commands.party.quit;mcmmo.commands.party.rename;mcmmo.commands.party.unlock"); + command.setPermissionMessage(permissionsMessage); + command.setExecutor(new PartyCommand()); + } + + public static void registerPtpCommand() { + PluginCommand command = mcMMO.p.getCommand("ptp"); + command.setDescription(LocaleLoader.getString("Commands.Description.ptp")); + command.setPermission("mcmmo.commands.ptp;mcmmo.commands.ptp.accept;mcmmo.commands.ptp.acceptall;mcmmo.commands.ptp.toggle"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "ptp", "")); + command.setExecutor(new PtpCommand()); + } + + public static void registerHardcoreCommand() { + PluginCommand command = mcMMO.p.getCommand("hardcore"); + command.setDescription(LocaleLoader.getString("Commands.Description.hardcore")); + command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "hardcore", "[on|off]")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "hardcore", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">")); + command.setExecutor(new HardcoreCommand()); + } + + public static void registerVampirismCommand() { + PluginCommand command = mcMMO.p.getCommand("vampirism"); + command.setDescription(LocaleLoader.getString("Commands.Description.vampirism")); + command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "vampirism", "[on|off]")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">")); + command.setExecutor(new VampirismCommand()); + } + + public static void registerMcnotifyCommand() { + PluginCommand command = mcMMO.p.getCommand("mcnotify"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify")); + command.setPermission("mcmmo.commands.mcnotify"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcnotify")); + command.setExecutor(new McnotifyCommand()); + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/CommandHelper.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java similarity index 92% rename from src/main/java/com/gmail/nossr50/commands/CommandHelper.java rename to src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index 25edb68f2..e4f06887a 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandHelper.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -1,122 +1,122 @@ -package com.gmail.nossr50.commands; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Permissions; - -public final class CommandHelper { - private CommandHelper() {} - - public static boolean noConsoleUsage(CommandSender sender) { - if (!(sender instanceof Player)) { - sender.sendMessage(LocaleLoader.getString("Commands.NoConsole")); - return true; - } - - return false; - } - - /** - * Print out details on Gathering skills. Only for online players. - * - * @param inspect The player to retrieve stats for - * @param profile The player's profile - * @param display The sender to display stats to - */ - public static void printGatheringSkills(Player inspect, PlayerProfile profile, CommandSender display) { - if (SkillTools.hasGatheringSkills(inspect)) { - display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); - - if (Permissions.skillEnabled(inspect, SkillType.EXCAVATION)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION))); - } - - if (Permissions.skillEnabled(inspect, SkillType.FISHING)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING))); - } - - if (Permissions.skillEnabled(inspect, SkillType.HERBALISM)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM))); - } - - if (Permissions.skillEnabled(inspect, SkillType.MINING)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING))); - } - - if (Permissions.skillEnabled(inspect, SkillType.WOODCUTTING)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING))); - } - } - } - - public static void printGatheringSkills(Player player, PlayerProfile profile) { - printGatheringSkills(player, profile, player); - } - - /** - * Print out details on Combat skills. Only for online players. - * - * @param inspect The player to retrieve stats for - * @param profile The player's profile - * @param display The sender to display stats to - */ - public static void printCombatSkills(Player inspect, PlayerProfile profile, CommandSender display) { - if (SkillTools.hasCombatSkills(inspect)) { - display.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); - - if (Permissions.skillEnabled(inspect, SkillType.AXES)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES))); - } - - if (Permissions.skillEnabled(inspect, SkillType.ARCHERY)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY))); - } - - if (Permissions.skillEnabled(inspect, SkillType.SWORDS)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS))); - } - - if (Permissions.skillEnabled(inspect, SkillType.TAMING)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING))); - } - - if (Permissions.skillEnabled(inspect, SkillType.UNARMED)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED))); - } - } - } - - public static void printCombatSkills(Player player, PlayerProfile profile) { - printCombatSkills(player, profile, player); - } - - /** - * Print out details on Misc skills. Only for online players. - * - * @param inspect The player to retrieve stats for - * @param profile The player's profile - * @param display The sender to display stats to - */ - public static void printMiscSkills(Player inspect, PlayerProfile profile, CommandSender display) { - if (SkillTools.hasMiscSkills(inspect)) { - display.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); - - if (Permissions.skillEnabled(inspect, SkillType.ACROBATICS)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS))); - } - - if (Permissions.skillEnabled(inspect, SkillType.REPAIR)) { - display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR))); - } - } - } - - public static void printMiscSkills(Player player, PlayerProfile profile) { - printMiscSkills(player, profile, player); - } -} +package com.gmail.nossr50.util.commands; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.SkillUtils; + +public final class CommandUtils { + private CommandUtils() {} + + public static boolean noConsoleUsage(CommandSender sender) { + if (!(sender instanceof Player)) { + sender.sendMessage(LocaleLoader.getString("Commands.NoConsole")); + return true; + } + + return false; + } + + /** + * Print out details on Gathering skills. Only for online players. + * + * @param inspect The player to retrieve stats for + * @param profile The player's profile + * @param display The sender to display stats to + */ + public static void printGatheringSkills(Player inspect, PlayerProfile profile, CommandSender display) { + if (SkillUtils.hasGatheringSkills(inspect)) { + display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); + + if (Permissions.skillEnabled(inspect, SkillType.EXCAVATION)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION))); + } + + if (Permissions.skillEnabled(inspect, SkillType.FISHING)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING))); + } + + if (Permissions.skillEnabled(inspect, SkillType.HERBALISM)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM))); + } + + if (Permissions.skillEnabled(inspect, SkillType.MINING)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING))); + } + + if (Permissions.skillEnabled(inspect, SkillType.WOODCUTTING)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING))); + } + } + } + + public static void printGatheringSkills(Player player, PlayerProfile profile) { + printGatheringSkills(player, profile, player); + } + + /** + * Print out details on Combat skills. Only for online players. + * + * @param inspect The player to retrieve stats for + * @param profile The player's profile + * @param display The sender to display stats to + */ + public static void printCombatSkills(Player inspect, PlayerProfile profile, CommandSender display) { + if (SkillUtils.hasCombatSkills(inspect)) { + display.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); + + if (Permissions.skillEnabled(inspect, SkillType.AXES)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES))); + } + + if (Permissions.skillEnabled(inspect, SkillType.ARCHERY)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY))); + } + + if (Permissions.skillEnabled(inspect, SkillType.SWORDS)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS))); + } + + if (Permissions.skillEnabled(inspect, SkillType.TAMING)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING))); + } + + if (Permissions.skillEnabled(inspect, SkillType.UNARMED)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED))); + } + } + } + + public static void printCombatSkills(Player player, PlayerProfile profile) { + printCombatSkills(player, profile, player); + } + + /** + * Print out details on Misc skills. Only for online players. + * + * @param inspect The player to retrieve stats for + * @param profile The player's profile + * @param display The sender to display stats to + */ + public static void printMiscSkills(Player inspect, PlayerProfile profile, CommandSender display) { + if (SkillUtils.hasMiscSkills(inspect)) { + display.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); + + if (Permissions.skillEnabled(inspect, SkillType.ACROBATICS)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS))); + } + + if (Permissions.skillEnabled(inspect, SkillType.REPAIR)) { + display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR))); + } + } + } + + public static void printMiscSkills(Player player, PlayerProfile profile) { + printMiscSkills(player, profile, player); + } +} diff --git a/src/main/java/com/gmail/nossr50/util/Users.java b/src/main/java/com/gmail/nossr50/util/player/UserManager.java similarity index 89% rename from src/main/java/com/gmail/nossr50/util/Users.java rename to src/main/java/com/gmail/nossr50/util/player/UserManager.java index 445f74eac..bd380486a 100644 --- a/src/main/java/com/gmail/nossr50/util/Users.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.util; +package com.gmail.nossr50.util.player; import java.io.File; import java.io.IOException; @@ -9,13 +9,13 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; -public final class Users { +public final class UserManager { private static Map players = new HashMap(); - private Users() {}; + private UserManager() {}; /** * Load users. @@ -42,7 +42,7 @@ public final class Users { McMMOPlayer mcMMOPlayer = players.get(playerName); if (mcMMOPlayer != null) { - mcMMOPlayer.setPlayer(player); //The player object is different on each reconnection and must be updated + mcMMOPlayer.setPlayer(player); // The player object is different on each reconnection and must be updated } else { mcMMOPlayer = new McMMOPlayer(player); diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java similarity index 73% rename from src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java rename to src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index e10efc94f..e53aea1d4 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.skills.utilities; +package com.gmail.nossr50.util.skills; import org.bukkit.Material; import org.bukkit.entity.AnimalTamer; @@ -20,26 +20,29 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.runnables.skills.AwardCombatXpTask; +import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.axes.AxeManager; -import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.runnables.CombatXpGiver; import com.gmail.nossr50.skills.swords.Swords; import com.gmail.nossr50.skills.taming.Taming; -import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.ModUtils; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Users; +import com.gmail.nossr50.util.player.UserManager; -public final class CombatTools { - private CombatTools() {} +public final class CombatUtils { + private CombatUtils() {} /** * Apply combat modifiers and process and XP gain. @@ -65,7 +68,7 @@ public final class CombatTools { ItemStack heldItem = player.getItemInHand(); Material heldItemType = heldItem.getType(); - if (ItemChecks.isSword(heldItem)) { + if (ItemUtils.isSword(heldItem)) { if (targetIsPlayer || targetIsTamedPet) { if (!SkillType.SWORDS.getPVPEnabled()) { return; @@ -76,13 +79,13 @@ public final class CombatTools { } if (Permissions.skillEnabled(player, SkillType.SWORDS)) { - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); String playerName = player.getName(); - boolean canSerratedStrike = Permissions.serratedStrikes(player); //So we don't have to check the same permission twice + boolean canSerratedStrike = Permissions.serratedStrikes(player); // So we don't have to check the same permission twice if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) { - SkillTools.abilityCheck(player, SkillType.SWORDS); + SkillUtils.abilityCheck(player, SkillType.SWORDS); } if (Permissions.bleed(player)) { @@ -96,7 +99,7 @@ public final class CombatTools { startGainXp(mcMMOPlayer, target, SkillType.SWORDS); } } - else if (ItemChecks.isAxe(heldItem)) { + else if (ItemUtils.isAxe(heldItem)) { if (((targetIsPlayer || targetIsTamedPet) && !SkillType.AXES.getPVPEnabled()) || (!targetIsPlayer && !targetIsTamedPet && !SkillType.AXES.getPVEEnabled())) { return; } @@ -105,7 +108,7 @@ public final class CombatTools { AxeManager axeManager = SkillManagerStore.getInstance().getAxeManager(player.getName()); if (axeManager.canActivateAbility()) { - SkillTools.abilityCheck(player, SkillType.AXES); + SkillUtils.abilityCheck(player, SkillType.AXES); } if (axeManager.canUseAxeMastery()) { @@ -119,7 +122,7 @@ public final class CombatTools { if (axeManager.canImpact(target)) { axeManager.impactCheck(target); } - else if (axeManager.canGreaterImpact(target)){ + else if (axeManager.canGreaterImpact(target)) { event.setDamage(axeManager.greaterImpactCheck(target, event.getDamage())); } @@ -141,14 +144,14 @@ public final class CombatTools { } if (Permissions.skillEnabled(player, SkillType.UNARMED)) { - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); String playerName = player.getName(); - boolean canBerserk = Permissions.berserk(player); //So we don't have to check the same permission twice + boolean canBerserk = Permissions.berserk(player); // So we don't have to check the same permission twice if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) { - SkillTools.abilityCheck(player, SkillType.UNARMED); + SkillUtils.abilityCheck(player, SkillType.UNARMED); } if (Permissions.bonusDamage(player, SkillType.UNARMED)) { @@ -176,69 +179,69 @@ public final class CombatTools { } switch (damager.getType()) { - case WOLF: - Wolf wolf = (Wolf) damager; + case WOLF: + Wolf wolf = (Wolf) damager; - if (wolf.isTamed() && wolf.getOwner() instanceof Player) { - Player master = (Player) wolf.getOwner(); + if (wolf.isTamed() && wolf.getOwner() instanceof Player) { + Player master = (Player) wolf.getOwner(); - if (Misc.isNPCEntity(master)) { - return; + if (Misc.isNPCEntity(master)) { + return; + } + + if (targetIsPlayer || targetIsTamedPet) { + if (!SkillType.TAMING.getPVPEnabled()) { + return; + } + } + else if (!SkillType.TAMING.getPVEEnabled()) { + return; + } + + if (Permissions.skillEnabled(master, SkillType.TAMING)) { + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master); + int skillLevel = SkillManagerStore.getInstance().getTamingManager(master.getName()).getSkillLevel(); + + if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) { + SkillManagerStore.getInstance().getTamingManager(master.getName()).fastFoodService(wolf, event.getDamage()); + } + + if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) { + SkillManagerStore.getInstance().getTamingManager(master.getName()).sharpenedClaws(event); + } + + if (Permissions.gore(master)) { + SkillManagerStore.getInstance().getTamingManager(master.getName()).gore(event); + } + + startGainXp(mcMMOPlayer, target, SkillType.TAMING); + } + } + + break; + + case ARROW: + LivingEntity shooter = ((Arrow) damager).getShooter(); + + /* Break instead of return due to Dodge/Counter/Deflect abilities */ + if (shooter == null || !(shooter instanceof Player)) { + break; } if (targetIsPlayer || targetIsTamedPet) { - if (!SkillType.TAMING.getPVPEnabled()) { + if (!SkillType.ARCHERY.getPVPEnabled()) { return; } } - else if (!SkillType.TAMING.getPVEEnabled()) { + else if (!SkillType.ARCHERY.getPVEEnabled()) { return; } - if (Permissions.skillEnabled(master, SkillType.TAMING)) { - McMMOPlayer mcMMOPlayer = Users.getPlayer(master); - int skillLevel = SkillManagerStore.getInstance().getTamingManager(master.getName()).getSkillLevel(); - - if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) { - SkillManagerStore.getInstance().getTamingManager(master.getName()).fastFoodService(wolf, event.getDamage()); - } - - if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) { - SkillManagerStore.getInstance().getTamingManager(master.getName()).sharpenedClaws(event); - } - - if (Permissions.gore(master)) { - SkillManagerStore.getInstance().getTamingManager(master.getName()).gore(event); - } - - startGainXp(mcMMOPlayer, target, SkillType.TAMING); - } - } - - break; - - case ARROW: - LivingEntity shooter = ((Arrow) damager).getShooter(); - - /* Break instead of return due to Dodge/Counter/Deflect abilities */ - if (shooter == null || !(shooter instanceof Player)) { + archeryCheck((Player) shooter, target, event); break; - } - if (targetIsPlayer || targetIsTamedPet) { - if (!SkillType.ARCHERY.getPVPEnabled()) { - return; - } - } - else if (!SkillType.ARCHERY.getPVEEnabled()) { - return; - } - - archeryCheck((Player) shooter, target, event); - break; - - default: - break; + default: + break; } if (targetIsPlayer) { @@ -255,12 +258,12 @@ public final class CombatTools { } if (damager instanceof Player) { - if (SkillType.SWORDS.getPVPEnabled() && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) { + if (SkillType.SWORDS.getPVPEnabled() && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) { SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); } } else { - if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) { + if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) { SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); } } @@ -303,7 +306,7 @@ public final class CombatTools { } SkillManagerStore.getInstance().getArcheryManager(playerName).distanceXpBonus(target); - startGainXp(Users.getPlayer(shooter), target, SkillType.ARCHERY); + startGainXp(UserManager.getPlayer(shooter), target, SkillType.ARCHERY); } } @@ -372,7 +375,7 @@ public final class CombatTools { * @param type The type of skill being used */ public static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, SkillType type) { - int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit + int numberOfTargets = Misc.getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit int damageAmount = damage; if (damageAmount < 1) { @@ -392,24 +395,24 @@ public final class CombatTools { mcMMO.p.getServer().getPluginManager().callEvent(armswing); switch (type) { - case SWORDS: - if (entity instanceof Player) { - ((Player) entity).sendMessage(LocaleLoader.getString("Swords.Combat.SS.Struck")); - } + case SWORDS: + if (entity instanceof Player) { + ((Player) entity).sendMessage(LocaleLoader.getString("Swords.Combat.SS.Struck")); + } - BleedTimer.add((LivingEntity) entity, Swords.serratedStrikesBleedTicks); + BleedTimerTask.add((LivingEntity) entity, Swords.serratedStrikesBleedTicks); - break; + break; - case AXES: - if (entity instanceof Player) { - ((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck")); - } + case AXES: + if (entity instanceof Player) { + ((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck")); + } - break; + break; - default: - break; + default: + break; } dealDamage((LivingEntity) entity, damageAmount, attacker); @@ -434,14 +437,14 @@ public final class CombatTools { Player defender = (Player) target; - if (System.currentTimeMillis() >= Users.getPlayer(defender).getProfile().getRespawnATS() + 5) { + if (System.currentTimeMillis() >= UserManager.getPlayer(defender).getProfile().getRespawnATS() + 5) { baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP(); } } else if (!target.hasMetadata(mcMMO.entityMetadataKey)) { if (target instanceof Animals) { - if (ModChecks.isCustomEntity(target)) { - baseXP = ModChecks.getCustomEntity(target).getXpMultiplier(); + if (ModUtils.isCustomEntity(target)) { + baseXP = ModUtils.getCustomEntity(target).getXpMultiplier(); } else { baseXP = Config.getInstance().getAnimalsXP(); @@ -451,55 +454,55 @@ public final class CombatTools { EntityType type = target.getType(); switch (type) { - case BAT: - baseXP = Config.getInstance().getAnimalsXP(); - break; + case BAT: + baseXP = Config.getInstance().getAnimalsXP(); + break; - case BLAZE: - case CAVE_SPIDER: - case CREEPER: - case ENDER_DRAGON: - case ENDERMAN: - case GHAST: - case GIANT: - case MAGMA_CUBE: - case PIG_ZOMBIE: - case SILVERFISH: - case SLIME: - case SPIDER: - case WITCH: - case WITHER: - case ZOMBIE: - baseXP = Config.getInstance().getCombatXP(type); - break; - - // Temporary workaround for custom entities - case UNKNOWN: - baseXP = 1.0; - break; - - case SKELETON: - switch(((Skeleton) target).getSkeletonType()) { + case BLAZE: + case CAVE_SPIDER: + case CREEPER: + case ENDER_DRAGON: + case ENDERMAN: + case GHAST: + case GIANT: + case MAGMA_CUBE: + case PIG_ZOMBIE: + case SILVERFISH: + case SLIME: + case SPIDER: + case WITCH: case WITHER: - baseXP = Config.getInstance().getWitherSkeletonXP(); + case ZOMBIE: + baseXP = Config.getInstance().getCombatXP(type); break; + + // Temporary workaround for custom entities + case UNKNOWN: + baseXP = 1.0; + break; + + case SKELETON: + switch (((Skeleton) target).getSkeletonType()) { + case WITHER: + baseXP = Config.getInstance().getWitherSkeletonXP(); + break; + default: + baseXP = Config.getInstance().getCombatXP(type); + break; + } + break; + + case IRON_GOLEM: + if (!((IronGolem) target).isPlayerCreated()) { + baseXP = Config.getInstance().getCombatXP(type); + } + break; + default: - baseXP = Config.getInstance().getCombatXP(type); + if (ModUtils.isCustomEntity(target)) { + baseXP = ModUtils.getCustomEntity(target).getXpMultiplier(); + } break; - } - break; - - case IRON_GOLEM: - if (!((IronGolem) target).isPlayerCreated()) { - baseXP = Config.getInstance().getCombatXP(type); - } - break; - - default: - if (ModChecks.isCustomEntity(target)) { - baseXP = ModChecks.getCustomEntity(target).getXpMultiplier(); - } - break; } } @@ -507,7 +510,7 @@ public final class CombatTools { } if (baseXP != 0) { - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new CombatXpGiver(mcMMOPlayer, skillType, baseXP, target), 0); + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target), 0); } } @@ -522,7 +525,7 @@ public final class CombatTools { if (entity instanceof Player) { Player defender = (Player) entity; - if (!defender.getWorld().getPVP() || defender == player || Users.getPlayer(defender).getProfile().getGodMode()) { + if (!defender.getWorld().getPVP() || defender == player || UserManager.getPlayer(defender).getProfile().getGodMode()) { return false; } @@ -530,7 +533,7 @@ public final class CombatTools { return false; } - //It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE() + // It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE() EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(player, entity, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 1); mcMMO.p.getServer().getPluginManager().callEvent(ede); diff --git a/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java similarity index 96% rename from src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java rename to src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java index 56dcbdc38..37d5fc4f6 100644 --- a/src/main/java/com/gmail/nossr50/util/ParticleEffectUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java @@ -1,89 +1,89 @@ -package com.gmail.nossr50.util; - -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.FireworkEffect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Firework; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.meta.FireworkMeta; - -import com.gmail.nossr50.config.Config; - -public final class ParticleEffectUtils { - - private ParticleEffectUtils() {}; - - public static void playBleedEffect(LivingEntity livingEntity) { - if (!Config.getInstance().getBleedEffectEnabled()) { - return; - } - - livingEntity.getWorld().playEffect(livingEntity.getEyeLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE); - } - - public static void playDodgeEffect(Player player) { - if (!Config.getInstance().getDodgeEffectEnabled()) { - return; - } - - Location location = player.getEyeLocation(); - World world = player.getWorld(); - - world.playEffect(location, Effect.SMOKE, BlockFace.SOUTH_EAST); - world.playEffect(location, Effect.SMOKE, BlockFace.SOUTH); - world.playEffect(location, Effect.SMOKE, BlockFace.SOUTH_WEST); - world.playEffect(location, Effect.SMOKE, BlockFace.EAST); - world.playEffect(location, Effect.SMOKE, BlockFace.SELF); - world.playEffect(location, Effect.SMOKE, BlockFace.WEST); - world.playEffect(location, Effect.SMOKE, BlockFace.NORTH_EAST); - world.playEffect(location, Effect.SMOKE, BlockFace.NORTH); - world.playEffect(location, Effect.SMOKE, BlockFace.NORTH_WEST); - } - - public static void playGreaterImpactEffect(LivingEntity livingEntity) { - if (!Config.getInstance().getGreaterImpactEffectEnabled()) { - return; - } - - Location location = livingEntity.getEyeLocation(); - - livingEntity.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false); - } - - public static void playAbilityEnabledEffect(Player player) { - if (!Config.getInstance().getAbilityActivationEffectEnabled()) { - return; - } - - fireworkParticleShower(player, Color.GREEN); - } - - public static void playAbilityDisabledEffect(Player player) { - if (!Config.getInstance().getAbilityDeactivationEffectEnabled()) { - return; - } - - fireworkParticleShower(player, Color.RED); - } - - private static void fireworkParticleShower(Player player, Color color) { - Location location = player.getLocation(); - location.setY(location.getY() - 1.0); - location.setPitch(-90); - - Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK); - FireworkMeta fireworkMeta = firework.getFireworkMeta(); - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with(Type.BALL_LARGE).trail(true).build(); - fireworkMeta.addEffect(effect); - fireworkMeta.addEffect(effect); - fireworkMeta.setPower(0); - firework.setFireworkMeta(fireworkMeta); - } -} +package com.gmail.nossr50.util.skills; + +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Firework; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.FireworkMeta; + +import com.gmail.nossr50.config.Config; + +public final class ParticleEffectUtils { + + private ParticleEffectUtils() {}; + + public static void playBleedEffect(LivingEntity livingEntity) { + if (!Config.getInstance().getBleedEffectEnabled()) { + return; + } + + livingEntity.getWorld().playEffect(livingEntity.getEyeLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE); + } + + public static void playDodgeEffect(Player player) { + if (!Config.getInstance().getDodgeEffectEnabled()) { + return; + } + + Location location = player.getEyeLocation(); + World world = player.getWorld(); + + world.playEffect(location, Effect.SMOKE, BlockFace.SOUTH_EAST); + world.playEffect(location, Effect.SMOKE, BlockFace.SOUTH); + world.playEffect(location, Effect.SMOKE, BlockFace.SOUTH_WEST); + world.playEffect(location, Effect.SMOKE, BlockFace.EAST); + world.playEffect(location, Effect.SMOKE, BlockFace.SELF); + world.playEffect(location, Effect.SMOKE, BlockFace.WEST); + world.playEffect(location, Effect.SMOKE, BlockFace.NORTH_EAST); + world.playEffect(location, Effect.SMOKE, BlockFace.NORTH); + world.playEffect(location, Effect.SMOKE, BlockFace.NORTH_WEST); + } + + public static void playGreaterImpactEffect(LivingEntity livingEntity) { + if (!Config.getInstance().getGreaterImpactEffectEnabled()) { + return; + } + + Location location = livingEntity.getEyeLocation(); + + livingEntity.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false); + } + + public static void playAbilityEnabledEffect(Player player) { + if (!Config.getInstance().getAbilityActivationEffectEnabled()) { + return; + } + + fireworkParticleShower(player, Color.GREEN); + } + + public static void playAbilityDisabledEffect(Player player) { + if (!Config.getInstance().getAbilityDeactivationEffectEnabled()) { + return; + } + + fireworkParticleShower(player, Color.RED); + } + + private static void fireworkParticleShower(Player player, Color color) { + Location location = player.getLocation(); + location.setY(location.getY() - 1.0); + location.setPitch(-90); + + Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK); + FireworkMeta fireworkMeta = firework.getFireworkMeta(); + FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with(Type.BALL_LARGE).trail(true).build(); + fireworkMeta.addEffect(effect); + fireworkMeta.addEffect(effect); + fireworkMeta.setPower(0); + firework.setFireworkMeta(fireworkMeta); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/PerksUtils.java b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java similarity index 94% rename from src/main/java/com/gmail/nossr50/skills/utilities/PerksUtils.java rename to src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java index b6b25af55..dadbacbcf 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/PerksUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java @@ -1,78 +1,79 @@ -package com.gmail.nossr50.skills.utilities; - -import org.bukkit.entity.Player; - -import com.gmail.nossr50.util.Permissions; - -public final class PerksUtils { - private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75; - private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100; - - private PerksUtils() {}; - - public static int handleCooldownPerks(Player player, int cooldown) { - if (Permissions.halvedCooldowns(player)) { - cooldown *= 0.5; - } - else if (Permissions.thirdedCooldowns(player)) { - cooldown *= (1.0 / 3.0); - } - else if (Permissions.quarteredCooldowns(player)) { - cooldown *= 0.75; - } - - return cooldown; - } - - public static int handleActivationPerks(Player player, int ticks, int maxTicks) { - if (Permissions.twelveSecondActivationBoost(player)) { - ticks += 12; - } - else if (Permissions.eightSecondActivationBoost(player)) { - ticks += 8; - } - else if (Permissions.fourSecondActivationBoost(player)) { - ticks += 4; - } - - if (maxTicks != 0 && ticks > maxTicks) { - ticks = maxTicks; - } - - return ticks; - } - - public static int handleXpPerks(Player player, int xp) { - if (Permissions.quadrupleXp(player)) { - xp *= 4; - } - else if (Permissions.tripleXp(player)) { - xp *= 3; - } - else if (Permissions.doubleAndOneHalfXp(player)) { - xp *= 2.5; - } - else if (Permissions.doubleXp(player)) { - xp *= 2; - } - else if (Permissions.oneAndOneHalfXp(player)) { - xp *= 1.5; - } - - return xp; - } - - /** - * Calculate activation chance for a skill. - * - * @param isLucky true if the player has the appropriate "lucky" perk, false otherwise - * @return the activation chance - */ - public static int handleLuckyPerks(Player player, SkillType skill) { - if (Permissions.lucky(player, skill)) { - return LUCKY_SKILL_ACTIVATION_CHANCE; - } - - return NORMAL_SKILL_ACTIVATION_CHANCE; - } -} +package com.gmail.nossr50.util.skills; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.util.Permissions; + +public final class PerksUtils { + private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75; + private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100; + + private PerksUtils() {}; + + public static int handleCooldownPerks(Player player, int cooldown) { + if (Permissions.halvedCooldowns(player)) { + cooldown *= 0.5; + } + else if (Permissions.thirdedCooldowns(player)) { + cooldown *= (1.0 / 3.0); + } + else if (Permissions.quarteredCooldowns(player)) { + cooldown *= 0.75; + } + + return cooldown; + } + + public static int handleActivationPerks(Player player, int ticks, int maxTicks) { + if (Permissions.twelveSecondActivationBoost(player)) { + ticks += 12; + } + else if (Permissions.eightSecondActivationBoost(player)) { + ticks += 8; + } + else if (Permissions.fourSecondActivationBoost(player)) { + ticks += 4; + } + + if (maxTicks != 0 && ticks > maxTicks) { + ticks = maxTicks; + } + + return ticks; + } + + public static int handleXpPerks(Player player, int xp) { + if (Permissions.quadrupleXp(player)) { + xp *= 4; + } + else if (Permissions.tripleXp(player)) { + xp *= 3; + } + else if (Permissions.doubleAndOneHalfXp(player)) { + xp *= 2.5; + } + else if (Permissions.doubleXp(player)) { + xp *= 2; + } + else if (Permissions.oneAndOneHalfXp(player)) { + xp *= 1.5; + } + + return xp; + } + + /** + * Calculate activation chance for a skill. + * + * @param isLucky true if the player has the appropriate "lucky" perk, false otherwise + * @return the activation chance + */ + public static int handleLuckyPerks(Player player, SkillType skill) { + if (Permissions.lucky(player, skill)) { + return LUCKY_SKILL_ACTIVATION_CHANCE; + } + + return NORMAL_SKILL_ACTIVATION_CHANCE; + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java similarity index 88% rename from src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java rename to src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index f57b81962..5c313d246 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -1,623 +1,628 @@ -package com.gmail.nossr50.skills.utilities; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.PluginManager; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.getspout.spoutapi.SpoutManager; -import org.getspout.spoutapi.player.SpoutPlayer; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.HiddenConfig; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; -import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; -import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; -import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mods.ModChecks; -import com.gmail.nossr50.spout.SpoutConfig; -import com.gmail.nossr50.spout.SpoutTools; -import com.gmail.nossr50.util.ItemChecks; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.ParticleEffectUtils; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; - -public class SkillTools { - public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) { - int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill); - - int currentFoodLevel = player.getFoodLevel(); - int foodChange = eventFoodLevel - currentFoodLevel; - - for (int i = baseLevel; i <= maxLevel; i+= rankChange) { - if (skillLevel >= i) { - foodChange++; - } - } - - return currentFoodLevel + foodChange; - } - - /** - * Checks to see if the cooldown for an item or ability is expired. - * - * @param oldTime The time the ability or item was last used - * @param cooldown The amount of time that must pass between uses - * @param player The player whose cooldown is being checked - * @return true if the cooldown is over, false otherwise - */ - public static boolean cooldownOver(long oldTime, int cooldown, Player player) { - long currentTime = System.currentTimeMillis(); - int adjustedCooldown = PerksUtils.handleCooldownPerks(player, cooldown); - - if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) { - return true; - } - - return false; - } - - /** - * Calculate the time remaining until the cooldown expires. - * - * @param deactivatedTimeStamp Time of deactivation - * @param cooldown The length of the cooldown - * @return the number of seconds remaining before the cooldown expires - */ - public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) { - return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR); - } - - /** - * Sends a message to the player when the cooldown expires. - * - * @param player The player to send a message to - * @param profile The profile of the player - * @param ability The ability to watch cooldowns for - */ - public static void watchCooldown(Player player, PlayerProfile profile, AbilityType ability) { - if (player == null || profile == null || ability == null) - return; - - if (!profile.getAbilityInformed(ability) && cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { - profile.setAbilityInformed(ability, true); - player.sendMessage(ability.getAbilityRefresh()); - } - } - - /** - * Process activating abilities & readying the tool. - * - * @param player The player using the ability - * @param skill The skill the ability is tied to - */ - public static void activationCheck(Player player, SkillType skill) { - if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) { - return; - } - - PlayerProfile profile = Users.getPlayer(player).getProfile(); - AbilityType ability = skill.getAbility(); - ToolType tool = skill.getTool(); - ItemStack inHand = player.getItemInHand(); - - if (ModChecks.isCustomTool(inHand) && !ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) { - return; - } - - /* Check if any abilities are active */ - if (profile == null) { - return; - } - - if (!profile.getAbilityUse()) { - return; - } - - for (AbilityType x : AbilityType.values()) { - if (profile.getAbilityMode(x)) { - return; - } - } - - /* Woodcutting & Axes need to be treated differently. - * Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action - */ - if (ability.getPermissions(player) && tool.inHand(inHand) && !profile.getToolPreparationMode(tool)) { - if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) { - if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { - player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); - return; - } - } - - if (Config.getInstance().getAbilityMessagesEnabled()) { - player.sendMessage(tool.getRaiseTool()); - } - - profile.setToolPreparationATS(tool, System.currentTimeMillis()); - profile.setToolPreparationMode(tool, true); - } - } - - /** - * Monitors various things relating to skill abilities. - * - * @param player The player using the skill - * @param profile The profile of the player - * @param curTime The current system time - * @param skill The skill being monitored - */ - public static void monitorSkill(Player player, PlayerProfile profile, long curTime, SkillType skill) { - final int FOUR_SECONDS = 4000; - - ToolType tool = skill.getTool(); - AbilityType ability = skill.getAbility(); - - if (profile == null) { - return; - } - - if (profile.getToolPreparationMode(tool) && curTime - (profile.getToolPreparationATS(tool) * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) { - profile.setToolPreparationMode(tool, false); - - if (Config.getInstance().getAbilityMessagesEnabled()) { - player.sendMessage(tool.getLowerTool()); - } - } - - if (ability.getPermissions(player)) { - if (profile.getAbilityMode(ability) && (profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) { - if (ability == AbilityType.BERSERK) { - player.setCanPickupItems(true); - } - else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) { - handleAbilitySpeedDecrease(player); - } - - profile.setAbilityMode(ability, false); - profile.setAbilityInformed(ability, false); - - ParticleEffectUtils.playAbilityDisabledEffect(player); - - if (profile.useChatNotifications()) { - player.sendMessage(ability.getAbilityOff()); - } - - sendSkillMessage(player, ability.getAbilityPlayerOff(player)); - } - } - } - - /** - * Check the XP of a skill. - * - * @param skillType The skill to check - * @param player The player whose skill to check - * @param profile The profile of the player whose skill to check - */ - public static void xpCheckSkill(SkillType skillType, Player player, PlayerProfile profile) { - int skillups = 0; - int xpRemoved = 0; - - if (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) { - - while (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) { - if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= Users.getPlayer(player).getPowerLevel() + 1)) { - int xp = profile.getXpToLevel(skillType); - xpRemoved += xp; - - profile.removeXp(skillType, xp); - skillups++; - profile.skillUp(skillType, 1); - } - else { - profile.addLevels(skillType, 0); - } - } - - McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType, skillups); - mcMMO.p.getServer().getPluginManager().callEvent(eventToFire); - - if (eventToFire.isCancelled()) { - profile.modifySkill(skillType, profile.getSkillLevel(skillType) - skillups); - profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + xpRemoved); - return; - } - - String capitalized = StringUtils.getCapitalized(skillType.toString()); - - /* Spout Stuff */ - if (mcMMO.spoutEnabled) { - SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); - - if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) { - SpoutTools.levelUpNotification(skillType, spoutPlayer); - - /* Update custom titles */ - if (SpoutConfig.getInstance().getShowPowerLevel()) { - spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getName(), Users.getPlayer(player).getPowerLevel())); - } - } - else { - player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", skillups, profile.getSkillLevel(skillType))); - } - } - else { - player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", skillups, profile.getSkillLevel(skillType))); - } - } - - if (mcMMO.spoutEnabled) { - SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); - - if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) { - if (SpoutConfig.getInstance().getXPBarEnabled()) { - profile.getSpoutHud().updateXpBar(); - } - } - } - } - - /** - * Checks if the given string represents a valid skill - * - * @param skillName The name of the skill to check - * @return true if this is a valid skill, false otherwise - */ - public static boolean isSkill(String skillName) { - if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) { - return isLocalizedSkill(skillName); - } - - if (SkillType.getSkill(skillName) != null) { - return true; - } - - return false; - } - - private static boolean isLocalizedSkill(String skillName) { - for (SkillType skill : SkillType.values()) { - if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName"))) { - return true; - } - } - - return false; - } - - public static String getSkillName(SkillType skill) { - if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) { - return StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName")); - } - - return StringUtils.getCapitalized(skill.toString()); - } - - /** - * Check if the player has any combat skill permissions. - * - * @param player The player to check permissions for - * @return true if the player has combat skills, false otherwise - */ - public static boolean hasCombatSkills(Player player) { - if (Permissions.skillEnabled(player, SkillType.AXES) - || Permissions.skillEnabled(player, SkillType.ARCHERY) - || Permissions.skillEnabled(player, SkillType.SWORDS) - || Permissions.skillEnabled(player, SkillType.TAMING) - || Permissions.skillEnabled(player, SkillType.UNARMED)) { - return true; - } - - return false; - } - - /** - * Check if the player has any gathering skill permissions. - * - * @param player The player to check permissions for - * @return true if the player has gathering skills, false otherwise - */ - public static boolean hasGatheringSkills(Player player) { - if (Permissions.skillEnabled(player, SkillType.EXCAVATION) - || Permissions.skillEnabled(player, SkillType.FISHING) - || Permissions.skillEnabled(player, SkillType.HERBALISM) - || Permissions.skillEnabled(player, SkillType.MINING) - || Permissions.skillEnabled(player, SkillType.WOODCUTTING)) { - return true; - } - - return false; - } - - /** - * Check if the player has any misc skill permissions. - * - * @param player The player to check permissions for - * @return true if the player has misc skills, false otherwise - */ - public static boolean hasMiscSkills(Player player) { - if (Permissions.skillEnabled(player, SkillType.ACROBATICS) - || Permissions.skillEnabled(player, SkillType.SMELTING) - || Permissions.skillEnabled(player, SkillType.REPAIR)) { - return true; - } - - return false; - } - - /** - * Check to see if an ability can be activated. - * - * @param player The player activating the ability - * @param type The skill the ability is based on - */ - public static void abilityCheck(Player player, SkillType type) { - PlayerProfile profile = Users.getPlayer(player).getProfile(); - ToolType tool = type.getTool(); - AbilityType ability = type.getAbility(); - - profile.setToolPreparationMode(tool, false); - - /* Axes and Woodcutting are odd because they share the same tool. - * We show them the too tired message when they take action. - */ - if (type == SkillType.WOODCUTTING || type == SkillType.AXES) { - if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { - player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); - return; - } - } - - if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) { - int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks()); - - ParticleEffectUtils.playAbilityEnabledEffect(player); - - if (profile.useChatNotifications()) { - player.sendMessage(ability.getAbilityOn()); - } - - SkillTools.sendSkillMessage(player, ability.getAbilityPlayer(player)); - - profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); - profile.setAbilityMode(ability, true); - - if (ability == AbilityType.BERSERK) { - player.setCanPickupItems(false); - } - else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) { - handleAbilitySpeedIncrease(player); - } - } - } - - /** - * Check to see if ability should be triggered. - * - * @param player The player using the ability - * @param block The block modified by the ability - * @param ability The ability to check - * @return true if the ability should activate, false otherwise - */ - public static boolean triggerCheck(Player player, Block block, AbilityType ability) { - boolean activate = true; - - switch (ability) { - case BERSERK: - case LEAF_BLOWER: - if (!ability.blockCheck(block.getState())) { - activate = false; - break; - } - - if (!blockBreakSimulate(block, player, true)) { - activate = false; - break; - } - break; - - case GIGA_DRILL_BREAKER: - case SUPER_BREAKER: - case GREEN_TERRA: - if (!ability.blockCheck(block.getState())) { - activate = false; - break; - } - break; - - default: - activate = false; - break; - } - - return activate; - } - - public static void sendSkillMessage(Player player, String message) { - for (Player otherPlayer : player.getWorld().getPlayers()) { - if (otherPlayer != player && Misc.isNear(player.getLocation(), otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { - otherPlayer.sendMessage(message); - } - } - } - - /** - * Check if a skill level is higher than the max bonus level of the ability. - * - * @param skillLevel Skill level to check - * @param maxLevel Max level of the ability - * @return whichever value is lower - */ - public static int skillCheck(int skillLevel, int maxLevel) { - //TODO: Could we just use Math.min(skillLevel, maxLevel) here? - if (skillLevel > maxLevel) { - return maxLevel; - } - - return skillLevel; - } - - public static void handleAbilitySpeedIncrease(Player player) { - if (HiddenConfig.getInstance().useEnchantmentBuffs()) { - ItemStack heldItem = player.getItemInHand(); - - if (heldItem == null || heldItem.getType() == Material.AIR ) { - return; - } - - int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED); - ItemMeta itemMeta = heldItem.getItemMeta(); - List itemLore = new ArrayList(); - - if (itemMeta.hasLore()) { - itemLore = itemMeta.getLore(); - } - - itemLore.add("mcMMO Ability Tool"); - itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + 5, true); - - itemMeta.setLore(itemLore); - heldItem.setItemMeta(itemMeta); - } - else { - int duration = 0; - int amplifier = 0; - - if (player.hasPotionEffect(PotionEffectType.FAST_DIGGING)) { - for (PotionEffect effect : player.getActivePotionEffects()) { - if (effect.getType() == PotionEffectType.FAST_DIGGING) { - duration = effect.getDuration(); - amplifier = effect.getAmplifier(); - break; - } - } - } - - PlayerProfile profile = Users.getPlayer(player).getProfile(); - int ticks = 0; - - if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) { - ticks = ((int) (profile.getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; - } - else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { - ticks = ((int) (profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; - } - - PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10); - player.addPotionEffect(abilityBuff, true); - } - } - - public static void handleAbilitySpeedDecrease(Player player) { - if (HiddenConfig.getInstance().useEnchantmentBuffs()) { - PlayerInventory playerInventory = player.getInventory(); - - for (int i = 0; i < playerInventory.getContents().length; i++) { - ItemStack item = playerInventory.getItem(i); - playerInventory.setItem(i, removeAbilityBuff(item)); - } - } - else { - player.removePotionEffect(PotionEffectType.FAST_DIGGING); - } - } - - public static ItemStack removeAbilityBuff(ItemStack item) { - if (item == null || item.getType() == Material.AIR ) { - return item; - } - - if (!ItemChecks.isPickaxe(item) && !ItemChecks.isShovel(item)) { - return item; - } - - if (item.containsEnchantment(Enchantment.DIG_SPEED)) { - ItemMeta itemMeta = item.getItemMeta(); - - if (itemMeta.hasLore()) { - List itemLore = itemMeta.getLore(); - - if (itemLore.remove("mcMMO Ability Tool")) { - int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED); - - if (efficiencyLevel <= 5) { - itemMeta.removeEnchant(Enchantment.DIG_SPEED); - } - else { - itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - 5, true); - } - - itemMeta.setLore(itemLore); - item.setItemMeta(itemMeta); - } - } - } - - return item; - } - - /** - * Simulate a block break event. - * - * @param block The block to break - * @param player The player breaking the block - * @param shouldArmSwing true if an armswing event should be fired, false otherwise - * @return true if the event wasn't cancelled, false otherwise - */ - public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) { - PluginManager pluginManger = mcMMO.p.getServer().getPluginManager(); - - //Support for NoCheat - if (shouldArmSwing) { - pluginManger.callEvent(new FakePlayerAnimationEvent(player)); - } - - FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true); - pluginManger.callEvent(damageEvent); - - FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player); - pluginManger.callEvent(breakEvent); - - if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) { - return true; - } - - return false; - } - - public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) { - int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill); - int activationChance = PerksUtils.handleLuckyPerks(player, skill); - double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel); - - return chance > Misc.getRandom().nextInt(activationChance); - } - - public static boolean activationSuccessful(Player player, SkillType skill, double chance) { - return chance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, skill)); - } - - public static boolean unlockLevelReached(Player player, SkillType skill, int unlockLevel) { - return Users.getPlayer(player).getProfile().getSkillLevel(skill) > unlockLevel; - } - - public static boolean treasureDropSuccessful(double dropChance, int activationChance) { - return dropChance > Misc.getRandom().nextDouble() * activationChance; - } -} +package com.gmail.nossr50.util.skills; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.PluginManager; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.getspout.spoutapi.SpoutManager; +import org.getspout.spoutapi.player.SpoutPlayer; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.HiddenConfig; +import com.gmail.nossr50.config.spout.SpoutConfig; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.skills.ToolType; +import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; +import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; +import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; +import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.ModUtils; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.spout.SpoutUtils; + +public class SkillUtils { + public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) { + int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill); + + int currentFoodLevel = player.getFoodLevel(); + int foodChange = eventFoodLevel - currentFoodLevel; + + for (int i = baseLevel; i <= maxLevel; i += rankChange) { + if (skillLevel >= i) { + foodChange++; + } + } + + return currentFoodLevel + foodChange; + } + + /** + * Checks to see if the cooldown for an item or ability is expired. + * + * @param oldTime The time the ability or item was last used + * @param cooldown The amount of time that must pass between uses + * @param player The player whose cooldown is being checked + * @return true if the cooldown is over, false otherwise + */ + public static boolean cooldownOver(long oldTime, int cooldown, Player player) { + long currentTime = System.currentTimeMillis(); + int adjustedCooldown = PerksUtils.handleCooldownPerks(player, cooldown); + + if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) { + return true; + } + + return false; + } + + /** + * Calculate the time remaining until the cooldown expires. + * + * @param deactivatedTimeStamp Time of deactivation + * @param cooldown The length of the cooldown + * @return the number of seconds remaining before the cooldown expires + */ + public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) { + return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR); + } + + /** + * Sends a message to the player when the cooldown expires. + * + * @param player The player to send a message to + * @param profile The profile of the player + * @param ability The ability to watch cooldowns for + */ + public static void watchCooldown(Player player, PlayerProfile profile, AbilityType ability) { + if (player == null || profile == null || ability == null) { + return; + } + + if (!profile.getAbilityInformed(ability) && cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { + profile.setAbilityInformed(ability, true); + player.sendMessage(ability.getAbilityRefresh()); + } + } + + /** + * Process activating abilities & readying the tool. + * + * @param player The player using the ability + * @param skill The skill the ability is tied to + */ + public static void activationCheck(Player player, SkillType skill) { + if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) { + return; + } + + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + AbilityType ability = skill.getAbility(); + ToolType tool = skill.getTool(); + ItemStack inHand = player.getItemInHand(); + + if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) { + return; + } + + /* Check if any abilities are active */ + if (profile == null) { + return; + } + + if (!profile.getAbilityUse()) { + return; + } + + for (AbilityType x : AbilityType.values()) { + if (profile.getAbilityMode(x)) { + return; + } + } + + /* + * Woodcutting & Axes need to be treated differently. + * Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action + */ + if (ability.getPermissions(player) && tool.inHand(inHand) && !profile.getToolPreparationMode(tool)) { + if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) { + if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { + player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); + return; + } + } + + if (Config.getInstance().getAbilityMessagesEnabled()) { + player.sendMessage(tool.getRaiseTool()); + } + + profile.setToolPreparationATS(tool, System.currentTimeMillis()); + profile.setToolPreparationMode(tool, true); + } + } + + /** + * Monitors various things relating to skill abilities. + * + * @param player The player using the skill + * @param profile The profile of the player + * @param curTime The current system time + * @param skill The skill being monitored + */ + public static void monitorSkill(Player player, PlayerProfile profile, long curTime, SkillType skill) { + final int FOUR_SECONDS = 4000; + + ToolType tool = skill.getTool(); + AbilityType ability = skill.getAbility(); + + if (profile == null) { + return; + } + + if (profile.getToolPreparationMode(tool) && curTime - (profile.getToolPreparationATS(tool) * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) { + profile.setToolPreparationMode(tool, false); + + if (Config.getInstance().getAbilityMessagesEnabled()) { + player.sendMessage(tool.getLowerTool()); + } + } + + if (ability.getPermissions(player)) { + if (profile.getAbilityMode(ability) && (profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) { + if (ability == AbilityType.BERSERK) { + player.setCanPickupItems(true); + } + else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) { + handleAbilitySpeedDecrease(player); + } + + profile.setAbilityMode(ability, false); + profile.setAbilityInformed(ability, false); + + ParticleEffectUtils.playAbilityDisabledEffect(player); + + if (profile.useChatNotifications()) { + player.sendMessage(ability.getAbilityOff()); + } + + sendSkillMessage(player, ability.getAbilityPlayerOff(player)); + } + } + } + + /** + * Check the XP of a skill. + * + * @param skillType The skill to check + * @param player The player whose skill to check + * @param profile The profile of the player whose skill to check + */ + public static void xpCheckSkill(SkillType skillType, Player player, PlayerProfile profile) { + int skillups = 0; + int xpRemoved = 0; + + if (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) { + + while (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) { + if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= UserManager.getPlayer(player).getPowerLevel() + 1)) { + int xp = profile.getXpToLevel(skillType); + xpRemoved += xp; + + profile.removeXp(skillType, xp); + skillups++; + profile.skillUp(skillType, 1); + } + else { + profile.addLevels(skillType, 0); + } + } + + McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType, skillups); + mcMMO.p.getServer().getPluginManager().callEvent(eventToFire); + + if (eventToFire.isCancelled()) { + profile.modifySkill(skillType, profile.getSkillLevel(skillType) - skillups); + profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + xpRemoved); + return; + } + + String capitalized = StringUtils.getCapitalized(skillType.toString()); + + /* Spout Stuff */ + if (mcMMO.spoutEnabled) { + SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); + + if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) { + SpoutUtils.levelUpNotification(skillType, spoutPlayer); + + /* Update custom titles */ + if (SpoutConfig.getInstance().getShowPowerLevel()) { + spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getName(), UserManager.getPlayer(player).getPowerLevel())); + } + } + else { + player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", skillups, profile.getSkillLevel(skillType))); + } + } + else { + player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", skillups, profile.getSkillLevel(skillType))); + } + } + + if (mcMMO.spoutEnabled) { + SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); + + if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) { + if (SpoutConfig.getInstance().getXPBarEnabled()) { + profile.getSpoutHud().updateXpBar(); + } + } + } + } + + /** + * Checks if the given string represents a valid skill + * + * @param skillName The name of the skill to check + * @return true if this is a valid skill, false otherwise + */ + public static boolean isSkill(String skillName) { + if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) { + return isLocalizedSkill(skillName); + } + + if (SkillType.getSkill(skillName) != null) { + return true; + } + + return false; + } + + private static boolean isLocalizedSkill(String skillName) { + for (SkillType skill : SkillType.values()) { + if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName"))) { + return true; + } + } + + return false; + } + + public static String getSkillName(SkillType skill) { + if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) { + return StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName")); + } + + return StringUtils.getCapitalized(skill.toString()); + } + + /** + * Check if the player has any combat skill permissions. + * + * @param player The player to check permissions for + * @return true if the player has combat skills, false otherwise + */ + public static boolean hasCombatSkills(Player player) { + if (Permissions.skillEnabled(player, SkillType.AXES) + || Permissions.skillEnabled(player, SkillType.ARCHERY) + || Permissions.skillEnabled(player, SkillType.SWORDS) + || Permissions.skillEnabled(player, SkillType.TAMING) + || Permissions.skillEnabled(player, SkillType.UNARMED)) { + return true; + } + + return false; + } + + /** + * Check if the player has any gathering skill permissions. + * + * @param player The player to check permissions for + * @return true if the player has gathering skills, false otherwise + */ + public static boolean hasGatheringSkills(Player player) { + if (Permissions.skillEnabled(player, SkillType.EXCAVATION) + || Permissions.skillEnabled(player, SkillType.FISHING) + || Permissions.skillEnabled(player, SkillType.HERBALISM) + || Permissions.skillEnabled(player, SkillType.MINING) + || Permissions.skillEnabled(player, SkillType.WOODCUTTING)) { + return true; + } + + return false; + } + + /** + * Check if the player has any misc skill permissions. + * + * @param player The player to check permissions for + * @return true if the player has misc skills, false otherwise + */ + public static boolean hasMiscSkills(Player player) { + if (Permissions.skillEnabled(player, SkillType.ACROBATICS) + || Permissions.skillEnabled(player, SkillType.SMELTING) + || Permissions.skillEnabled(player, SkillType.REPAIR)) { + return true; + } + + return false; + } + + /** + * Check to see if an ability can be activated. + * + * @param player The player activating the ability + * @param type The skill the ability is based on + */ + public static void abilityCheck(Player player, SkillType type) { + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + ToolType tool = type.getTool(); + AbilityType ability = type.getAbility(); + + profile.setToolPreparationMode(tool, false); + + /* + * Axes and Woodcutting are odd because they share the same tool. + * We show them the too tired message when they take action. + */ + if (type == SkillType.WOODCUTTING || type == SkillType.AXES) { + if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { + player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); + return; + } + } + + if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) { + int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks()); + + ParticleEffectUtils.playAbilityEnabledEffect(player); + + if (profile.useChatNotifications()) { + player.sendMessage(ability.getAbilityOn()); + } + + SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player)); + + profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); + profile.setAbilityMode(ability, true); + + if (ability == AbilityType.BERSERK) { + player.setCanPickupItems(false); + } + else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) { + handleAbilitySpeedIncrease(player); + } + } + } + + /** + * Check to see if ability should be triggered. + * + * @param player The player using the ability + * @param block The block modified by the ability + * @param ability The ability to check + * @return true if the ability should activate, false otherwise + */ + public static boolean triggerCheck(Player player, Block block, AbilityType ability) { + boolean activate = true; + + switch (ability) { + case BERSERK: + case LEAF_BLOWER: + if (!ability.blockCheck(block.getState())) { + activate = false; + break; + } + + if (!blockBreakSimulate(block, player, true)) { + activate = false; + break; + } + break; + + case GIGA_DRILL_BREAKER: + case SUPER_BREAKER: + case GREEN_TERRA: + if (!ability.blockCheck(block.getState())) { + activate = false; + break; + } + break; + + default: + activate = false; + break; + } + + return activate; + } + + public static void sendSkillMessage(Player player, String message) { + for (Player otherPlayer : player.getWorld().getPlayers()) { + if (otherPlayer != player && Misc.isNear(player.getLocation(), otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { + otherPlayer.sendMessage(message); + } + } + } + + /** + * Check if a skill level is higher than the max bonus level of the ability. + * + * @param skillLevel Skill level to check + * @param maxLevel Max level of the ability + * @return whichever value is lower + */ + public static int skillCheck(int skillLevel, int maxLevel) { + // TODO: Could we just use Math.min(skillLevel, maxLevel) here? + if (skillLevel > maxLevel) { + return maxLevel; + } + + return skillLevel; + } + + public static void handleAbilitySpeedIncrease(Player player) { + if (HiddenConfig.getInstance().useEnchantmentBuffs()) { + ItemStack heldItem = player.getItemInHand(); + + if (heldItem == null || heldItem.getType() == Material.AIR) { + return; + } + + int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED); + ItemMeta itemMeta = heldItem.getItemMeta(); + List itemLore = new ArrayList(); + + if (itemMeta.hasLore()) { + itemLore = itemMeta.getLore(); + } + + itemLore.add("mcMMO Ability Tool"); + itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + 5, true); + + itemMeta.setLore(itemLore); + heldItem.setItemMeta(itemMeta); + } + else { + int duration = 0; + int amplifier = 0; + + if (player.hasPotionEffect(PotionEffectType.FAST_DIGGING)) { + for (PotionEffect effect : player.getActivePotionEffects()) { + if (effect.getType() == PotionEffectType.FAST_DIGGING) { + duration = effect.getDuration(); + amplifier = effect.getAmplifier(); + break; + } + } + } + + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + int ticks = 0; + + if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) { + ticks = ((int) (profile.getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; + } + else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { + ticks = ((int) (profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; + } + + PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10); + player.addPotionEffect(abilityBuff, true); + } + } + + public static void handleAbilitySpeedDecrease(Player player) { + if (HiddenConfig.getInstance().useEnchantmentBuffs()) { + PlayerInventory playerInventory = player.getInventory(); + + for (int i = 0; i < playerInventory.getContents().length; i++) { + ItemStack item = playerInventory.getItem(i); + playerInventory.setItem(i, removeAbilityBuff(item)); + } + } + else { + player.removePotionEffect(PotionEffectType.FAST_DIGGING); + } + } + + public static ItemStack removeAbilityBuff(ItemStack item) { + if (item == null || item.getType() == Material.AIR) { + return item; + } + + if (!ItemUtils.isPickaxe(item) && !ItemUtils.isShovel(item)) { + return item; + } + + if (item.containsEnchantment(Enchantment.DIG_SPEED)) { + ItemMeta itemMeta = item.getItemMeta(); + + if (itemMeta.hasLore()) { + List itemLore = itemMeta.getLore(); + + if (itemLore.remove("mcMMO Ability Tool")) { + int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED); + + if (efficiencyLevel <= 5) { + itemMeta.removeEnchant(Enchantment.DIG_SPEED); + } + else { + itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - 5, true); + } + + itemMeta.setLore(itemLore); + item.setItemMeta(itemMeta); + } + } + } + + return item; + } + + /** + * Simulate a block break event. + * + * @param block The block to break + * @param player The player breaking the block + * @param shouldArmSwing true if an armswing event should be fired, false otherwise + * @return true if the event wasn't cancelled, false otherwise + */ + public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) { + PluginManager pluginManger = mcMMO.p.getServer().getPluginManager(); + + // Support for NoCheat + if (shouldArmSwing) { + pluginManger.callEvent(new FakePlayerAnimationEvent(player)); + } + + FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true); + pluginManger.callEvent(damageEvent); + + FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player); + pluginManger.callEvent(breakEvent); + + if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) { + return true; + } + + return false; + } + + public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) { + int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill); + int activationChance = PerksUtils.handleLuckyPerks(player, skill); + double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel); + + return chance > Misc.getRandom().nextInt(activationChance); + } + + public static boolean activationSuccessful(Player player, SkillType skill, double chance) { + return chance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, skill)); + } + + public static boolean unlockLevelReached(Player player, SkillType skill, int unlockLevel) { + return UserManager.getPlayer(player).getProfile().getSkillLevel(skill) > unlockLevel; + } + + public static boolean treasureDropSuccessful(double dropChance, int activationChance) { + return dropChance > Misc.getRandom().nextDouble() * activationChance; + } +} diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java b/src/main/java/com/gmail/nossr50/util/spout/SpoutSoundUtils.java similarity index 84% rename from src/main/java/com/gmail/nossr50/spout/SpoutSounds.java rename to src/main/java/com/gmail/nossr50/util/spout/SpoutSoundUtils.java index 82ce3fe77..ea5b34be5 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java +++ b/src/main/java/com/gmail/nossr50/util/spout/SpoutSoundUtils.java @@ -1,18 +1,17 @@ -package com.gmail.nossr50.spout; - -import org.bukkit.entity.Player; -import org.getspout.spoutapi.SpoutManager; - -import com.gmail.nossr50.mcMMO; - -public class SpoutSounds { - - /** - * Play noise on level-up. - * - * @param player The player who leveled up - */ - protected static void playLevelUpNoise(Player player, mcMMO plugin) { - SpoutManager.getSoundManager().playCustomSoundEffect(plugin, SpoutManager.getPlayer(player), "level.wav", false); - } -} +package com.gmail.nossr50.util.spout; + +import org.bukkit.entity.Player; +import org.getspout.spoutapi.SpoutManager; + +import com.gmail.nossr50.mcMMO; + +public class SpoutSoundUtils { + /** + * Play noise on level-up. + * + * @param player The player who leveled up + */ + protected static void playLevelUpNoise(Player player, mcMMO plugin) { + SpoutManager.getSoundManager().playCustomSoundEffect(plugin, SpoutManager.getPlayer(player), "level.wav", false); + } +} diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutTools.java b/src/main/java/com/gmail/nossr50/util/spout/SpoutUtils.java similarity index 53% rename from src/main/java/com/gmail/nossr50/spout/SpoutTools.java rename to src/main/java/com/gmail/nossr50/util/spout/SpoutUtils.java index 136e61084..5d0ea19c2 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutTools.java +++ b/src/main/java/com/gmail/nossr50/util/spout/SpoutUtils.java @@ -1,584 +1,586 @@ -package com.gmail.nossr50.spout; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.getspout.spoutapi.SpoutManager; -import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent; -import org.getspout.spoutapi.keyboard.Keyboard; -import org.getspout.spoutapi.player.FileManager; -import org.getspout.spoutapi.player.SpoutPlayer; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.Users; - -public class SpoutTools { - private static mcMMO plugin = mcMMO.p; - - public final static String spoutDirectory = mcMMO.getMainDirectory() + "Resources" + File.separator; - public final static String hudDirectory = spoutDirectory + "HUD" + File.separator; - public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator; - public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator; - public final static String soundDirectory = spoutDirectory + "Sound" + File.separator; - - public static boolean showPowerLevel; - - private final static SpoutListener spoutListener = new SpoutListener(); - public static Keyboard menuKey; - - /** - * Write file to disk. - * - * @param theFileName The name of the file - * @param theFilePath The name of the file path - */ - private static void writeFile(String theFileName, String theFilePath) { - InputStream is = null; - OutputStream os = null; - JarFile jar = null; - - try { - File currentFile = new File(theFilePath + theFileName); - - // No point in writing the file again if it already exists. - if (currentFile.exists()) { - return; - } - - jar = new JarFile(mcMMO.mcmmo); - JarEntry entry = jar.getJarEntry("resources/" + theFileName); - is = jar.getInputStream(entry); - - byte[] buf = new byte[2048]; - int nbRead; - - os = new BufferedOutputStream(new FileOutputStream(currentFile)); - - while ((nbRead = is.read(buf)) != -1) { - os.write(buf, 0, nbRead); - } - - os.flush(); - } - catch (FileNotFoundException e) { - e.printStackTrace(); - } - catch (IOException e) { - e.printStackTrace(); - } - finally { - if (is != null) { - try { - is.close(); - } - catch (IOException ex) { - ex.printStackTrace(); - } - } - if (os != null) { - try { - os.close(); - } - catch (IOException ex) { - ex.printStackTrace(); - } - } - - if (jar != null) { - try { - jar.close(); - } - catch (IOException ex) { - ex.printStackTrace(); - } - } - } - } - - /** - * Extract Spout files to the Resources directory. - */ - public static void extractFiles() { - // Setup directories - new File(spoutDirectory).mkdir(); - new File(hudDirectory).mkdir(); - new File(hudStandardDirectory).mkdir(); - new File(hudRetroDirectory).mkdir(); - new File(soundDirectory).mkdir(); - - // XP Bar images - for (int x = 0; x < 255; x++) { - String theFileName; - - if (x < 10) { - theFileName = "xpbar_inc00" + x + ".png"; - } - else if (x < 100) { - theFileName = "xpbar_inc0" + x + ".png"; - } - else { - theFileName = "xpbar_inc" + x + ".png"; - } - - writeFile(theFileName, hudStandardDirectory); - } - - // Standard XP Icons - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - String skillTypeString = StringUtils.getCapitalized(skillType.toString()); - - writeFile(skillTypeString + ".png", hudStandardDirectory); - writeFile(skillTypeString + "_r.png", hudRetroDirectory); - } - - // Blank icons - writeFile("Icon.png", hudStandardDirectory); - writeFile("Icon_r.png", hudRetroDirectory); - - // Sound FX - writeFile("level.wav", soundDirectory); - } - - /** - * Setup Spout config options - */ - public static void setupSpoutConfigs() { - showPowerLevel = SpoutConfig.getInstance().getShowPowerLevel(); - String temp = SpoutConfig.getInstance().getMenuKey(); - - for (Keyboard x : Keyboard.values()) { - if (x.toString().equalsIgnoreCase(temp)) { - menuKey = x; - } - } - - if (menuKey == null) { - mcMMO.p.getLogger().warning("Invalid KEY for Menu.Key, using KEY_M"); - menuKey = Keyboard.KEY_M; - } - } - - /** - * Get all the Spout files in the Resources folder. - * - * @return a list of all files is the Resources folder - */ - public static ArrayList getFiles() { - ArrayList files = new ArrayList(); - - // XP BAR - for (int x = 0; x < 255; x++) { - if (x < 10) { - files.add(new File(hudStandardDirectory + "xpbar_inc00" + x + ".png")); - } - else if (x < 100) { - files.add(new File(hudStandardDirectory + "xpbar_inc0" + x + ".png")); - } - else { - files.add(new File(hudStandardDirectory + "xpbar_inc" + x + ".png")); - } - } - - // Standard XP Icons - for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - String skillTypeString = StringUtils.getCapitalized(skillType.toString()); - - files.add(new File(hudStandardDirectory + skillTypeString + ".png")); - files.add(new File(hudRetroDirectory + skillTypeString + "_r.png")); - } - - // Blank icons - files.add(new File(hudStandardDirectory + "Icon.png")); - files.add(new File(hudRetroDirectory + "Icon_r.png")); - - // Level SFX - files.add(new File(soundDirectory + "level.wav")); - - return files; - } - - /** - * Register custom Spout events. - */ - public static void registerCustomEvent() { - plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin); - } - - /** - * Handle level-up notifications through Spout. - * - * @param skillType The skill that leveled up - * @param spoutPlayer The player that leveled up - */ - public static void levelUpNotification(SkillType skillType, SpoutPlayer spoutPlayer) { - PlayerProfile profile = Users.getPlayer(spoutPlayer).getProfile(); - int notificationTier = getNotificationTier(profile.getSkillLevel(skillType)); - Material mat = null; - - switch (skillType) { - case TAMING: - switch (notificationTier) { - case 1: - case 2: - mat = Material.PORK; - break; - - case 3: - case 4: - mat = Material.GRILLED_PORK; - break; - - case 5: - mat = Material.BONE; - break; - - default: - break; - } - - break; - - case MINING: - switch (notificationTier) { - case 1: - mat = Material.COAL_ORE; - break; - - case 2: - mat = Material.IRON_ORE; - break; - - case 3: - mat = Material.GOLD_ORE; - break; - - case 4: - mat = Material.DIAMOND_ORE; - break; - - case 5: - mat = Material.EMERALD_ORE; - break; - - default: - break; - } - - break; - - case WOODCUTTING: - switch (notificationTier) { - case 1: - mat = Material.STICK; - break; - - case 2: - case 3: - mat = Material.WOOD; - break; - - case 4: - case 5: - mat = Material.LOG; - break; - - default: - break; - } - - break; - - case REPAIR: - mat = Material.ANVIL; - break; - - case HERBALISM: - switch (notificationTier) { - case 1: - mat = Material.YELLOW_FLOWER; - break; - - case 2: - mat = Material.RED_ROSE; - break; - - case 3: - mat = Material.BROWN_MUSHROOM; - break; - - case 4: - mat = Material.RED_MUSHROOM; - break; - - case 5: - mat = Material.PUMPKIN; - break; - - default: - break; - } - - break; - - case ACROBATICS: - switch (notificationTier) { - case 1: - mat = Material.LEATHER_BOOTS; - break; - - case 2: - mat = Material.CHAINMAIL_BOOTS; - break; - - case 3: - mat = Material.IRON_BOOTS; - break; - - case 4: - mat = Material.GOLD_BOOTS; - break; - - case 5: - mat = Material.DIAMOND_BOOTS; - break; - - default: - break; - } - - break; - - case SWORDS: - switch (notificationTier) { - case 1: - mat = Material.WOOD_SWORD; - break; - - case 2: - mat = Material.STONE_SWORD; - break; - - case 3: - mat = Material.IRON_SWORD; - break; - - case 4: - mat = Material.GOLD_SWORD; - break; - - case 5: - mat = Material.DIAMOND_SWORD; - break; - - default: - break; - } - - break; - - case ARCHERY: - switch (notificationTier) { - case 1: - case 2: - case 3: - mat = Material.ARROW; - break; - - case 4: - case 5: - mat = Material.BOW; - break; - - default: - break; - } - - break; - - case UNARMED: - switch (notificationTier) { - case 1: - mat = Material.LEATHER_HELMET; - break; - - case 2: - mat = Material.CHAINMAIL_HELMET; - break; - - case 3: - mat = Material.IRON_HELMET; - break; - - case 4: - mat = Material.GOLD_HELMET; - break; - - case 5: - mat = Material.DIAMOND_HELMET; - break; - - default: - break; - } - - break; - - case EXCAVATION: - switch (notificationTier) { - case 1: - mat = Material.WOOD_SPADE; - break; - - case 2: - mat = Material.STONE_SPADE; - break; - - case 3: - mat = Material.IRON_SPADE; - break; - - case 4: - mat = Material.GOLD_SPADE; - break; - - case 5: - mat = Material.DIAMOND_SPADE; - break; - - default: - break; - } - - break; - - case AXES: - switch (notificationTier) { - case 1: - mat = Material.WOOD_AXE; - break; - - case 2: - mat = Material.STONE_AXE; - break; - - case 3: - mat = Material.IRON_AXE; - break; - - case 4: - mat = Material.GOLD_AXE; - break; - - case 5: - mat = Material.DIAMOND_AXE; - break; - - default: - break; - } - - break; - - case FISHING: - switch (notificationTier) { - case 1: - case 2: - mat = Material.RAW_FISH; - break; - - case 3: - case 4: - mat = Material.COOKED_FISH; - break; - - case 5: - mat = Material.FISHING_ROD; - break; - - default: - break; - } - - break; - - default: - mat = Material.WATCH; - break; - } - - spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", SkillTools.getSkillName(skillType), profile.getSkillLevel(skillType)), mat); - SpoutSounds.playLevelUpNoise(spoutPlayer, plugin); - } - - /** - * Gets the notification tier of a skill. - * - * @param level The level of the skill - * @return the notification tier of the skill - */ - private static int getNotificationTier(int level) { - if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier4()) { - return 5; - } - else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier3()) { - return 4; - } - else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier2()) { - return 3; - } - else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier1()) { - return 2; - } - else { - return 1; - } - } - - /** - * Re-enable SpoutCraft for players after a /reload - */ - public static void reloadSpoutPlayers() { - for (SpoutPlayer spoutPlayer : SpoutManager.getPlayerChunkMap().getOnlinePlayers()) { - mcMMO.p.getServer().getPluginManager().callEvent(new SpoutCraftEnableEvent(spoutPlayer)); - } - } - - public static void reloadSpoutPlayer(Player player) { - SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); - - if (spoutPlayer != null) { - mcMMO.p.getServer().getPluginManager().callEvent(new SpoutCraftEnableEvent(spoutPlayer)); - } - } - - public static void preCacheFiles() { - extractFiles(); //Extract source materials - - FileManager FM = SpoutManager.getFileManager(); - FM.addToPreLoginCache(plugin, getFiles()); - } -} +package com.gmail.nossr50.util.spout; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.getspout.spoutapi.SpoutManager; +import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent; +import org.getspout.spoutapi.keyboard.Keyboard; +import org.getspout.spoutapi.player.FileManager; +import org.getspout.spoutapi.player.SpoutPlayer; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.spout.SpoutConfig; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.listeners.SpoutListener; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class SpoutUtils { + private static mcMMO plugin = mcMMO.p; + + public final static String spoutDirectory = mcMMO.getMainDirectory() + "Resources" + File.separator; + public final static String hudDirectory = spoutDirectory + "HUD" + File.separator; + public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator; + public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator; + public final static String soundDirectory = spoutDirectory + "Sound" + File.separator; + + public static boolean showPowerLevel; + + private final static SpoutListener spoutListener = new SpoutListener(); + public static Keyboard menuKey; + + /** + * Write file to disk. + * + * @param theFileName The name of the file + * @param theFilePath The name of the file path + */ + private static void writeFile(String theFileName, String theFilePath) { + InputStream is = null; + OutputStream os = null; + JarFile jar = null; + + try { + File currentFile = new File(theFilePath + theFileName); + + // No point in writing the file again if it already exists. + if (currentFile.exists()) { + return; + } + + jar = new JarFile(mcMMO.mcmmo); + JarEntry entry = jar.getJarEntry("resources/" + theFileName); + is = jar.getInputStream(entry); + + byte[] buf = new byte[2048]; + int nbRead; + + os = new BufferedOutputStream(new FileOutputStream(currentFile)); + + while ((nbRead = is.read(buf)) != -1) { + os.write(buf, 0, nbRead); + } + + os.flush(); + } + catch (FileNotFoundException e) { + e.printStackTrace(); + } + catch (IOException e) { + e.printStackTrace(); + } + finally { + if (is != null) { + try { + is.close(); + } + catch (IOException ex) { + ex.printStackTrace(); + } + } + if (os != null) { + try { + os.close(); + } + catch (IOException ex) { + ex.printStackTrace(); + } + } + + if (jar != null) { + try { + jar.close(); + } + catch (IOException ex) { + ex.printStackTrace(); + } + } + } + } + + /** + * Extract Spout files to the Resources directory. + */ + public static void extractFiles() { + // Setup directories + new File(spoutDirectory).mkdir(); + new File(hudDirectory).mkdir(); + new File(hudStandardDirectory).mkdir(); + new File(hudRetroDirectory).mkdir(); + new File(soundDirectory).mkdir(); + + // XP Bar images + for (int x = 0; x < 255; x++) { + String theFileName; + + if (x < 10) { + theFileName = "xpbar_inc00" + x + ".png"; + } + else if (x < 100) { + theFileName = "xpbar_inc0" + x + ".png"; + } + else { + theFileName = "xpbar_inc" + x + ".png"; + } + + writeFile(theFileName, hudStandardDirectory); + } + + // Standard XP Icons + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + String skillTypeString = StringUtils.getCapitalized(skillType.toString()); + + writeFile(skillTypeString + ".png", hudStandardDirectory); + writeFile(skillTypeString + "_r.png", hudRetroDirectory); + } + + // Blank icons + writeFile("Icon.png", hudStandardDirectory); + writeFile("Icon_r.png", hudRetroDirectory); + + // Sound FX + writeFile("level.wav", soundDirectory); + } + + /** + * Setup Spout config options + */ + public static void setupSpoutConfigs() { + showPowerLevel = SpoutConfig.getInstance().getShowPowerLevel(); + String temp = SpoutConfig.getInstance().getMenuKey(); + + for (Keyboard x : Keyboard.values()) { + if (x.toString().equalsIgnoreCase(temp)) { + menuKey = x; + } + } + + if (menuKey == null) { + mcMMO.p.getLogger().warning("Invalid KEY for Menu.Key, using KEY_M"); + menuKey = Keyboard.KEY_M; + } + } + + /** + * Get all the Spout files in the Resources folder. + * + * @return a list of all files is the Resources folder + */ + public static ArrayList getFiles() { + ArrayList files = new ArrayList(); + + // XP BAR + for (int x = 0; x < 255; x++) { + if (x < 10) { + files.add(new File(hudStandardDirectory + "xpbar_inc00" + x + ".png")); + } + else if (x < 100) { + files.add(new File(hudStandardDirectory + "xpbar_inc0" + x + ".png")); + } + else { + files.add(new File(hudStandardDirectory + "xpbar_inc" + x + ".png")); + } + } + + // Standard XP Icons + for (SkillType skillType : SkillType.values()) { + if (skillType.isChildSkill()) { + continue; + } + + String skillTypeString = StringUtils.getCapitalized(skillType.toString()); + + files.add(new File(hudStandardDirectory + skillTypeString + ".png")); + files.add(new File(hudRetroDirectory + skillTypeString + "_r.png")); + } + + // Blank icons + files.add(new File(hudStandardDirectory + "Icon.png")); + files.add(new File(hudRetroDirectory + "Icon_r.png")); + + // Level SFX + files.add(new File(soundDirectory + "level.wav")); + + return files; + } + + /** + * Register custom Spout events. + */ + public static void registerCustomEvent() { + plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin); + } + + /** + * Handle level-up notifications through Spout. + * + * @param skillType The skill that leveled up + * @param spoutPlayer The player that leveled up + */ + public static void levelUpNotification(SkillType skillType, SpoutPlayer spoutPlayer) { + PlayerProfile profile = UserManager.getPlayer(spoutPlayer).getProfile(); + int notificationTier = getNotificationTier(profile.getSkillLevel(skillType)); + Material mat = null; + + switch (skillType) { + case TAMING: + switch (notificationTier) { + case 1: + case 2: + mat = Material.PORK; + break; + + case 3: + case 4: + mat = Material.GRILLED_PORK; + break; + + case 5: + mat = Material.BONE; + break; + + default: + break; + } + + break; + + case MINING: + switch (notificationTier) { + case 1: + mat = Material.COAL_ORE; + break; + + case 2: + mat = Material.IRON_ORE; + break; + + case 3: + mat = Material.GOLD_ORE; + break; + + case 4: + mat = Material.DIAMOND_ORE; + break; + + case 5: + mat = Material.EMERALD_ORE; + break; + + default: + break; + } + + break; + + case WOODCUTTING: + switch (notificationTier) { + case 1: + mat = Material.STICK; + break; + + case 2: + case 3: + mat = Material.WOOD; + break; + + case 4: + case 5: + mat = Material.LOG; + break; + + default: + break; + } + + break; + + case REPAIR: + mat = Material.ANVIL; + break; + + case HERBALISM: + switch (notificationTier) { + case 1: + mat = Material.YELLOW_FLOWER; + break; + + case 2: + mat = Material.RED_ROSE; + break; + + case 3: + mat = Material.BROWN_MUSHROOM; + break; + + case 4: + mat = Material.RED_MUSHROOM; + break; + + case 5: + mat = Material.PUMPKIN; + break; + + default: + break; + } + + break; + + case ACROBATICS: + switch (notificationTier) { + case 1: + mat = Material.LEATHER_BOOTS; + break; + + case 2: + mat = Material.CHAINMAIL_BOOTS; + break; + + case 3: + mat = Material.IRON_BOOTS; + break; + + case 4: + mat = Material.GOLD_BOOTS; + break; + + case 5: + mat = Material.DIAMOND_BOOTS; + break; + + default: + break; + } + + break; + + case SWORDS: + switch (notificationTier) { + case 1: + mat = Material.WOOD_SWORD; + break; + + case 2: + mat = Material.STONE_SWORD; + break; + + case 3: + mat = Material.IRON_SWORD; + break; + + case 4: + mat = Material.GOLD_SWORD; + break; + + case 5: + mat = Material.DIAMOND_SWORD; + break; + + default: + break; + } + + break; + + case ARCHERY: + switch (notificationTier) { + case 1: + case 2: + case 3: + mat = Material.ARROW; + break; + + case 4: + case 5: + mat = Material.BOW; + break; + + default: + break; + } + + break; + + case UNARMED: + switch (notificationTier) { + case 1: + mat = Material.LEATHER_HELMET; + break; + + case 2: + mat = Material.CHAINMAIL_HELMET; + break; + + case 3: + mat = Material.IRON_HELMET; + break; + + case 4: + mat = Material.GOLD_HELMET; + break; + + case 5: + mat = Material.DIAMOND_HELMET; + break; + + default: + break; + } + + break; + + case EXCAVATION: + switch (notificationTier) { + case 1: + mat = Material.WOOD_SPADE; + break; + + case 2: + mat = Material.STONE_SPADE; + break; + + case 3: + mat = Material.IRON_SPADE; + break; + + case 4: + mat = Material.GOLD_SPADE; + break; + + case 5: + mat = Material.DIAMOND_SPADE; + break; + + default: + break; + } + + break; + + case AXES: + switch (notificationTier) { + case 1: + mat = Material.WOOD_AXE; + break; + + case 2: + mat = Material.STONE_AXE; + break; + + case 3: + mat = Material.IRON_AXE; + break; + + case 4: + mat = Material.GOLD_AXE; + break; + + case 5: + mat = Material.DIAMOND_AXE; + break; + + default: + break; + } + + break; + + case FISHING: + switch (notificationTier) { + case 1: + case 2: + mat = Material.RAW_FISH; + break; + + case 3: + case 4: + mat = Material.COOKED_FISH; + break; + + case 5: + mat = Material.FISHING_ROD; + break; + + default: + break; + } + + break; + + default: + mat = Material.WATCH; + break; + } + + spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", SkillUtils.getSkillName(skillType), profile.getSkillLevel(skillType)), mat); + SpoutSoundUtils.playLevelUpNoise(spoutPlayer, plugin); + } + + /** + * Gets the notification tier of a skill. + * + * @param level The level of the skill + * @return the notification tier of the skill + */ + private static int getNotificationTier(int level) { + if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier4()) { + return 5; + } + else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier3()) { + return 4; + } + else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier2()) { + return 3; + } + else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier1()) { + return 2; + } + else { + return 1; + } + } + + /** + * Re-enable SpoutCraft for players after a /reload + */ + public static void reloadSpoutPlayers() { + for (SpoutPlayer spoutPlayer : SpoutManager.getPlayerChunkMap().getOnlinePlayers()) { + mcMMO.p.getServer().getPluginManager().callEvent(new SpoutCraftEnableEvent(spoutPlayer)); + } + } + + public static void reloadSpoutPlayer(Player player) { + SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); + + if (spoutPlayer != null) { + mcMMO.p.getServer().getPluginManager().callEvent(new SpoutCraftEnableEvent(spoutPlayer)); + } + } + + public static void preCacheFiles() { + extractFiles(); // Extract source materials + + FileManager FM = SpoutManager.getFileManager(); + FM.addToPreLoginCache(plugin, getFiles()); + } +} diff --git a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java index 2720051aa..6a0f0f135 100644 --- a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java +++ b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java @@ -41,12 +41,12 @@ public class ZipLibrary { mcMMO.p.getLogger().severe(e.toString()); } - //Generate the proper date for the backup filename + // Generate the proper date for the backup filename Date date = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); File fileZip = new File(BackupDirectory + File.separator + dateFormat.format(date) + ".zip"); - //Create the Source List, and add directories/etc to the file. + // Create the Source List, and add directories/etc to the file. List sources = new ArrayList(); if (!Config.getInstance().getUseMySQL()) { sources.add(FlatFileDirectory); @@ -65,7 +65,7 @@ public class ZipLibrary { sources.add(SpoutFile); } - //Actually do something + // Actually do something mcMMO.p.getLogger().info("Backing up your mcMMO Configuration... "); packZip(fileZip, sources); diff --git a/src/main/resources/armor.yml b/src/main/resources/armor.yml index 535ef722b..5e061a621 100644 --- a/src/main/resources/armor.yml +++ b/src/main/resources/armor.yml @@ -1,75 +1,75 @@ -# -# Settings for Boots -### -Boots: - Boot_1: - ID: 999 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Boot_2: - ID: 999 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - -# -# Settings for Chestplates -### -Chestplates: - Chestplate_1: - ID: 999 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Chestplate_2: - ID: 999 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - -# -# Settings for Helmets -### -Helmets: - Helmet_1: - ID: 999 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Helmet_2: - ID: 999 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - -# -# Settings for Leggings -### -Leggings: - Legging_1: - ID: 999 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Legging_2: - ID: 999 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 +# +# Settings for Boots +### +Boots: + Boot_1: + ID: 999 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Boot_2: + ID: 999 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + +# +# Settings for Chestplates +### +Chestplates: + Chestplate_1: + ID: 999 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Chestplate_2: + ID: 999 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + +# +# Settings for Helmets +### +Helmets: + Helmet_1: + ID: 999 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Helmet_2: + ID: 999 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + +# +# Settings for Leggings +### +Leggings: + Legging_1: + ID: 999 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Legging_2: + ID: 999 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 Durability: 9999 \ No newline at end of file diff --git a/src/main/resources/blocks.yml b/src/main/resources/blocks.yml index 12bb6b656..a2c3e1eb9 100644 --- a/src/main/resources/blocks.yml +++ b/src/main/resources/blocks.yml @@ -1,109 +1,109 @@ -# -# Settings for Custom Excavation Blocks -### -Excavation: - Block_1: - ID: 999 - Data_Value: 0 - XP_Gain: 99 - Drop_Item: false - Drop_Item_ID: 999 - Drop_Item_Data_Value: 0 - Min_Drop_Item_Amount: 1 - Max_Drop_Item_Amount: 1 - Block_2: - ID: 999 - Data_Value: 0 - XP_Gain: 99 - Drop_Item: false - Drop_Item_ID: 999 - Drop_Item_Data_Value: 0 - Min_Drop_Item_Amount: 1 - Max_Drop_Item_Amount: 1 - -# -# Settings for Custom Herbalism Blocks -### -Herbalism: - Block_1: - ID: 999 - Data_Value: 0 - XP_Gain: 99 - Drop_Item: false - Drop_Item_ID: 999 - Drop_Item_Data_Value: 0 - Min_Drop_Item_Amount: 1 - Max_Drop_Item_Amount: 1 - Block_2: - ID: 999 - Data_Value: 0 - XP_Gain: 99 - Drop_Item: false - Drop_Item_ID: 999 - Drop_Item_Data_Value: 0 - Min_Drop_Item_Amount: 1 - Max_Drop_Item_Amount: 1 - -# -# Settings for Custom Mining Blocks -### -Mining: - Block_1: - ID: 999 - Data_Value: 0 - XP_Gain: 99 - Is_Ore: true - Tier: 1 - Drop_Item: false - Drop_Item_ID: 999 - Drop_Item_Data_Value: 0 - Min_Drop_Item_Amount: 1 - Max_Drop_Item_Amount: 1 - Block_2: - ID: 999 - Data_Value: 0 - XP_Gain: 99 - Is_Ore: true - Tier: 1 - Drop_Item: false - Drop_Item_ID: 999 - Drop_Item_Data_Value: 0 - Min_Drop_Item_Amount: 1 - Max_Drop_Item_Amount: 1 - -# -# Settings for Custom Woodcutting Blocks -### -Woodcutting: - Block_1: - ID: 999 - Data_Value: 0 - XP_Gain: 99 - Is_Log: true - Drop_Item: false - Drop_Item_ID: 999 - Drop_Item_Data_Value: 0 - Min_Drop_Item_Amount: 1 - Max_Drop_Item_Amount: 1 - Block_2: - ID: 999 - Data_Value: 0 - XP_Gain: 99 - Is_Log: true - Drop_Item: false - Drop_Item_ID: 999 - Drop_Item_Data_Value: 0 - Min_Drop_Item_Amount: 1 - Max_Drop_Item_Amount: 1 - -# -# Settings for Custom Ability Blocks -# (These blocks don't trigger abilities) -### -Ability_Blocks: - Block_1: - ID: 999 - Data_Value: 0 - Block_2: - ID: 999 +# +# Settings for Custom Excavation Blocks +### +Excavation: + Block_1: + ID: 999 + Data_Value: 0 + XP_Gain: 99 + Drop_Item: false + Drop_Item_ID: 999 + Drop_Item_Data_Value: 0 + Min_Drop_Item_Amount: 1 + Max_Drop_Item_Amount: 1 + Block_2: + ID: 999 + Data_Value: 0 + XP_Gain: 99 + Drop_Item: false + Drop_Item_ID: 999 + Drop_Item_Data_Value: 0 + Min_Drop_Item_Amount: 1 + Max_Drop_Item_Amount: 1 + +# +# Settings for Custom Herbalism Blocks +### +Herbalism: + Block_1: + ID: 999 + Data_Value: 0 + XP_Gain: 99 + Drop_Item: false + Drop_Item_ID: 999 + Drop_Item_Data_Value: 0 + Min_Drop_Item_Amount: 1 + Max_Drop_Item_Amount: 1 + Block_2: + ID: 999 + Data_Value: 0 + XP_Gain: 99 + Drop_Item: false + Drop_Item_ID: 999 + Drop_Item_Data_Value: 0 + Min_Drop_Item_Amount: 1 + Max_Drop_Item_Amount: 1 + +# +# Settings for Custom Mining Blocks +### +Mining: + Block_1: + ID: 999 + Data_Value: 0 + XP_Gain: 99 + Is_Ore: true + Tier: 1 + Drop_Item: false + Drop_Item_ID: 999 + Drop_Item_Data_Value: 0 + Min_Drop_Item_Amount: 1 + Max_Drop_Item_Amount: 1 + Block_2: + ID: 999 + Data_Value: 0 + XP_Gain: 99 + Is_Ore: true + Tier: 1 + Drop_Item: false + Drop_Item_ID: 999 + Drop_Item_Data_Value: 0 + Min_Drop_Item_Amount: 1 + Max_Drop_Item_Amount: 1 + +# +# Settings for Custom Woodcutting Blocks +### +Woodcutting: + Block_1: + ID: 999 + Data_Value: 0 + XP_Gain: 99 + Is_Log: true + Drop_Item: false + Drop_Item_ID: 999 + Drop_Item_Data_Value: 0 + Min_Drop_Item_Amount: 1 + Max_Drop_Item_Amount: 1 + Block_2: + ID: 999 + Data_Value: 0 + XP_Gain: 99 + Is_Log: true + Drop_Item: false + Drop_Item_ID: 999 + Drop_Item_Data_Value: 0 + Min_Drop_Item_Amount: 1 + Max_Drop_Item_Amount: 1 + +# +# Settings for Custom Ability Blocks +# (These blocks don't trigger abilities) +### +Ability_Blocks: + Block_1: + ID: 999 + Data_Value: 0 + Block_2: + ID: 999 Data_Value: 0 \ No newline at end of file diff --git a/src/main/resources/entities.yml b/src/main/resources/entities.yml index 08886ad1b..afdc7e395 100644 --- a/src/main/resources/entities.yml +++ b/src/main/resources/entities.yml @@ -1,66 +1,66 @@ -# -# Settings for Hostile Mobs -### -Hostile: - Mob_1: - ID: 9999 - XP_Multiplier: 1.0 - Tameable: false - Taming_XP: 250 - CanBeSummoned: false - COTW_Material_ID: 999 - COTW_Material_Data: 9 - COTW_Material_Amount: 99 - Mob_2: - ID: 9999 - XP_Multiplier: 1.0 - Tameable: false - Taming_XP: 250 - CanBeSummoned: false - COTW_Material_ID: 999 - COTW_Material_Data: 9 - COTW_Material_Amount: 99 -# -# Settings for Neutral Mobs -### -Neutral: - Mob_1: - ID: 9999 - XP_Multiplier: 1.0 - Tameable: false - Taming_XP: 250 - CanBeSummoned: false - COTW_Material_ID: 999 - COTW_Material_Data: 9 - COTW_Material_Amount: 99 - Mob_2: - ID: 9999 - XP_Multiplier: 1.0 - Tameable: false - Taming_XP: 250 - CanBeSummoned: false - COTW_Material_ID: 999 - COTW_Material_Data: 9 - COTW_Material_Amount: 99 -# -# Settings for Passive Mobs -### -Passive: - Mob_1: - ID: 9999 - XP_Multiplier: 1.0 - Tameable: false - Taming_XP: 250 - CanBeSummoned: false - COTW_Material_ID: 999 - COTW_Material_Data: 9 - COTW_Material_Amount: 99 - Mob_2: - ID: 9999 - XP_Multiplier: 1.0 - Tameable: false - Taming_XP: 250 - CanBeSummoned: false - COTW_Material_ID: 999 - COTW_Material_Data: 9 +# +# Settings for Hostile Mobs +### +Hostile: + Mob_1: + ID: 9999 + XP_Multiplier: 1.0 + Tameable: false + Taming_XP: 250 + CanBeSummoned: false + COTW_Material_ID: 999 + COTW_Material_Data: 9 + COTW_Material_Amount: 99 + Mob_2: + ID: 9999 + XP_Multiplier: 1.0 + Tameable: false + Taming_XP: 250 + CanBeSummoned: false + COTW_Material_ID: 999 + COTW_Material_Data: 9 + COTW_Material_Amount: 99 +# +# Settings for Neutral Mobs +### +Neutral: + Mob_1: + ID: 9999 + XP_Multiplier: 1.0 + Tameable: false + Taming_XP: 250 + CanBeSummoned: false + COTW_Material_ID: 999 + COTW_Material_Data: 9 + COTW_Material_Amount: 99 + Mob_2: + ID: 9999 + XP_Multiplier: 1.0 + Tameable: false + Taming_XP: 250 + CanBeSummoned: false + COTW_Material_ID: 999 + COTW_Material_Data: 9 + COTW_Material_Amount: 99 +# +# Settings for Passive Mobs +### +Passive: + Mob_1: + ID: 9999 + XP_Multiplier: 1.0 + Tameable: false + Taming_XP: 250 + CanBeSummoned: false + COTW_Material_ID: 999 + COTW_Material_Data: 9 + COTW_Material_Amount: 99 + Mob_2: + ID: 9999 + XP_Multiplier: 1.0 + Tameable: false + Taming_XP: 250 + CanBeSummoned: false + COTW_Material_ID: 999 + COTW_Material_Data: 9 COTW_Material_Amount: 99 \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 99a00f362..30e71dcd6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,1508 +1,1508 @@ -name: mcMMO -version: ${project.version}-b${BUILD_NUMBER} -description: > - mcMMO takes core Minecraft game mechanics and expands them to add an extensive - RPG experience, the goal of the project has always been a quality RPG - experience. Everything in mcMMO is carefully thought out and is constantly - improving. mcMMO adds eleven skills to train in and level in, while also - offering a high level of customization for server admins. There are countless - features, including custom sounds, graphical elements, and more added when - running mcMMO in conjunction with Spout. I carefully read feedback and - evaluate the mechanics of mcMMO in every update to provide an ever-evolving - experience. - -author: nossr50 -authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1] -website: http://dev.bukkit.org/server-mods/mcmmo/ - -main: com.gmail.nossr50.mcMMO -softdepend: [Spout] -load: STARTUP - -commands: - mchud: - description: Change your HUD - xplock: - aliases: [mcxplock] - description: Lock your mcMMO XP bar - xprate: - aliases: [mcxprate] - description: Modify the xp rate or start an event - mcmmo: - description: Shows a brief mod description - mctop: - description: Show mcMMO leader boards - mcrank: - description: Show mcMMO ranking for a player - addxp: - description: Add mcMMO XP to a user - addlevels: - description: Add mcMMO levels to a user - mcability: - description: Toggle whether or not abilities get readied on right click - mcrefresh: - description: Refresh all cooldowns for mcMMO - mcgod: - description: Toggle mcMMO god-mode on/off - mcstats: - aliases: [stats] - description: Shows your mcMMO stats and xp - mcremove: - description: Remove a user from the database - mmoedit: - description: Edit the mcMMO skill values for a user - ptp: - description: Teleport to a party member - party: - description: Create/join a party - inspect: - description: View detailed mcMMO info on another player - mmoupdate: - description: Convert from Flat File to MySQL - partychat: - aliases: [pc, p] - description: Toggle Party chat or send party chat messages - skillreset: - description: Reset the level of one or all of your skills - excavation: - description: Detailed mcMMO skill info - herbalism: - description: Detailed mcMMO skill info - mining: - description: Detailed mcMMO skill info - woodcutting: - description: Detailed mcMMO skill info - axes: - description: Detailed mcMMO skill info - archery: - description: Detailed mcMMO skill info - swords: - description: Detailed mcMMO skill info - taming: - description: Detailed mcMMO skill info - unarmed: - description: Detailed mcMMO skill info - acrobatics: - description: Detailed mcMMO skill info - repair: - description: Detailed mcMMO skill info - fishing: - description: Detailed mcMMO skill info - smelting: - description: Detailed mcMMO skill info - adminchat: - aliases: [ac, a] - description: Toggle Admin chat or send admin chat messages - mcpurge: - description: Purge users with 0 powerlevel and/or who haven't connected in several months from the server DB. - hardcore: - aliases: [mchardcore] - description: Modify the mcMMO hardcore percentage or toggle hardcore mode on/off - vampirism: - aliases: [mcvampirism] - description: Modify the mcMMO vampirism percentage or toggle vampirism mode on/off - mcnotify: - aliases: [notify] - description: Toggle mcMMO abilities chat display notifications on/off -permissions: - mcmmo.*: - default: false - description: Implies all mcmmo permissions. - children: - mcmmo.all: true - mcmmo.all: - default: false - description: Implies all mcmmo permissions. - children: - mcmmo.admin: true - mcmmo.bypass.all: true - mcmmo.commands.all: true - mcmmo.defaults: true - mcmmo.defaultsop: true - mcmmo.party.all: true - mcmmo.perks.all: true - mcmmo.ability.*: - default: false - description: Implies all mcmmo.ability permissions. - children: - mcmmo.ability.all: true - mcmmo.ability.all: - default: false - description: Implies all mcmmo.ability permissions. - children: - mcmmo.ability.acrobatics.all: true - mcmmo.ability.archery.all: true - mcmmo.ability.axes.all: true - mcmmo.ability.excavation.all: true - mcmmo.ability.fishing.all: true - mcmmo.ability.herbalism.all: true - mcmmo.ability.mining.all: true - mcmmo.ability.repair.all: true - mcmmo.ability.smelting.all: true - mcmmo.ability.swords.all: true - mcmmo.ability.taming.all: true - mcmmo.ability.unarmed.all: true - mcmmo.ability.woodcutting.all: true - mcmmo.ability.acrobatics.*: - default: false - description: Allows access to all Acrobatics abilities - children: - mcmmo.ability.acrobatics.all: true - mcmmo.ability.acrobatics.all: - description: Allows access to all Acrobatics abilities - children: - mcmmo.ability.acrobatics.dodge: true - mcmmo.ability.acrobatics.gracefulroll: true - mcmmo.ability.acrobatics.roll: true - mcmmo.ability.acrobatics.dodge: - description: Allows access to the Dodge ability - mcmmo.ability.acrobatics.gracefulroll: - description: Allows access to the Graceful Roll ability - mcmmo.ability.acrobatics.roll: - description: Allows access to the Roll ability - mcmmo.ability.archery.*: - default: false - description: Allows access to all Archery abilities - children: - mcmmo.ability.archery.all: true - mcmmo.ability.archery.all: - description: Allows access to all Archery abilities - children: - mcmmo.ability.archery.bonusdamage: true - mcmmo.ability.archery.daze: true - mcmmo.ability.archery.trackarrows: true - mcmmo.ability.archery.bonusdamage: - description: Allows bonus damage from Archery - mcmmo.ability.archery.daze: - description: Allows access to the Daze ability - mcmmo.ability.archery.trackarrows: - description: Allows tracking & retrieval of arrows - mcmmo.ability.axes.*: - default: false - description: Allows access to all Axes abilities - children: - mcmmo.ability.axes.all: true - mcmmo.ability.axes.all: - description: Allows access to all Axes abilities - children: - mcmmo.ability.axes.bonusdamage: true - mcmmo.ability.axes.criticalhit: true - mcmmo.ability.axes.greaterimpact: true - mcmmo.ability.axes.impact: true - mcmmo.ability.axes.skullsplitter: true - mcmmo.ability.axes.bonusdamage: - description: Allows bonus damage from Axes - mcmmo.ability.axes.criticalhit: - description: Allows access to the Critical Hit ability - mcmmo.ability.axes.greaterimpact: - description: Allows access to the Greater Impact ability - mcmmo.ability.axes.impact: - description: Allows access to the Impact ability - mcmmo.ability.axes.skullsplitter: - description: Allows access to the Skull Splitter ability - mcmmo.ability.blastmining.*: - default: false - description: Allows access to all Blast Mining abilities - children: - mcmmo.ability.blastmining.all: true - mcmmo.ability.blastmining.all: - default: false - description: Allows access to all Blast Mining abilities - children: - mcmmo.ability.blastmining.biggerbombs: true - mcmmo.ability.blastmining.demolitionsexpertise: true - mcmmo.ability.blastmining.detonate: true - mcmmo.ability.blastmining.biggerbombs: - default: false - description: Allows access to the Bigger Bombs ability - children: - mcmmo.ability.mining.blastmining.biggerbombs: true - mcmmo.ability.blastmining.demolitionsexpertise: - default: false - description: Allows access to the Demolitions Expertise ability - children: - mcmmo.ability.mining.blastmining.demolitionsexpertise: true - mcmmo.ability.blastmining.detonate: - default: false - description: Allows for remote TNT detonation - children: - mcmmo.ability.mining.blastmining.detonate: true - mcmmo.ability.excavation.*: - default: false - description: Allows access to all Excavation abilities - children: - mcmmo.ability.excavation.all: true - mcmmo.ability.excavation.all: - description: Allows access to all Excavation abilities - children: - mcmmo.ability.excavation.gigadrillbreaker: true - mcmmo.ability.excavation.treasures: true - mcmmo.ability.excavation.gigadrillbreaker: - description: Allows access to the Giga Drill Breaker ability - mcmmo.ability.excavation.treasures: - description: Allows treasure drops from Excavation - mcmmo.ability.fishing.*: - default: false - description: Allows access to all Fishing abilities - children: - mcmmo.ability.fishing.all: true - mcmmo.ability.fishing.all: - description: Allows access to all Fishing abilities - children: - mcmmo.ability.fishing.fishermansdiet: true - mcmmo.ability.fishing.magic: true - mcmmo.ability.fishing.shakemob: true - mcmmo.ability.fishing.treasures: true - mcmmo.ability.fishing.vanillaxpboost: true - mcmmo.ability.fishing.fishermansdiet: - description: Allows access to the Fishermans's Diet ability - mcmmo.ability.fishing.magic: - description: Allows enchanted drops from Fishing - mcmmo.ability.fishing.shakemob: - description: Allows access to the Shake Mob ability - mcmmo.ability.fishing.treasures: - description: Allows treasure drops from Fishing - mcmmo.ability.fishing.vanillaxpboost: - description: Allows vanilla XP boost from Fishing - mcmmo.ability.herbalism.*: - default: false - description: Allows access to all Herbalism abilities - children: - mcmmo.ability.herbalism.all: true - mcmmo.ability.herbalism.all: - description: Allows access to all Herbalism abilities - children: - mcmmo.ability.herbalism.doubledrops: true - mcmmo.ability.herbalism.farmersdiet: true - mcmmo.ability.herbalism.greenterra: true - mcmmo.ability.herbalism.greenthumb.all: true - mcmmo.ability.herbalism.hylianluck: true - mcmmo.ability.herbalism.shroomthumb: true - mcmmo.ability.herbalism.doubledrops: - description: Allows double drop chance from Herbalism - mcmmo.ability.herbalism.farmersdiet: - description: Allows access to the Farmer's Diet ability - mcmmo.ability.herbalism.greenterra: - description: Allows access to the Green Terra ability - mcmmo.ability.herbalism.greenthumb.*: - default: false - description: Allows access to all Green Thumb abilities - children: - mcmmo.ability.herbalism.greenthumb.all: true - mcmmo.ability.herbalism.greenthumb.all: - description: Allows access to all Green Thumb abilities for blocks - children: - mcmmo.ability.herbalism.greenthumb.blocks.all: true - mcmmo.ability.herbalism.greenthumb.plants.all: true - mcmmo.ability.herbalism.greenthumb.blocks.*: - default: false - description: Allows access to all Green Thumb abilities for blocks - children: - mcmmo.ability.herbalism.greenthumb.blocks.all: true - mcmmo.ability.herbalism.greenthumb.blocks.all: - description: Allows access to all Green Thumb abilities for blocks - children: - mcmmo.ability.herbalism.greenthumb.blocks.cobblestone: true - mcmmo.ability.herbalism.greenthumb.blocks.cobblewall: true - mcmmo.ability.herbalism.greenthumb.blocks.dirt: true - mcmmo.ability.herbalism.greenthumb.blocks.smoothbrick: true - mcmmo.ability.herbalism.greenthumb.blocks.cobblestone: - description: Allows access to the Green Thumb ability for cobblestone - mcmmo.ability.herbalism.greenthumb.blocks.cobblewall: - description: Allows access to the Green Thumb ability for cobblestone walls - mcmmo.ability.herbalism.greenthumb.blocks.dirt: - description: Allows access to the Green Thumb ability for dirt - mcmmo.ability.herbalism.greenthumb.blocks.smoothbrick: - description: Allows access to the Green Thumb ability for smooth brick - mcmmo.ability.herbalism.greenthumb.plants.*: - default: false - description: Allows access to all Green Thumb abilities for plants - children: - mcmmo.ability.herbalism.greenthumb.plants.all: true - mcmmo.ability.herbalism.greenthumb.plants.all: - description: Allows access to all Green Thumb abilities for plants - children: - mcmmo.ability.herbalism.greenthumb.plants.carrot: true - mcmmo.ability.herbalism.greenthumb.plants.cocoa: true - mcmmo.ability.herbalism.greenthumb.plants.crops: true - mcmmo.ability.herbalism.greenthumb.plants.netherwarts: true - mcmmo.ability.herbalism.greenthumb.plants.potato: true - mcmmo.ability.herbalism.greenthumb.plants.carrot: - description: Allows access to the Green Thumb ability for carrots - mcmmo.ability.herbalism.greenthumb.plants.cocoa: - description: Allows access to the Green Thumb ability for cocoa - mcmmo.ability.herbalism.greenthumb.plants.crops: - description: Allows access to the Green Thumb ability for wheat - mcmmo.ability.herbalism.greenthumb.plants.netherwarts: - description: Allows access to the Green Thumb ability for netherwart - mcmmo.ability.herbalism.greenthumb.plants.potato: - description: Allows access to the Green Thumb ability for potatoes - mcmmo.ability.herbalism.greenthumbblocks: - default: false - description: Allows access to all Green Thumb abilities for blocks - children: - mcmmo.ability.herbalism.greenthumb.blocks.all: true - mcmmo.ability.herbalism.greenthumbcarrots: - default: false - description: Allows access to the Green Thumb ability for carrots - children: - mcmmo.ability.herbalism.greenthumb.plants.carrot: true - mcmmo.ability.herbalism.greenthumbcocoa: - default: false - description: Allows access to the Green Thumb ability for cocoa - children: - mcmmo.ability.herbalism.greenthumb.plants.cocoa: true - mcmmo.ability.herbalism.greenthumbnetherwart: - default: false - description: Allows access to the Green Thumb ability for netherwart - children: - mcmmo.ability.herbalism.greenthumb.plants.netherwarts: true - mcmmo.ability.herbalism.greenthumbpotatoes: - default: false - description: Allows access to the Green Thumb ability for potatoes - children: - mcmmo.ability.herbalism.greenthumb.plants.potato: true - mcmmo.ability.herbalism.greenthumbwheat: - default: false - description: Allows access to the Green Thumb ability for wheat - children: - mcmmo.ability.herbalism.greenthumb.plants.crops: true - mcmmo.ability.herbalism.hylianluck: - description: Allows access to the Hylian Luck ability - mcmmo.ability.herbalism.shroomthumb: - description: Allows access to the Shroom Thumb ability - mcmmo.ability.mining.*: - default: false - description: Allows access to all Mining abilities - children: - mcmmo.ability.mining.all: true - mcmmo.ability.mining.all: - description: Allows access to all Mining abilities - children: - mcmmo.ability.mining.blastmining.all: true - mcmmo.ability.mining.doubledrops: true - mcmmo.ability.mining.superbreaker: true - mcmmo.ability.mining.blastmining.*: - default: false - description: Allows access to all Blast Mining abilities - children: - mcmmo.ability.mining.blastmining.all: true - mcmmo.ability.mining.blastmining.all: - description: Allows access to all Blast Mining abilities - children: - mcmmo.ability.mining.blastmining.biggerbombs: true - mcmmo.ability.mining.blastmining.demolitionsexpertise: true - mcmmo.ability.mining.blastmining.detonate: true - mcmmo.ability.mining.blastmining.biggerbombs: - description: Allows access to the Bigger Bombs ability - mcmmo.ability.mining.blastmining.demolitionsexpertise: - description: Allows access to the Demolitions Expertise ability - mcmmo.ability.mining.blastmining.detonate: - description: Allows for remote TNT detonation - mcmmo.ability.mining.doubledrops: - description: Allows double drop chance when mining - mcmmo.ability.mining.superbreaker: - description: Allows access to the Super Breaker ability - mcmmo.ability.repair.*: - default: false - description: Allows access to all Repair abilities - children: - mcmmo.ability.repair.all: true - mcmmo.ability.repair.all: - description: Allows access to all Repair abilities - children: - mcmmo.ability.repair.arcaneforging: true - mcmmo.ability.repair.armorrepair: true - mcmmo.ability.repair.diamondrepair: true - mcmmo.ability.repair.goldrepair: true - mcmmo.ability.repair.ironrepair: true - mcmmo.ability.repair.leatherrepair: true - mcmmo.ability.repair.othermaterialrepair: true - mcmmo.ability.repair.otherrepair: true - mcmmo.ability.repair.repairbonus: true - mcmmo.ability.repair.repairmastery: true - mcmmo.ability.repair.salvage: true - mcmmo.ability.repair.stonerepair: true - mcmmo.ability.repair.stringrepair: true - mcmmo.ability.repair.toolrepair: true - mcmmo.ability.repair.woodrepair: true - mcmmo.ability.repair.arcaneforging: - description: Allows access to the Arcane Forging ability - mcmmo.ability.repair.armorrepair: - description: Allows ability to repair armor - mcmmo.ability.repair.diamondrepair: - description: Allows ability to repair Diamond tools & armor - mcmmo.ability.repair.goldrepair: - description: Allows ability to repair Gold tools & armor - mcmmo.ability.repair.ironrepair: - description: Allows ability to repair Iron tools & armor - mcmmo.ability.repair.leatherrepair: - description: Allows ability to repair Leather armor - mcmmo.ability.repair.othermaterialrepair: - description: Allows ability to repair items of material type OTHER - mcmmo.ability.repair.otherrepair: - description: Allows ability to repair items of type OTHER - mcmmo.ability.repair.repairbonus: - description: Allows access to Super Repair bonus - mcmmo.ability.repair.repairmastery: - description: Allows access to Repair Mastery - mcmmo.ability.repair.salvage: - description: Allows access to the Salvage ability - mcmmo.ability.repair.stonerepair: - description: Allows ability to repair Stone tools - mcmmo.ability.repair.stringrepair: - description: Allows ability to repair Bow and Fishing rod - mcmmo.ability.repair.toolrepair: - description: Allows ability to repair tools - mcmmo.ability.repair.woodrepair: - description: Allows ability to repair Wood tools - mcmmo.ability.smelting.*: - default: false - description: Allows access to all Smelting abilities - children: - mcmmo.ability.smelting.all: true - mcmmo.ability.smelting.all: - description: Allows access to all Smelting abilities - children: - mcmmo.ability.smelting.doubledrops: true - mcmmo.ability.smelting.fluxmining: true - mcmmo.ability.smelting.fuelefficiency: true - mcmmo.ability.smelting.vanillaxpboost: true - mcmmo.ability.smelting.doubledrops: - description: Allows access to the Second Smelt ability - mcmmo.ability.smelting.fluxmining: - description: Allows access to the Flux Mining ability - mcmmo.ability.smelting.fuelefficiency: - description: Allows access to the Fuel Efficiency ability - mcmmo.ability.smelting.secondsmelt: - default: false - description: Allows access to the Second Smelt ability - children: - mcmmo.ability.smelting.doubledrops: true - mcmmo.ability.smelting.vanillaxpboost: +name: mcMMO +version: ${project.version}-b${BUILD_NUMBER} +description: > + mcMMO takes core Minecraft game mechanics and expands them to add an extensive + RPG experience, the goal of the project has always been a quality RPG + experience. Everything in mcMMO is carefully thought out and is constantly + improving. mcMMO adds eleven skills to train in and level in, while also + offering a high level of customization for server admins. There are countless + features, including custom sounds, graphical elements, and more added when + running mcMMO in conjunction with Spout. I carefully read feedback and + evaluate the mechanics of mcMMO in every update to provide an ever-evolving + experience. + +author: nossr50 +authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1] +website: http://dev.bukkit.org/server-mods/mcmmo/ + +main: com.gmail.nossr50.mcMMO +softdepend: [Spout] +load: STARTUP + +commands: + mchud: + description: Change your HUD + xplock: + aliases: [mcxplock] + description: Lock your mcMMO XP bar + xprate: + aliases: [mcxprate] + description: Modify the xp rate or start an event + mcmmo: + description: Shows a brief mod description + mctop: + description: Show mcMMO leader boards + mcrank: + description: Show mcMMO ranking for a player + addxp: + description: Add mcMMO XP to a user + addlevels: + description: Add mcMMO levels to a user + mcability: + description: Toggle whether or not abilities get readied on right click + mcrefresh: + description: Refresh all cooldowns for mcMMO + mcgod: + description: Toggle mcMMO god-mode on/off + mcstats: + aliases: [stats] + description: Shows your mcMMO stats and xp + mcremove: + description: Remove a user from the database + mmoedit: + description: Edit the mcMMO skill values for a user + ptp: + description: Teleport to a party member + party: + description: Create/join a party + inspect: + description: View detailed mcMMO info on another player + mmoupdate: + description: Convert from Flat File to MySQL + partychat: + aliases: [pc, p] + description: Toggle Party chat or send party chat messages + skillreset: + description: Reset the level of one or all of your skills + excavation: + description: Detailed mcMMO skill info + herbalism: + description: Detailed mcMMO skill info + mining: + description: Detailed mcMMO skill info + woodcutting: + description: Detailed mcMMO skill info + axes: + description: Detailed mcMMO skill info + archery: + description: Detailed mcMMO skill info + swords: + description: Detailed mcMMO skill info + taming: + description: Detailed mcMMO skill info + unarmed: + description: Detailed mcMMO skill info + acrobatics: + description: Detailed mcMMO skill info + repair: + description: Detailed mcMMO skill info + fishing: + description: Detailed mcMMO skill info + smelting: + description: Detailed mcMMO skill info + adminchat: + aliases: [ac, a] + description: Toggle Admin chat or send admin chat messages + mcpurge: + description: Purge users with 0 powerlevel and/or who haven't connected in several months from the server DB. + hardcore: + aliases: [mchardcore] + description: Modify the mcMMO hardcore percentage or toggle hardcore mode on/off + vampirism: + aliases: [mcvampirism] + description: Modify the mcMMO vampirism percentage or toggle vampirism mode on/off + mcnotify: + aliases: [notify] + description: Toggle mcMMO abilities chat display notifications on/off +permissions: + mcmmo.*: + default: false + description: Implies all mcmmo permissions. + children: + mcmmo.all: true + mcmmo.all: + default: false + description: Implies all mcmmo permissions. + children: + mcmmo.admin: true + mcmmo.bypass.all: true + mcmmo.commands.all: true + mcmmo.defaults: true + mcmmo.defaultsop: true + mcmmo.party.all: true + mcmmo.perks.all: true + mcmmo.ability.*: + default: false + description: Implies all mcmmo.ability permissions. + children: + mcmmo.ability.all: true + mcmmo.ability.all: + default: false + description: Implies all mcmmo.ability permissions. + children: + mcmmo.ability.acrobatics.all: true + mcmmo.ability.archery.all: true + mcmmo.ability.axes.all: true + mcmmo.ability.excavation.all: true + mcmmo.ability.fishing.all: true + mcmmo.ability.herbalism.all: true + mcmmo.ability.mining.all: true + mcmmo.ability.repair.all: true + mcmmo.ability.smelting.all: true + mcmmo.ability.swords.all: true + mcmmo.ability.taming.all: true + mcmmo.ability.unarmed.all: true + mcmmo.ability.woodcutting.all: true + mcmmo.ability.acrobatics.*: + default: false + description: Allows access to all Acrobatics abilities + children: + mcmmo.ability.acrobatics.all: true + mcmmo.ability.acrobatics.all: + description: Allows access to all Acrobatics abilities + children: + mcmmo.ability.acrobatics.dodge: true + mcmmo.ability.acrobatics.gracefulroll: true + mcmmo.ability.acrobatics.roll: true + mcmmo.ability.acrobatics.dodge: + description: Allows access to the Dodge ability + mcmmo.ability.acrobatics.gracefulroll: + description: Allows access to the Graceful Roll ability + mcmmo.ability.acrobatics.roll: + description: Allows access to the Roll ability + mcmmo.ability.archery.*: + default: false + description: Allows access to all Archery abilities + children: + mcmmo.ability.archery.all: true + mcmmo.ability.archery.all: + description: Allows access to all Archery abilities + children: + mcmmo.ability.archery.bonusdamage: true + mcmmo.ability.archery.daze: true + mcmmo.ability.archery.trackarrows: true + mcmmo.ability.archery.bonusdamage: + description: Allows bonus damage from Archery + mcmmo.ability.archery.daze: + description: Allows access to the Daze ability + mcmmo.ability.archery.trackarrows: + description: Allows tracking & retrieval of arrows + mcmmo.ability.axes.*: + default: false + description: Allows access to all Axes abilities + children: + mcmmo.ability.axes.all: true + mcmmo.ability.axes.all: + description: Allows access to all Axes abilities + children: + mcmmo.ability.axes.bonusdamage: true + mcmmo.ability.axes.criticalhit: true + mcmmo.ability.axes.greaterimpact: true + mcmmo.ability.axes.impact: true + mcmmo.ability.axes.skullsplitter: true + mcmmo.ability.axes.bonusdamage: + description: Allows bonus damage from Axes + mcmmo.ability.axes.criticalhit: + description: Allows access to the Critical Hit ability + mcmmo.ability.axes.greaterimpact: + description: Allows access to the Greater Impact ability + mcmmo.ability.axes.impact: + description: Allows access to the Impact ability + mcmmo.ability.axes.skullsplitter: + description: Allows access to the Skull Splitter ability + mcmmo.ability.blastmining.*: + default: false + description: Allows access to all Blast Mining abilities + children: + mcmmo.ability.blastmining.all: true + mcmmo.ability.blastmining.all: + default: false + description: Allows access to all Blast Mining abilities + children: + mcmmo.ability.blastmining.biggerbombs: true + mcmmo.ability.blastmining.demolitionsexpertise: true + mcmmo.ability.blastmining.detonate: true + mcmmo.ability.blastmining.biggerbombs: + default: false + description: Allows access to the Bigger Bombs ability + children: + mcmmo.ability.mining.blastmining.biggerbombs: true + mcmmo.ability.blastmining.demolitionsexpertise: + default: false + description: Allows access to the Demolitions Expertise ability + children: + mcmmo.ability.mining.blastmining.demolitionsexpertise: true + mcmmo.ability.blastmining.detonate: + default: false + description: Allows for remote TNT detonation + children: + mcmmo.ability.mining.blastmining.detonate: true + mcmmo.ability.excavation.*: + default: false + description: Allows access to all Excavation abilities + children: + mcmmo.ability.excavation.all: true + mcmmo.ability.excavation.all: + description: Allows access to all Excavation abilities + children: + mcmmo.ability.excavation.gigadrillbreaker: true + mcmmo.ability.excavation.treasures: true + mcmmo.ability.excavation.gigadrillbreaker: + description: Allows access to the Giga Drill Breaker ability + mcmmo.ability.excavation.treasures: + description: Allows treasure drops from Excavation + mcmmo.ability.fishing.*: + default: false + description: Allows access to all Fishing abilities + children: + mcmmo.ability.fishing.all: true + mcmmo.ability.fishing.all: + description: Allows access to all Fishing abilities + children: + mcmmo.ability.fishing.fishermansdiet: true + mcmmo.ability.fishing.magic: true + mcmmo.ability.fishing.shakemob: true + mcmmo.ability.fishing.treasures: true + mcmmo.ability.fishing.vanillaxpboost: true + mcmmo.ability.fishing.fishermansdiet: + description: Allows access to the Fishermans's Diet ability + mcmmo.ability.fishing.magic: + description: Allows enchanted drops from Fishing + mcmmo.ability.fishing.shakemob: + description: Allows access to the Shake Mob ability + mcmmo.ability.fishing.treasures: + description: Allows treasure drops from Fishing + mcmmo.ability.fishing.vanillaxpboost: + description: Allows vanilla XP boost from Fishing + mcmmo.ability.herbalism.*: + default: false + description: Allows access to all Herbalism abilities + children: + mcmmo.ability.herbalism.all: true + mcmmo.ability.herbalism.all: + description: Allows access to all Herbalism abilities + children: + mcmmo.ability.herbalism.doubledrops: true + mcmmo.ability.herbalism.farmersdiet: true + mcmmo.ability.herbalism.greenterra: true + mcmmo.ability.herbalism.greenthumb.all: true + mcmmo.ability.herbalism.hylianluck: true + mcmmo.ability.herbalism.shroomthumb: true + mcmmo.ability.herbalism.doubledrops: + description: Allows double drop chance from Herbalism + mcmmo.ability.herbalism.farmersdiet: + description: Allows access to the Farmer's Diet ability + mcmmo.ability.herbalism.greenterra: + description: Allows access to the Green Terra ability + mcmmo.ability.herbalism.greenthumb.*: + default: false + description: Allows access to all Green Thumb abilities + children: + mcmmo.ability.herbalism.greenthumb.all: true + mcmmo.ability.herbalism.greenthumb.all: + description: Allows access to all Green Thumb abilities for blocks + children: + mcmmo.ability.herbalism.greenthumb.blocks.all: true + mcmmo.ability.herbalism.greenthumb.plants.all: true + mcmmo.ability.herbalism.greenthumb.blocks.*: + default: false + description: Allows access to all Green Thumb abilities for blocks + children: + mcmmo.ability.herbalism.greenthumb.blocks.all: true + mcmmo.ability.herbalism.greenthumb.blocks.all: + description: Allows access to all Green Thumb abilities for blocks + children: + mcmmo.ability.herbalism.greenthumb.blocks.cobblestone: true + mcmmo.ability.herbalism.greenthumb.blocks.cobblewall: true + mcmmo.ability.herbalism.greenthumb.blocks.dirt: true + mcmmo.ability.herbalism.greenthumb.blocks.smoothbrick: true + mcmmo.ability.herbalism.greenthumb.blocks.cobblestone: + description: Allows access to the Green Thumb ability for cobblestone + mcmmo.ability.herbalism.greenthumb.blocks.cobblewall: + description: Allows access to the Green Thumb ability for cobblestone walls + mcmmo.ability.herbalism.greenthumb.blocks.dirt: + description: Allows access to the Green Thumb ability for dirt + mcmmo.ability.herbalism.greenthumb.blocks.smoothbrick: + description: Allows access to the Green Thumb ability for smooth brick + mcmmo.ability.herbalism.greenthumb.plants.*: + default: false + description: Allows access to all Green Thumb abilities for plants + children: + mcmmo.ability.herbalism.greenthumb.plants.all: true + mcmmo.ability.herbalism.greenthumb.plants.all: + description: Allows access to all Green Thumb abilities for plants + children: + mcmmo.ability.herbalism.greenthumb.plants.carrot: true + mcmmo.ability.herbalism.greenthumb.plants.cocoa: true + mcmmo.ability.herbalism.greenthumb.plants.crops: true + mcmmo.ability.herbalism.greenthumb.plants.netherwarts: true + mcmmo.ability.herbalism.greenthumb.plants.potato: true + mcmmo.ability.herbalism.greenthumb.plants.carrot: + description: Allows access to the Green Thumb ability for carrots + mcmmo.ability.herbalism.greenthumb.plants.cocoa: + description: Allows access to the Green Thumb ability for cocoa + mcmmo.ability.herbalism.greenthumb.plants.crops: + description: Allows access to the Green Thumb ability for wheat + mcmmo.ability.herbalism.greenthumb.plants.netherwarts: + description: Allows access to the Green Thumb ability for netherwart + mcmmo.ability.herbalism.greenthumb.plants.potato: + description: Allows access to the Green Thumb ability for potatoes + mcmmo.ability.herbalism.greenthumbblocks: + default: false + description: Allows access to all Green Thumb abilities for blocks + children: + mcmmo.ability.herbalism.greenthumb.blocks.all: true + mcmmo.ability.herbalism.greenthumbcarrots: + default: false + description: Allows access to the Green Thumb ability for carrots + children: + mcmmo.ability.herbalism.greenthumb.plants.carrot: true + mcmmo.ability.herbalism.greenthumbcocoa: + default: false + description: Allows access to the Green Thumb ability for cocoa + children: + mcmmo.ability.herbalism.greenthumb.plants.cocoa: true + mcmmo.ability.herbalism.greenthumbnetherwart: + default: false + description: Allows access to the Green Thumb ability for netherwart + children: + mcmmo.ability.herbalism.greenthumb.plants.netherwarts: true + mcmmo.ability.herbalism.greenthumbpotatoes: + default: false + description: Allows access to the Green Thumb ability for potatoes + children: + mcmmo.ability.herbalism.greenthumb.plants.potato: true + mcmmo.ability.herbalism.greenthumbwheat: + default: false + description: Allows access to the Green Thumb ability for wheat + children: + mcmmo.ability.herbalism.greenthumb.plants.crops: true + mcmmo.ability.herbalism.hylianluck: + description: Allows access to the Hylian Luck ability + mcmmo.ability.herbalism.shroomthumb: + description: Allows access to the Shroom Thumb ability + mcmmo.ability.mining.*: + default: false + description: Allows access to all Mining abilities + children: + mcmmo.ability.mining.all: true + mcmmo.ability.mining.all: + description: Allows access to all Mining abilities + children: + mcmmo.ability.mining.blastmining.all: true + mcmmo.ability.mining.doubledrops: true + mcmmo.ability.mining.superbreaker: true + mcmmo.ability.mining.blastmining.*: + default: false + description: Allows access to all Blast Mining abilities + children: + mcmmo.ability.mining.blastmining.all: true + mcmmo.ability.mining.blastmining.all: + description: Allows access to all Blast Mining abilities + children: + mcmmo.ability.mining.blastmining.biggerbombs: true + mcmmo.ability.mining.blastmining.demolitionsexpertise: true + mcmmo.ability.mining.blastmining.detonate: true + mcmmo.ability.mining.blastmining.biggerbombs: + description: Allows access to the Bigger Bombs ability + mcmmo.ability.mining.blastmining.demolitionsexpertise: + description: Allows access to the Demolitions Expertise ability + mcmmo.ability.mining.blastmining.detonate: + description: Allows for remote TNT detonation + mcmmo.ability.mining.doubledrops: + description: Allows double drop chance when mining + mcmmo.ability.mining.superbreaker: + description: Allows access to the Super Breaker ability + mcmmo.ability.repair.*: + default: false + description: Allows access to all Repair abilities + children: + mcmmo.ability.repair.all: true + mcmmo.ability.repair.all: + description: Allows access to all Repair abilities + children: + mcmmo.ability.repair.arcaneforging: true + mcmmo.ability.repair.armorrepair: true + mcmmo.ability.repair.diamondrepair: true + mcmmo.ability.repair.goldrepair: true + mcmmo.ability.repair.ironrepair: true + mcmmo.ability.repair.leatherrepair: true + mcmmo.ability.repair.othermaterialrepair: true + mcmmo.ability.repair.otherrepair: true + mcmmo.ability.repair.repairbonus: true + mcmmo.ability.repair.repairmastery: true + mcmmo.ability.repair.salvage: true + mcmmo.ability.repair.stonerepair: true + mcmmo.ability.repair.stringrepair: true + mcmmo.ability.repair.toolrepair: true + mcmmo.ability.repair.woodrepair: true + mcmmo.ability.repair.arcaneforging: + description: Allows access to the Arcane Forging ability + mcmmo.ability.repair.armorrepair: + description: Allows ability to repair armor + mcmmo.ability.repair.diamondrepair: + description: Allows ability to repair Diamond tools & armor + mcmmo.ability.repair.goldrepair: + description: Allows ability to repair Gold tools & armor + mcmmo.ability.repair.ironrepair: + description: Allows ability to repair Iron tools & armor + mcmmo.ability.repair.leatherrepair: + description: Allows ability to repair Leather armor + mcmmo.ability.repair.othermaterialrepair: + description: Allows ability to repair items of material type OTHER + mcmmo.ability.repair.otherrepair: + description: Allows ability to repair items of type OTHER + mcmmo.ability.repair.repairbonus: + description: Allows access to Super Repair bonus + mcmmo.ability.repair.repairmastery: + description: Allows access to Repair Mastery + mcmmo.ability.repair.salvage: + description: Allows access to the Salvage ability + mcmmo.ability.repair.stonerepair: + description: Allows ability to repair Stone tools + mcmmo.ability.repair.stringrepair: + description: Allows ability to repair Bow and Fishing rod + mcmmo.ability.repair.toolrepair: + description: Allows ability to repair tools + mcmmo.ability.repair.woodrepair: + description: Allows ability to repair Wood tools + mcmmo.ability.smelting.*: + default: false + description: Allows access to all Smelting abilities + children: + mcmmo.ability.smelting.all: true + mcmmo.ability.smelting.all: + description: Allows access to all Smelting abilities + children: + mcmmo.ability.smelting.doubledrops: true + mcmmo.ability.smelting.fluxmining: true + mcmmo.ability.smelting.fuelefficiency: true + mcmmo.ability.smelting.vanillaxpboost: true + mcmmo.ability.smelting.doubledrops: + description: Allows access to the Second Smelt ability + mcmmo.ability.smelting.fluxmining: + description: Allows access to the Flux Mining ability + mcmmo.ability.smelting.fuelefficiency: + description: Allows access to the Fuel Efficiency ability + mcmmo.ability.smelting.secondsmelt: + default: false + description: Allows access to the Second Smelt ability + children: + mcmmo.ability.smelting.doubledrops: true + mcmmo.ability.smelting.vanillaxpboost: description: Allows vanilla XP boost from Smelting - mcmmo.ability.swords.*: - default: false - description: Allows access to all Swords abilities - children: - mcmmo.ability.swords.all: true - mcmmo.ability.swords.all: - description: Allows access to all Swords abilities - children: - mcmmo.ability.swords.bleed: true - mcmmo.ability.swords.counterattack: true - mcmmo.ability.swords.serratedstrikes: true - mcmmo.ability.swords.bleed: - description: Allows access to the Bleed ability - mcmmo.ability.swords.counterattack: - description: Allows access to the Counter Attack ability - mcmmo.ability.swords.serratedstrikes: - description: Allows access to the Serrated Strikes ability - mcmmo.ability.taming.*: - default: false - description: Allows access to all Taming abilities - children: - mcmmo.ability.taming.all: true - mcmmo.ability.taming.all: - description: Allows access to all Taming abilities - children: - mcmmo.ability.taming.beastlore: true - mcmmo.ability.taming.callofthewild: true - mcmmo.ability.taming.environmentallyaware: true - mcmmo.ability.taming.fastfoodservice: true - mcmmo.ability.taming.gore: true - mcmmo.ability.taming.holyhound: true - mcmmo.ability.taming.sharpenedclaws: true - mcmmo.ability.taming.shockproof: true - mcmmo.ability.taming.thickfur: true - mcmmo.ability.taming.beastlore: - description: Allows access to the Beast Lore ability - mcmmo.ability.taming.callofthewild: - description: Allows access to the Call of the Wild ability - mcmmo.ability.taming.environmentallyaware: - description: Allows access to the Environmentally Aware ability - mcmmo.ability.taming.fastfoodservice: - description: Allows access to the Fast Food Service ability - mcmmo.ability.taming.gore: - description: Allows access to the Gore ability - mcmmo.ability.taming.holyhound: - description: Allows access to the Holy Hound ability - mcmmo.ability.taming.sharpenedclaws: - description: Allows access to the Sharpened Claws ability - mcmmo.ability.taming.shockproof: - description: Allows access to the Shock Proof ability - mcmmo.ability.taming.thickfur: - description: Allows access to the Thick Fur ability - mcmmo.ability.unarmed.*: - default: false - description: Allows access to all Unarmed abilities - children: - mcmmo.ability.unarmed.all: true - mcmmo.ability.unarmed.all: - description: Allows access to all Unarmed abilities - children: - mcmmo.ability.unarmed.berserk: true - mcmmo.ability.unarmed.blockcracker: true - mcmmo.ability.unarmed.bonusdamage: true - mcmmo.ability.unarmed.deflect: true - mcmmo.ability.unarmed.disarm: true - mcmmo.ability.unarmed.irongrip: true - mcmmo.ability.unarmed.berserk: - description: Allows access to the Berserker ability - mcmmo.ability.unarmed.blockcracker: - description: Allows access to the Block Cracker ability - mcmmo.ability.unarmed.bonusdamage: - description: Allows bonus damage from Unarmed - mcmmo.ability.unarmed.deflect: - description: Allows access to the Deflect ability - mcmmo.ability.unarmed.disarm: - description: Allows access to the Disarm ability - mcmmo.ability.unarmed.irongrip: - description: Allows access to the Iron Grip ability - mcmmo.ability.woodcutting.*: - default: false - description: Allows access to all Woodcutting abilities - children: - mcmmo.ability.woodcutting.all: true - mcmmo.ability.woodcutting.all: - description: Allows access to all Woodcutting abilities - children: - mcmmo.ability.woodcutting.doubledrops: true - mcmmo.ability.woodcutting.leafblower: true - mcmmo.ability.woodcutting.treefeller: true - mcmmo.ability.woodcutting.doubledrops: - description: Allows double drop chance when woodcutting - mcmmo.ability.woodcutting.leafblower: - description: Allows access to Leaf Blower ability - mcmmo.ability.woodcutting.treefeller: - description: Allows access to Tree Feller ability - mcmmo.admin: - default: false - description: Implies access to everything in mcMMO - children: - mcmmo.commands.mmoupdate: true - mcmmo.commands.xprate.all: true - mcmmo.bypass.*: - default: false - description: Implies all bypass permissions. - children: - mcmmo.bypass.all: true - mcmmo.bypass.all: - default: false - description: Implies all bypass permissions. - children: - mcmmo.bypass.arcanebypass: true - mcmmo.bypass.hardcoremode: true - mcmmo.commands.inspect.far: true - mcmmo.commands.inspect.offline: true - mcmmo.bypass.arcanebypass: - default: false - description: Allows user to bypass Arcane Repair so he will never lose enchantments - mcmmo.bypass.hardcoremode: - default: false - description: Allows user to bypass negative penalties of Hardcore mode - mcmmo.bypass.inspect.distance: - default: false - description: Allows user to bypass Inspect's distance requirements - children: - mcmmo.commands.inspect.far: true - mcmmo.bypass.inspect.offline: - default: false - description: Allows user to bypass Inspect's offline player requirements - children: - mcmmo.commands.inspect.offline: true - mcmmo.chat.*: - default: false - description: Implies all mcmmo.chat permissions. (Warning, contains adminchat) - children: - mcmmo.chat.all: true - mcmmo.chat.all: - description: Implies all mcmmo.chat permissions. (Warning, contains adminchat) - children: - mcmmo.chat.adminchat: true - mcmmo.chat.partychat: true - mcmmo.chat.adminchat: - description: Allows participation in admin chat - mcmmo.chat.partychat: - description: Allows participation in party chat - mcmmo.motd: + mcmmo.ability.swords.*: + default: false + description: Allows access to all Swords abilities + children: + mcmmo.ability.swords.all: true + mcmmo.ability.swords.all: + description: Allows access to all Swords abilities + children: + mcmmo.ability.swords.bleed: true + mcmmo.ability.swords.counterattack: true + mcmmo.ability.swords.serratedstrikes: true + mcmmo.ability.swords.bleed: + description: Allows access to the Bleed ability + mcmmo.ability.swords.counterattack: + description: Allows access to the Counter Attack ability + mcmmo.ability.swords.serratedstrikes: + description: Allows access to the Serrated Strikes ability + mcmmo.ability.taming.*: + default: false + description: Allows access to all Taming abilities + children: + mcmmo.ability.taming.all: true + mcmmo.ability.taming.all: + description: Allows access to all Taming abilities + children: + mcmmo.ability.taming.beastlore: true + mcmmo.ability.taming.callofthewild: true + mcmmo.ability.taming.environmentallyaware: true + mcmmo.ability.taming.fastfoodservice: true + mcmmo.ability.taming.gore: true + mcmmo.ability.taming.holyhound: true + mcmmo.ability.taming.sharpenedclaws: true + mcmmo.ability.taming.shockproof: true + mcmmo.ability.taming.thickfur: true + mcmmo.ability.taming.beastlore: + description: Allows access to the Beast Lore ability + mcmmo.ability.taming.callofthewild: + description: Allows access to the Call of the Wild ability + mcmmo.ability.taming.environmentallyaware: + description: Allows access to the Environmentally Aware ability + mcmmo.ability.taming.fastfoodservice: + description: Allows access to the Fast Food Service ability + mcmmo.ability.taming.gore: + description: Allows access to the Gore ability + mcmmo.ability.taming.holyhound: + description: Allows access to the Holy Hound ability + mcmmo.ability.taming.sharpenedclaws: + description: Allows access to the Sharpened Claws ability + mcmmo.ability.taming.shockproof: + description: Allows access to the Shock Proof ability + mcmmo.ability.taming.thickfur: + description: Allows access to the Thick Fur ability + mcmmo.ability.unarmed.*: + default: false + description: Allows access to all Unarmed abilities + children: + mcmmo.ability.unarmed.all: true + mcmmo.ability.unarmed.all: + description: Allows access to all Unarmed abilities + children: + mcmmo.ability.unarmed.berserk: true + mcmmo.ability.unarmed.blockcracker: true + mcmmo.ability.unarmed.bonusdamage: true + mcmmo.ability.unarmed.deflect: true + mcmmo.ability.unarmed.disarm: true + mcmmo.ability.unarmed.irongrip: true + mcmmo.ability.unarmed.berserk: + description: Allows access to the Berserker ability + mcmmo.ability.unarmed.blockcracker: + description: Allows access to the Block Cracker ability + mcmmo.ability.unarmed.bonusdamage: + description: Allows bonus damage from Unarmed + mcmmo.ability.unarmed.deflect: + description: Allows access to the Deflect ability + mcmmo.ability.unarmed.disarm: + description: Allows access to the Disarm ability + mcmmo.ability.unarmed.irongrip: + description: Allows access to the Iron Grip ability + mcmmo.ability.woodcutting.*: + default: false + description: Allows access to all Woodcutting abilities + children: + mcmmo.ability.woodcutting.all: true + mcmmo.ability.woodcutting.all: + description: Allows access to all Woodcutting abilities + children: + mcmmo.ability.woodcutting.doubledrops: true + mcmmo.ability.woodcutting.leafblower: true + mcmmo.ability.woodcutting.treefeller: true + mcmmo.ability.woodcutting.doubledrops: + description: Allows double drop chance when woodcutting + mcmmo.ability.woodcutting.leafblower: + description: Allows access to Leaf Blower ability + mcmmo.ability.woodcutting.treefeller: + description: Allows access to Tree Feller ability + mcmmo.admin: + default: false + description: Implies access to everything in mcMMO + children: + mcmmo.commands.mmoupdate: true + mcmmo.commands.xprate.all: true + mcmmo.bypass.*: + default: false + description: Implies all bypass permissions. + children: + mcmmo.bypass.all: true + mcmmo.bypass.all: + default: false + description: Implies all bypass permissions. + children: + mcmmo.bypass.arcanebypass: true + mcmmo.bypass.hardcoremode: true + mcmmo.commands.inspect.far: true + mcmmo.commands.inspect.offline: true + mcmmo.bypass.arcanebypass: + default: false + description: Allows user to bypass Arcane Repair so he will never lose enchantments + mcmmo.bypass.hardcoremode: + default: false + description: Allows user to bypass negative penalties of Hardcore mode + mcmmo.bypass.inspect.distance: + default: false + description: Allows user to bypass Inspect's distance requirements + children: + mcmmo.commands.inspect.far: true + mcmmo.bypass.inspect.offline: + default: false + description: Allows user to bypass Inspect's offline player requirements + children: + mcmmo.commands.inspect.offline: true + mcmmo.chat.*: + default: false + description: Implies all mcmmo.chat permissions. (Warning, contains adminchat) + children: + mcmmo.chat.all: true + mcmmo.chat.all: + description: Implies all mcmmo.chat permissions. (Warning, contains adminchat) + children: + mcmmo.chat.adminchat: true + mcmmo.chat.partychat: true + mcmmo.chat.adminchat: + description: Allows participation in admin chat + mcmmo.chat.partychat: + description: Allows participation in party chat + mcmmo.motd: description: Allows access to the motd - mcmmo.commands.*: - default: false - description: Implies all mcmmo.commands permissions. - children: - mcmmo.commands.all: true - mcmmo.commands.all: - default: false - description: Implies all mcmmo.commands permissions. - children: - mcmmo.commands.defaults: true - mcmmo.commands.defaultsop: true - mcmmo.commands.mcpurge: true - mcmmo.commands.mcremove: true - mcmmo.commands.mmoupdate: true - mcmmo.commands.defaults: - description: Implies all default mcmmo.commands permissions. - children: - mcmmo.commands.acrobatics: true - mcmmo.commands.archery: true - mcmmo.commands.axes: true - mcmmo.commands.excavation: true - mcmmo.commands.fishing: true - mcmmo.commands.herbalism: true - mcmmo.commands.inspect: true - mcmmo.commands.mcability: true - mcmmo.commands.mchud: true - mcmmo.commands.mcmmo.all: true - mcmmo.commands.mcnotify: true - mcmmo.commands.mcrank: true - mcmmo.commands.mcstats: true - mcmmo.commands.mctop.all: true - mcmmo.commands.mining: true - mcmmo.commands.party.all: true - mcmmo.commands.ptp: true - mcmmo.commands.ptp.accept: true - mcmmo.commands.ptp.acceptall: true - mcmmo.commands.ptp.toggle: true - mcmmo.commands.repair: true - mcmmo.commands.smelting: true - mcmmo.commands.swords: true - mcmmo.commands.taming: true - mcmmo.commands.unarmed: true - mcmmo.commands.woodcutting: true - mcmmo.commands.xplock.all: true - mcmmo.commands.defaultsop: - description: Implies all default op mcmmo.commands permissions. - children: - mcmmo.commands.addlevels: true - mcmmo.commands.addlevels.others: true - mcmmo.commands.addxp: true - mcmmo.commands.addxp.others: true - mcmmo.commands.defaults: true - mcmmo.commands.hardcore.all: true - mcmmo.commands.inspect.far: true - mcmmo.commands.inspect.offline: true - mcmmo.commands.mcability.others: true - mcmmo.commands.mcgod: true - mcmmo.commands.mcgod.others: true - mcmmo.commands.mcrank.others.all: true - mcmmo.commands.mcrefresh: true - mcmmo.commands.mcrefresh.others: true - mcmmo.commands.mmoedit: true - mcmmo.commands.mmoedit.others: true - mcmmo.commands.ptp.world.all: true - mcmmo.commands.skillreset.all: true - mcmmo.commands.vampirism.all: true - mcmmo.commands.xprate.all: true - mcmmo.commands.ability: - default: false - description: Allows access to the mcability command - children: - mcmmo.commands.mcability: true - mcmmo.commands.acrobatics: - description: Allows access to the acrobatics command - mcmmo.commands.addlevels: - description: Allows access to the addlevels command - mcmmo.commands.addlevels.others: - description: Allows access to the addlevels command for other players - mcmmo.commands.addxp: - description: Allows access to the addxp command - mcmmo.commands.addxp.others: - description: Allows access to the addxp command for other players - mcmmo.commands.archery: - description: Allows access to the archery command - mcmmo.commands.axes: - description: Allows access to the axes command - mcmmo.commands.excavation: - description: Allows access to the excavation command - mcmmo.commands.fishing: - description: Allows access to the fishing command - mcmmo.commands.hardcore.*: - default: false - description: Implies access to all mcmmo.commands.hardcore permissions - children: - mcmmo.commands.hardcore.all: true - mcmmo.commands.hardcore.all: - description: Implies access to all mcmmo.commands.hardcore permissions - children: - mcmmo.commands.hardcore: true - mcmmo.commands.hardcore.modify: true - mcmmo.commands.hardcore.toggle: true - mcmmo.commands.hardcore: - description: Allows access to the hardcore command - mcmmo.commands.hardcore.modify: - description: Allows access to the hardcore command to modify the hardcore rate - mcmmo.commands.hardcore.toggle: - description: Allows access to the hardcore command to toggle hardcore on/off - mcmmo.commands.herbalism: - description: Allows access to the herbalism command - mcmmo.commands.inspect.*: - default: false - description: Implies access to all mcmmo.commands.inspect permissions - children: - mcmmo.commands.inspect.all: true - mcmmo.commands.inspect.all: - default: false - description: Implies access to all mcmmo.commands.inspect permissions - children: - mcmmo.commands.inspect: true - mcmmo.commands.inspect.far: true - mcmmo.commands.inspect.offline: true - mcmmo.commands.inspect: - description: Allows access to the inspect command - mcmmo.commands.inspect.far: - description: Allows access to the inspect command for far players - mcmmo.commands.inspect.offline: - description: Allows access to the inspect command for offline players - mcmmo.commands.mcability: - description: Allows access to the mcability command - mcmmo.commands.mcability.others: - description: Allows access to the mcability command for other players - mcmmo.commands.mcc: - default: false - description: Allows access to the mcmmo help command - children: - mcmmo.commands.mcmmo.help: true - mcmmo.commands.mcgod: - description: Allows access to the mcgod command - mcmmo.commands.mcgod.others: - description: Allows access to the mcgod command for other players - mcmmo.commands.mchud: - description: Allows access to the mchud command - mcmmo.commands.mcmmo.*: - default: false - description: Implies access to all mcmmo.commands.mcmmo permissions - children: - mcmmo.commands.mcmmo.all: true - mcmmo.commands.mcmmo.all: - description: Implies access to all mcmmo.commands.mcmmo permissions. - children: - mcmmo.commands.mcmmo.description: true - mcmmo.commands.mcmmo.help: true - mcmmo.commands.mcmmo.description: - description: Allows access to the mcmmo command - mcmmo.commands.mcmmo.help: - description: Allows access to the mcmmo help command - mcmmo.commands.mcnotify: - description: Allows access to the mcnotify command - mcmmo.commands.mcpurge: - default: false - description: Allows access to the mcpurge command - mcmmo.commands.mcrank: - description: Allows access to the mcrank command - mcmmo.commands.mcrank.others.*: - default: false - description: Implies access to all mcmmo.commands.mcrank.others permissions - children: - mcmmo.commands.mcrank.others.all: true - mcmmo.commands.mcrank.others.all: - description: Implies access to all mcmmo.commands.mcrank.others permissions - children: - mcmmo.commands.mcrank.others: true - mcmmo.commands.mcrank.others.far: true - mcmmo.commands.mcrank.others.offline: true - mcmmo.commands.mcrank.others: - description: Allows access to the mcrank command for other players - mcmmo.commands.mcrank.others.far: - description: Allows access to the mcrank command for far players - mcmmo.commands.mcrank.others.offline: - description: Allows access to the mcrank command for offline players - mcmmo.commands.mcrefresh: - description: Allows access to the mcrefresh command - mcmmo.commands.mcrefresh.others: - description: Allows access to the mcrefresh command for other players - mcmmo.commands.mcremove: - default: false - description: Allows access to the mcremove command - mcmmo.commands.mcstats: - description: Allows access to the mcstats command - mcmmo.commands.mctop.*: - default: false - description: Implies access to all mcmmo.commands.mctop permissions - children: - mcmmo.commands.mctop.all: true - mcmmo.commands.mctop.all: - description: Implies access to all mcmmo.commands.mctop permissions - children: - mcmmo.commands.mctop: true - mcmmo.commands.mctop.acrobatics: true - mcmmo.commands.mctop.archery: true - mcmmo.commands.mctop.axes: true - mcmmo.commands.mctop.excavation: true - mcmmo.commands.mctop.fishing: true - mcmmo.commands.mctop.herbalism: true - mcmmo.commands.mctop.mining: true - mcmmo.commands.mctop.repair: true - mcmmo.commands.mctop.smelting: true - mcmmo.commands.mctop.swords: true - mcmmo.commands.mctop.taming: true - mcmmo.commands.mctop.unarmed: true - mcmmo.commands.mctop.woodcutting: true - mcmmo.commands.mctop: - description: Allows access to the mctop command - mcmmo.commands.mctop.acrobatics: - description: Allows access to the mctop command for acrobatics - mcmmo.commands.mctop.archery: - description: Allows access to the mctop command for archery - mcmmo.commands.mctop.axes: - description: Allows access to the mctop command for axes - mcmmo.commands.mctop.excavation: - description: Allows access to the mctop command for excavation - mcmmo.commands.mctop.fishing: - description: Allows access to the mctop command for fishing - mcmmo.commands.mctop.herbalism: - description: Allows access to the mctop command for herbalism - mcmmo.commands.mctop.mining: - description: Allows access to the mctop command for mining - mcmmo.commands.mctop.repair: - description: Allows access to the mctop command for repair - mcmmo.commands.mctop.smelting: - description: Allows access to the mctop command for smelting - mcmmo.commands.mctop.swords: - description: Allows access to the mctop command for swords - mcmmo.commands.mctop.taming: - description: Allows access to the mctop command for taming - mcmmo.commands.mctop.unarmed: - description: Allows access to the mctop command for unarmed - mcmmo.commands.mctop.woodcutting: - description: Allows access to the mctop command for woodcutting - mcmmo.commands.mining: - description: Allows access to the mining command - mcmmo.commands.mmoedit: - description: Allows access to the mmoedit command - mcmmo.commands.mmoedit.others: - description: Allows access to the mmoedit command for other players - mcmmo.commands.mmoupdate: - default: false - description: Allows access to the mmoupdate command - mcmmo.commands.party.*: - default: false - description: Implies access to all mcmmo.commands.party permissions. - children: - mcmmo.commands.party.all: true - mcmmo.commands.party.all: - description: Implies access to all mcmmo.commands.party permissions. - children: - mcmmo.commands.party: true - mcmmo.commands.party.accept: true - mcmmo.commands.party.chat: true - mcmmo.commands.party.create: true - mcmmo.commands.party.disband: true - mcmmo.commands.party.expshare: true - mcmmo.commands.party.help: true - mcmmo.commands.party.info: true - mcmmo.commands.party.invite: true - mcmmo.commands.party.itemshare: true - mcmmo.commands.party.join: true - mcmmo.commands.party.kick: true - mcmmo.commands.party.lock: true - mcmmo.commands.party.owner: true - mcmmo.commands.party.password: true - mcmmo.commands.party.quit: true - mcmmo.commands.party.rename: true - mcmmo.commands.party.teleport: true - mcmmo.commands.party.unlock: true - mcmmo.commands.party: - description: Allows access to the party command - mcmmo.commands.party.accept: - description: Allows access to the party accept command - mcmmo.commands.party.chat: - description: Dummy permission for mcmmo.chat.partychat - children: - mcmmo.chat.partychat: true - mcmmo.commands.party.create: - description: Allows access to the party create command - mcmmo.commands.party.disband: - description: Allows access to the party disband command - mcmmo.commands.party.expshare: - description: Allows access to the party expshare command - mcmmo.commands.party.help: - description: Allows access to the party help command - mcmmo.commands.party.info: - description: Allows access to the party info command - mcmmo.commands.party.invite: - description: Allows access to the party invite command - mcmmo.commands.party.itemshare: - description: Allows access to the party itemshare command - mcmmo.commands.party.join: - description: Allows access to the party join command - mcmmo.commands.party.kick: - description: Allows access to the party kick command - mcmmo.commands.party.lock: - description: Allows access to the party lock command - mcmmo.commands.party.owner: - description: Allows access to the party owner command - mcmmo.commands.party.password: - description: Allows access to the party password command - mcmmo.commands.party.quit: - description: Allows access to the party quit command - mcmmo.commands.party.rename: - description: Allows access to the party rename command - mcmmo.commands.party.teleport: - description: Dummy permission for mcmmo.commands.ptp - children: - mcmmo.commands.ptp: true - mcmmo.commands.party.unlock: - description: Allows access to the party unlock command - mcmmo.commands.ptp.*: - default: false - description: Implies access to all mcmmo.commands.ptp permissions. - children: - mcmmo.commands.ptp.all: true - mcmmo.commands.ptp.all: - default: false - description: Implies access to all mcmmo.commands.ptp permissions. - children: - mcmmo.commands.ptp: true - mcmmo.commands.ptp.accept: true - mcmmo.commands.ptp.acceptall: true - mcmmo.commands.ptp.toggle: true - mcmmo.commands.ptp.world.all: true - mcmmo.commands.ptp: - description: Allows access to the ptp command - mcmmo.commands.ptp.accept: - description: Allows access to the ptp accept command - mcmmo.commands.ptp.acceptall: - description: Allows access to the ptp acceptall command - mcmmo.commands.ptp.toggle: - description: Allows access to the ptp toggle command - mcmmo.commands.ptp.world.*: - default: false - description: Implies access to all mcmmo.commands.ptp.world permissions. - children: - mcmmo.commands.ptp.world.all: true - mcmmo.commands.ptp.world.all: - description: Implies access to all mcmmo.commands.ptp.world permissions - mcmmo.commands.repair: - description: Allows access to the repair command - mcmmo.commands.skillreset.*: - default: false - description: Implies access to all mcmmo.commands.skillreset permissions - children: - mcmmo.commands.skillreset.all: true - mcmmo.commands.skillreset.all: - description: Implies access to all mcmmo.commands.skillreset permissions - children: - mcmmo.commands.skillreset: true - mcmmo.commands.skillreset.acrobatics: true - mcmmo.commands.skillreset.archery: true - mcmmo.commands.skillreset.axes: true - mcmmo.commands.skillreset.excavation: true - mcmmo.commands.skillreset.fishing: true - mcmmo.commands.skillreset.herbalism: true - mcmmo.commands.skillreset.mining: true - mcmmo.commands.skillreset.others.all: true - mcmmo.commands.skillreset.repair: true - mcmmo.commands.skillreset.smelting: true - mcmmo.commands.skillreset.swords: true - mcmmo.commands.skillreset.taming: true - mcmmo.commands.skillreset.unarmed: true - mcmmo.commands.skillreset.woodcutting: true - mcmmo.commands.skillreset: - description: Allows access to the skillreset command - mcmmo.commands.skillreset.acrobatics: - description: Allows access to the skillreset command for acrobatics - mcmmo.commands.skillreset.archery: - description: Allows access to the skillreset command for archery - mcmmo.commands.skillreset.axes: - description: Allows access to the skillreset command for axes - mcmmo.commands.skillreset.excavation: - description: Allows access to the skillreset command for excavation - mcmmo.commands.skillreset.fishing: - description: Allows access to the skillreset command for fishing - mcmmo.commands.skillreset.herbalism: - description: Allows access to the skillreset command for herbalism - mcmmo.commands.skillreset.mining: - description: Allows access to the skillreset command for mining - mcmmo.commands.skillreset.others.*: - default: false - description: Implies access to all mcmmo.commands.skillreset.others permissions - children: - mcmmo.commands.skillreset.others.all: true - mcmmo.commands.skillreset.others.all: - description: Implies access to all mcmmo.commands.skillreset.others permissions - children: - mcmmo.commands.skillreset.others: true - mcmmo.commands.skillreset.others.acrobatics: true - mcmmo.commands.skillreset.others.archery: true - mcmmo.commands.skillreset.others.axes: true - mcmmo.commands.skillreset.others.excavation: true - mcmmo.commands.skillreset.others.fishing: true - mcmmo.commands.skillreset.others.herbalism: true - mcmmo.commands.skillreset.others.mining: true - mcmmo.commands.skillreset.others.repair: true - mcmmo.commands.skillreset.others.smelting: true - mcmmo.commands.skillreset.others.swords: true - mcmmo.commands.skillreset.others.taming: true - mcmmo.commands.skillreset.others.unarmed: true - mcmmo.commands.skillreset.others.woodcutting: true - mcmmo.commands.skillreset.others: - description: Allows access to the skillreset command for other players - mcmmo.commands.skillreset.others.acrobatics: - description: Allows access to the skillreset command for acrobatics for other players - mcmmo.commands.skillreset.others.archery: - description: Allows access to the skillreset command for archery for other players - mcmmo.commands.skillreset.others.axes: - description: Allows access to the skillreset command for axes for other players - mcmmo.commands.skillreset.others.excavation: - description: Allows access to the skillreset command for excavation for other players - mcmmo.commands.skillreset.others.fishing: - description: Allows access to the skillreset command for fishing for other players - mcmmo.commands.skillreset.others.herbalism: - description: Allows access to the skillreset command for herbalism for other players - mcmmo.commands.skillreset.others.mining: - description: Allows access to the skillreset command for mining for other players - mcmmo.commands.skillreset.others.repair: - description: Allows access to the skillreset command for repair for other players - mcmmo.commands.skillreset.others.smelting: - description: Allows access to the skillreset command for smelting for other players - mcmmo.commands.skillreset.others.swords: - description: Allows access to the skillreset command for swords for other players - mcmmo.commands.skillreset.others.taming: - description: Allows access to the skillreset command for taming for other players - mcmmo.commands.skillreset.others.unarmed: - description: Allows access to the skillreset command for unarmed for other players - mcmmo.commands.skillreset.others.woodcutting: - description: Allows access to the skillreset command for woodcutting for other players - mcmmo.commands.skillreset.repair: - description: Allows access to the skillreset command for repair - mcmmo.commands.skillreset.smelting: - description: Allows access to the skillreset command for smelting - mcmmo.commands.skillreset.swords: - description: Allows access to the skillreset command for swords - mcmmo.commands.skillreset.taming: - description: Allows access to the skillreset command for taming - mcmmo.commands.skillreset.unarmed: - description: Allows access to the skillreset command for unarmed - mcmmo.commands.skillreset.woodcutting: - description: Allows access to the skillreset command for woodcutting - mcmmo.commands.smelting: - description: Allows access to the smelting command - mcmmo.commands.swords: - description: Allows access to the swords command - mcmmo.commands.taming: - description: Allows access to the taming command - mcmmo.commands.unarmed: - description: Allows access to the unarmed command - mcmmo.commands.vampirism.*: - default: false - description: Implies access to all mcmmo.commands.vampirism permissions - children: - mcmmo.commands.vampirism.all: true - mcmmo.commands.vampirism.all: - description: Implies access to all mcmmo.commands.vampirism permissions - children: - mcmmo.commands.vampirism: true - mcmmo.commands.vampirism.modify: true - mcmmo.commands.vampirism.toggle: true - mcmmo.commands.vampirism: - description: Allows access to the vampirism command - mcmmo.commands.vampirism.modify: - description: Allows access to the vampirism command to modify the vampirism rate - mcmmo.commands.vampirism.toggle: - description: Allows access to the vampirism command to toggle vampirism on/off - mcmmo.commands.woodcutting: - description: Allows access to the woodcutting command - mcmmo.commands.xplock.*: - default: false - description: Implies access to all mcmmo.commands.xplock permissions - children: - mcmmo.commands.xplock.all: true - mcmmo.commands.xplock.all: - description: Implies access to all mcmmo.commands.xplock permissions - children: - mcmmo.commands.xplock: true - mcmmo.commands.xplock.acrobatics: true - mcmmo.commands.xplock.archery: true - mcmmo.commands.xplock.axes: true - mcmmo.commands.xplock.excavation: true - mcmmo.commands.xplock.fishing: true - mcmmo.commands.xplock.herbalism: true - mcmmo.commands.xplock.mining: true - mcmmo.commands.xplock.repair: true - mcmmo.commands.xplock.smelting: true - mcmmo.commands.xplock.swords: true - mcmmo.commands.xplock.taming: true - mcmmo.commands.xplock.unarmed: true - mcmmo.commands.xplock.woodcutting: true - mcmmo.commands.xplock: - description: Allows access to the xplock command - mcmmo.commands.xplock.acrobatics: - description: Allows access to the xplock command for acrobatics - mcmmo.commands.xplock.archery: - description: Allows access to the xplock command for archery - mcmmo.commands.xplock.axes: - description: Allows access to the xplock command for axes - mcmmo.commands.xplock.excavation: - description: Allows access to the xplock command for excavation - mcmmo.commands.xplock.fishing: - description: Allows access to the xplock command for fishing - mcmmo.commands.xplock.herbalism: - description: Allows access to the xplock command for herbalism - mcmmo.commands.xplock.mining: - description: Allows access to the xplock command for mining - mcmmo.commands.xplock.repair: - description: Allows access to the xplock command for repair - mcmmo.commands.xplock.smelting: - description: Allows access to the xplock command for smelting - mcmmo.commands.xplock.swords: - description: Allows access to the xplock command for swords - mcmmo.commands.xplock.taming: - description: Allows access to the xplock command for taming - mcmmo.commands.xplock.unarmed: - description: Allows access to the xplock command for unarmed - mcmmo.commands.xplock.woodcutting: - description: Allows access to the xplock command for woodcutting - mcmmo.commands.xprate.*: - default: false - description: Implies access to all mcmmo.commands.xprate permissions - children: - mcmmo.commands.xprate.all: true - mcmmo.commands.xprate.all: - description: Implies access to all mcmmo.commands.xprate permissions - children: - mcmmo.commands.xprate: true - mcmmo.commands.xprate.reset: true - mcmmo.commands.xprate.set: true - mcmmo.commands.xprate: - description: Allows access to the xprate command - mcmmo.commands.xprate.reset: - description: Allows access to the xprate reset command - mcmmo.commands.xprate.set: - description: Allows access to the xprate command to control xp events - mcmmo.defaults: - default: true - description: mcmmo permisions that default to true - children: - mcmmo.chat.partychat: true - mcmmo.commands.defaults: true - mcmmo.motd: true - mcmmo.skills.all: true - mcmmo.defaultsop: - default: op - description: mcmmo permissions that default to op - children: - mcmmo.chat.adminchat: true - mcmmo.commands.defaultsop: true - mcmmo.item.all: true - mcmmo.tools.updatecheck: true - mcmmo.item.*: - default: false - description: Implies all mcmmo.item permissions - children: - mcmmo.item.all: true - mcmmo.item.all: - description: Implies all mcmmo.item permissions - children: - mcmmo.item.chimaerawing: true - mcmmo.item.chimaerawing: - description: Allows use of Chimaera Wing item - mcmmo.motd: - description: Allows access to the motd - mcmmo.party.*: - default: false - description: Implies access to all mcmmo party permissions - children: - mcmmo.party.all: true - mcmmo.party.all: - default: false - description: Implies access to all mcmmo party permissions - children: - mcmmo.party.friendlyfire: true - mcmmo.party.friendlyfire: - default: false - description: Allows in-party friendly fire if both attacker and victim have this permission - mcmmo.perks.*: - default: false - description: implies access to all mcmmo perks - children: - mcmmo.perks.all: true - mcmmo.perks.all: - default: false - description: implies access to all mcmmo perks - children: - mcmmo.perks.activationtime.all: true - mcmmo.perks.cooldowns.all: true - mcmmo.perks.lucky.all: true - mcmmo.perks.xp.all: true - mcmmo.perks.activationtime.*: - default: false - description: Increased activation time perks typically given to donors or VIPs - children: - mcmmo.perks.activationtime.all: true - mcmmo.perks.activationtime.all: - default: false - description: Increased activation time perks typically given to donors or VIPs - children: - mcmmo.perks.activationtime.eightseconds: true - mcmmo.perks.activationtime.fourseconds: true - mcmmo.perks.activationtime.twelveseconds: true - mcmmo.perks.activationtime.eightseconds: - default: false - description: Increases activation time by 8 seconds - mcmmo.perks.activationtime.fourseconds: - default: false - description: Increases activation time by 4 seconds - mcmmo.perks.activationtime.twelveseconds: - default: false - description: Increases activation time by 12 seconds - mcmmo.perks.cooldowns.*: - default: false - description: Reduced cooldown perks typically given to donors or VIPs - children: - mcmmo.perks.cooldowns.all: true - mcmmo.perks.cooldowns.all: - default: false - description: Reduced cooldown perks typically given to donors or VIPs - children: - mcmmo.perks.cooldowns.halved: true - mcmmo.perks.cooldowns.quartered: true - mcmmo.perks.cooldowns.thirded: true - mcmmo.perks.cooldowns.halved: - default: false - description: Cuts cooldowns down by 1/2 - mcmmo.perks.cooldowns.quartered: - default: false - description: Cuts cooldowns down by 1/4 - mcmmo.perks.cooldowns.thirded: - default: false - description: Cuts cooldowns down by 1/3 - mcmmo.perks.lucky.*: - default: false - description: Gives all abilities & skills a 33.3% better chance to activate. - children: - mcmmo.perks.lucky.all: true - mcmmo.perks.lucky.all: - default: false - description: Gives all abilities & skills a 33.3% better chance to activate. - children: - mcmmo.perks.lucky.acrobatics: true - mcmmo.perks.lucky.archery: true - mcmmo.perks.lucky.axes: true - mcmmo.perks.lucky.excavation: true - mcmmo.perks.lucky.fishing: true - mcmmo.perks.lucky.herbalism: true - mcmmo.perks.lucky.mining: true - mcmmo.perks.lucky.repair: true - mcmmo.perks.lucky.smelting: true - mcmmo.perks.lucky.swords: true - mcmmo.perks.lucky.taming: true - mcmmo.perks.lucky.unarmed: true - mcmmo.perks.lucky.woodcutting: true - mcmmo.perks.lucky.acrobatics: - default: false - description: Gives Acrobatics abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.archery: - default: false - description: Gives Archery abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.axes: - default: false - description: Gives Axes abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.excavation: - default: false - description: Gives Excavation abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.fishing: - default: false - description: Gives Fishing abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.herbalism: - default: false - description: Gives Herbalism abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.mining: - default: false - description: Gives Mining abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.repair: - default: false - description: Gives Repair abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.smelting: - default: false - description: Gives Smelting abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.swords: - default: false - description: Gives Swords abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.taming: - default: false - description: Gives Taming abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.unarmed: - default: false - description: Gives Unarmed abilities & skills a 33.3% better chance to activate. - mcmmo.perks.lucky.woodcutting: - default: false - description: Gives Woodcutting abilities & skills a 33.3% better chance to activate. - mcmmo.perks.xp.*: - default: false - description: XP Perks typically given to donors or VIPs - children: - mcmmo.perks.xp.all: true - mcmmo.perks.xp.all: - default: false - description: XP Perks typically given to donors or VIPs - children: - mcmmo.perks.xp.150percentboost: true - mcmmo.perks.xp.50percentboost: true - mcmmo.perks.xp.double: true - mcmmo.perks.xp.quadruple: true - mcmmo.perks.xp.triple: true - mcmmo.perks.xp.150percentboost: - default: false - description: Mulitplies incoming XP by 2.5 - mcmmo.perks.xp.50percentboost: - default: false - description: Mulitplies incoming XP by 1.5 - mcmmo.perks.xp.double: - default: false - description: Doubles incoming XP - mcmmo.perks.xp.quadruple: - default: false - description: Quadruples incoming XP - mcmmo.perks.xp.triple: - default: false - description: Triples incoming XP - mcmmo.skillreset: - default: false - description: Allow reset of skill levels - children: - mcmmo.commands.skillreset.all: true - mcmmo.commands.skillreset.others.all: false - mcmmo.skills.*: - default: false - description: Implies all mcmmo.skills permissions. - children: - mcmmo.skills.all: true - mcmmo.skills.all: - description: Implies all mcmmo.skills permissions. - children: - mcmmo.skills.acrobatics: true - mcmmo.skills.archery: true - mcmmo.skills.axes: true - mcmmo.skills.excavation: true - mcmmo.skills.fishing: true - mcmmo.skills.herbalism: true - mcmmo.skills.mining: true - mcmmo.skills.repair: true - mcmmo.skills.swords: true - mcmmo.skills.smelting: true - mcmmo.skills.taming: true - mcmmo.skills.unarmed: true - mcmmo.skills.woodcutting: true - mcmmo.skills.acrobatics: - description: Allows access to the Acrobatics skill - children: - mcmmo.ability.acrobatics.all: true - mcmmo.commands.acrobatics: true - mcmmo.commands.xplock.acrobatics: true - mcmmo.skills.archery: - description: Allows access to the Archery skill - children: - mcmmo.ability.archery.all: true - mcmmo.commands.archery: true - mcmmo.commands.xplock.archery: true - mcmmo.skills.axes: - description: Allows access to the Axes skill - children: - mcmmo.ability.axes.all: true - mcmmo.commands.axes: true - mcmmo.commands.xplock.axes: true - mcmmo.skills.excavation: - description: Allows access to the Excavation skill - children: - mcmmo.ability.excavation.all: true - mcmmo.commands.excavation: true - mcmmo.commands.xplock.excavation: true - mcmmo.skills.fishing: - description: Allows access to the Fishing skill - children: - mcmmo.ability.fishing.all: true - mcmmo.commands.fishing: true - mcmmo.commands.xplock.fishing: true - mcmmo.skills.herbalism: - description: Allows access to the Herbalism skill - children: - mcmmo.ability.herbalism.all: true - mcmmo.commands.herbalism: true - mcmmo.commands.xplock.herbalism: true - mcmmo.skills.mining: - description: Allows access to the Mining skill - children: - mcmmo.ability.mining.all: true - mcmmo.commands.mining: true - mcmmo.commands.xplock.mining: true - mcmmo.skills.repair: - description: Allows access to the Repair skill - children: - mcmmo.ability.repair.all: true - mcmmo.commands.repair: true - mcmmo.commands.xplock.repair: true - mcmmo.skills.smelting: - description: Allows access to the Smelting skill - children: - mcmmo.ability.smelting.all: true - mcmmo.commands.smelting: true - mcmmo.commands.xplock.smelting: true - mcmmo.skills.swords: - description: Allows access to the Swords skill - children: - mcmmo.ability.swords.all: true - mcmmo.commands.swords: true - mcmmo.commands.xplock.swords: true - mcmmo.skills.taming: - description: Allows access to the Taming skill - children: - mcmmo.ability.taming.all: true - mcmmo.commands.taming: true - mcmmo.commands.xplock.taming: true - mcmmo.skills.unarmed: - description: Allows access to the Unarmed skill - children: - mcmmo.ability.unarmed.all: true - mcmmo.commands.unarmed: true - mcmmo.commands.xplock.unarmed: true - mcmmo.skills.woodcutting: - description: Allows access to the Woodcutting skill - children: - mcmmo.ability.woodcutting.all: true - mcmmo.commands.woodcutting: true - mcmmo.commands.xplock.woodcutting: true - mcmmo.tools.*: - default: false - description: Implies all mcmmo.tools permissions. - children: - mcmmo.tools.all: true - mcmmo.tools.all: - default: false - description: Implies all mcmmo.tools permissions. - children: - mcmmo.tools.mcgod: true - mcmmo.tools.mcrefresh: true - mcmmo.tools.mcremove: true - mcmmo.tools.mmoedit: true - mcmmo.tools.updatecheck: true - mcmmo.tools.mcgod: - default: false - description: Allows access to mcgod command - children: - mcmmo.commands.mcgod: true - mcmmo.tools.mcrefresh: - default: false - description: Allows access to mcrefresh command - children: - mcmmo.commands.mcrefresh: true - mcmmo.commands.mcrefresh.others: true - mcmmo.tools.mcremove: - default: false - decription: Allows access to mcremove and mcpurge command - children: - mcmmo.commands.mcremove: true - mcmmo.tools.mmoedit: - default: false - description: Allows access to mmoedit command - children: - mcmmo.commands.addlevels: true - mcmmo.commands.addlevels.others: true - mcmmo.commands.addxp: true - mcmmo.commands.addxp.others: true - mcmmo.commands.mcpurge: true - mcmmo.commands.mmoedit: true - mcmmo.commands.mmoedit.others: true - mcmmo.tools.updatecheck: - default: false - description: Notifies admins if there is a new version of mcMMO available + mcmmo.commands.*: + default: false + description: Implies all mcmmo.commands permissions. + children: + mcmmo.commands.all: true + mcmmo.commands.all: + default: false + description: Implies all mcmmo.commands permissions. + children: + mcmmo.commands.defaults: true + mcmmo.commands.defaultsop: true + mcmmo.commands.mcpurge: true + mcmmo.commands.mcremove: true + mcmmo.commands.mmoupdate: true + mcmmo.commands.defaults: + description: Implies all default mcmmo.commands permissions. + children: + mcmmo.commands.acrobatics: true + mcmmo.commands.archery: true + mcmmo.commands.axes: true + mcmmo.commands.excavation: true + mcmmo.commands.fishing: true + mcmmo.commands.herbalism: true + mcmmo.commands.inspect: true + mcmmo.commands.mcability: true + mcmmo.commands.mchud: true + mcmmo.commands.mcmmo.all: true + mcmmo.commands.mcnotify: true + mcmmo.commands.mcrank: true + mcmmo.commands.mcstats: true + mcmmo.commands.mctop.all: true + mcmmo.commands.mining: true + mcmmo.commands.party.all: true + mcmmo.commands.ptp: true + mcmmo.commands.ptp.accept: true + mcmmo.commands.ptp.acceptall: true + mcmmo.commands.ptp.toggle: true + mcmmo.commands.repair: true + mcmmo.commands.smelting: true + mcmmo.commands.swords: true + mcmmo.commands.taming: true + mcmmo.commands.unarmed: true + mcmmo.commands.woodcutting: true + mcmmo.commands.xplock.all: true + mcmmo.commands.defaultsop: + description: Implies all default op mcmmo.commands permissions. + children: + mcmmo.commands.addlevels: true + mcmmo.commands.addlevels.others: true + mcmmo.commands.addxp: true + mcmmo.commands.addxp.others: true + mcmmo.commands.defaults: true + mcmmo.commands.hardcore.all: true + mcmmo.commands.inspect.far: true + mcmmo.commands.inspect.offline: true + mcmmo.commands.mcability.others: true + mcmmo.commands.mcgod: true + mcmmo.commands.mcgod.others: true + mcmmo.commands.mcrank.others.all: true + mcmmo.commands.mcrefresh: true + mcmmo.commands.mcrefresh.others: true + mcmmo.commands.mmoedit: true + mcmmo.commands.mmoedit.others: true + mcmmo.commands.ptp.world.all: true + mcmmo.commands.skillreset.all: true + mcmmo.commands.vampirism.all: true + mcmmo.commands.xprate.all: true + mcmmo.commands.ability: + default: false + description: Allows access to the mcability command + children: + mcmmo.commands.mcability: true + mcmmo.commands.acrobatics: + description: Allows access to the acrobatics command + mcmmo.commands.addlevels: + description: Allows access to the addlevels command + mcmmo.commands.addlevels.others: + description: Allows access to the addlevels command for other players + mcmmo.commands.addxp: + description: Allows access to the addxp command + mcmmo.commands.addxp.others: + description: Allows access to the addxp command for other players + mcmmo.commands.archery: + description: Allows access to the archery command + mcmmo.commands.axes: + description: Allows access to the axes command + mcmmo.commands.excavation: + description: Allows access to the excavation command + mcmmo.commands.fishing: + description: Allows access to the fishing command + mcmmo.commands.hardcore.*: + default: false + description: Implies access to all mcmmo.commands.hardcore permissions + children: + mcmmo.commands.hardcore.all: true + mcmmo.commands.hardcore.all: + description: Implies access to all mcmmo.commands.hardcore permissions + children: + mcmmo.commands.hardcore: true + mcmmo.commands.hardcore.modify: true + mcmmo.commands.hardcore.toggle: true + mcmmo.commands.hardcore: + description: Allows access to the hardcore command + mcmmo.commands.hardcore.modify: + description: Allows access to the hardcore command to modify the hardcore rate + mcmmo.commands.hardcore.toggle: + description: Allows access to the hardcore command to toggle hardcore on/off + mcmmo.commands.herbalism: + description: Allows access to the herbalism command + mcmmo.commands.inspect.*: + default: false + description: Implies access to all mcmmo.commands.inspect permissions + children: + mcmmo.commands.inspect.all: true + mcmmo.commands.inspect.all: + default: false + description: Implies access to all mcmmo.commands.inspect permissions + children: + mcmmo.commands.inspect: true + mcmmo.commands.inspect.far: true + mcmmo.commands.inspect.offline: true + mcmmo.commands.inspect: + description: Allows access to the inspect command + mcmmo.commands.inspect.far: + description: Allows access to the inspect command for far players + mcmmo.commands.inspect.offline: + description: Allows access to the inspect command for offline players + mcmmo.commands.mcability: + description: Allows access to the mcability command + mcmmo.commands.mcability.others: + description: Allows access to the mcability command for other players + mcmmo.commands.mcc: + default: false + description: Allows access to the mcmmo help command + children: + mcmmo.commands.mcmmo.help: true + mcmmo.commands.mcgod: + description: Allows access to the mcgod command + mcmmo.commands.mcgod.others: + description: Allows access to the mcgod command for other players + mcmmo.commands.mchud: + description: Allows access to the mchud command + mcmmo.commands.mcmmo.*: + default: false + description: Implies access to all mcmmo.commands.mcmmo permissions + children: + mcmmo.commands.mcmmo.all: true + mcmmo.commands.mcmmo.all: + description: Implies access to all mcmmo.commands.mcmmo permissions. + children: + mcmmo.commands.mcmmo.description: true + mcmmo.commands.mcmmo.help: true + mcmmo.commands.mcmmo.description: + description: Allows access to the mcmmo command + mcmmo.commands.mcmmo.help: + description: Allows access to the mcmmo help command + mcmmo.commands.mcnotify: + description: Allows access to the mcnotify command + mcmmo.commands.mcpurge: + default: false + description: Allows access to the mcpurge command + mcmmo.commands.mcrank: + description: Allows access to the mcrank command + mcmmo.commands.mcrank.others.*: + default: false + description: Implies access to all mcmmo.commands.mcrank.others permissions + children: + mcmmo.commands.mcrank.others.all: true + mcmmo.commands.mcrank.others.all: + description: Implies access to all mcmmo.commands.mcrank.others permissions + children: + mcmmo.commands.mcrank.others: true + mcmmo.commands.mcrank.others.far: true + mcmmo.commands.mcrank.others.offline: true + mcmmo.commands.mcrank.others: + description: Allows access to the mcrank command for other players + mcmmo.commands.mcrank.others.far: + description: Allows access to the mcrank command for far players + mcmmo.commands.mcrank.others.offline: + description: Allows access to the mcrank command for offline players + mcmmo.commands.mcrefresh: + description: Allows access to the mcrefresh command + mcmmo.commands.mcrefresh.others: + description: Allows access to the mcrefresh command for other players + mcmmo.commands.mcremove: + default: false + description: Allows access to the mcremove command + mcmmo.commands.mcstats: + description: Allows access to the mcstats command + mcmmo.commands.mctop.*: + default: false + description: Implies access to all mcmmo.commands.mctop permissions + children: + mcmmo.commands.mctop.all: true + mcmmo.commands.mctop.all: + description: Implies access to all mcmmo.commands.mctop permissions + children: + mcmmo.commands.mctop: true + mcmmo.commands.mctop.acrobatics: true + mcmmo.commands.mctop.archery: true + mcmmo.commands.mctop.axes: true + mcmmo.commands.mctop.excavation: true + mcmmo.commands.mctop.fishing: true + mcmmo.commands.mctop.herbalism: true + mcmmo.commands.mctop.mining: true + mcmmo.commands.mctop.repair: true + mcmmo.commands.mctop.smelting: true + mcmmo.commands.mctop.swords: true + mcmmo.commands.mctop.taming: true + mcmmo.commands.mctop.unarmed: true + mcmmo.commands.mctop.woodcutting: true + mcmmo.commands.mctop: + description: Allows access to the mctop command + mcmmo.commands.mctop.acrobatics: + description: Allows access to the mctop command for acrobatics + mcmmo.commands.mctop.archery: + description: Allows access to the mctop command for archery + mcmmo.commands.mctop.axes: + description: Allows access to the mctop command for axes + mcmmo.commands.mctop.excavation: + description: Allows access to the mctop command for excavation + mcmmo.commands.mctop.fishing: + description: Allows access to the mctop command for fishing + mcmmo.commands.mctop.herbalism: + description: Allows access to the mctop command for herbalism + mcmmo.commands.mctop.mining: + description: Allows access to the mctop command for mining + mcmmo.commands.mctop.repair: + description: Allows access to the mctop command for repair + mcmmo.commands.mctop.smelting: + description: Allows access to the mctop command for smelting + mcmmo.commands.mctop.swords: + description: Allows access to the mctop command for swords + mcmmo.commands.mctop.taming: + description: Allows access to the mctop command for taming + mcmmo.commands.mctop.unarmed: + description: Allows access to the mctop command for unarmed + mcmmo.commands.mctop.woodcutting: + description: Allows access to the mctop command for woodcutting + mcmmo.commands.mining: + description: Allows access to the mining command + mcmmo.commands.mmoedit: + description: Allows access to the mmoedit command + mcmmo.commands.mmoedit.others: + description: Allows access to the mmoedit command for other players + mcmmo.commands.mmoupdate: + default: false + description: Allows access to the mmoupdate command + mcmmo.commands.party.*: + default: false + description: Implies access to all mcmmo.commands.party permissions. + children: + mcmmo.commands.party.all: true + mcmmo.commands.party.all: + description: Implies access to all mcmmo.commands.party permissions. + children: + mcmmo.commands.party: true + mcmmo.commands.party.accept: true + mcmmo.commands.party.chat: true + mcmmo.commands.party.create: true + mcmmo.commands.party.disband: true + mcmmo.commands.party.expshare: true + mcmmo.commands.party.help: true + mcmmo.commands.party.info: true + mcmmo.commands.party.invite: true + mcmmo.commands.party.itemshare: true + mcmmo.commands.party.join: true + mcmmo.commands.party.kick: true + mcmmo.commands.party.lock: true + mcmmo.commands.party.owner: true + mcmmo.commands.party.password: true + mcmmo.commands.party.quit: true + mcmmo.commands.party.rename: true + mcmmo.commands.party.teleport: true + mcmmo.commands.party.unlock: true + mcmmo.commands.party: + description: Allows access to the party command + mcmmo.commands.party.accept: + description: Allows access to the party accept command + mcmmo.commands.party.chat: + description: Dummy permission for mcmmo.chat.partychat + children: + mcmmo.chat.partychat: true + mcmmo.commands.party.create: + description: Allows access to the party create command + mcmmo.commands.party.disband: + description: Allows access to the party disband command + mcmmo.commands.party.expshare: + description: Allows access to the party expshare command + mcmmo.commands.party.help: + description: Allows access to the party help command + mcmmo.commands.party.info: + description: Allows access to the party info command + mcmmo.commands.party.invite: + description: Allows access to the party invite command + mcmmo.commands.party.itemshare: + description: Allows access to the party itemshare command + mcmmo.commands.party.join: + description: Allows access to the party join command + mcmmo.commands.party.kick: + description: Allows access to the party kick command + mcmmo.commands.party.lock: + description: Allows access to the party lock command + mcmmo.commands.party.owner: + description: Allows access to the party owner command + mcmmo.commands.party.password: + description: Allows access to the party password command + mcmmo.commands.party.quit: + description: Allows access to the party quit command + mcmmo.commands.party.rename: + description: Allows access to the party rename command + mcmmo.commands.party.teleport: + description: Dummy permission for mcmmo.commands.ptp + children: + mcmmo.commands.ptp: true + mcmmo.commands.party.unlock: + description: Allows access to the party unlock command + mcmmo.commands.ptp.*: + default: false + description: Implies access to all mcmmo.commands.ptp permissions. + children: + mcmmo.commands.ptp.all: true + mcmmo.commands.ptp.all: + default: false + description: Implies access to all mcmmo.commands.ptp permissions. + children: + mcmmo.commands.ptp: true + mcmmo.commands.ptp.accept: true + mcmmo.commands.ptp.acceptall: true + mcmmo.commands.ptp.toggle: true + mcmmo.commands.ptp.world.all: true + mcmmo.commands.ptp: + description: Allows access to the ptp command + mcmmo.commands.ptp.accept: + description: Allows access to the ptp accept command + mcmmo.commands.ptp.acceptall: + description: Allows access to the ptp acceptall command + mcmmo.commands.ptp.toggle: + description: Allows access to the ptp toggle command + mcmmo.commands.ptp.world.*: + default: false + description: Implies access to all mcmmo.commands.ptp.world permissions. + children: + mcmmo.commands.ptp.world.all: true + mcmmo.commands.ptp.world.all: + description: Implies access to all mcmmo.commands.ptp.world permissions + mcmmo.commands.repair: + description: Allows access to the repair command + mcmmo.commands.skillreset.*: + default: false + description: Implies access to all mcmmo.commands.skillreset permissions + children: + mcmmo.commands.skillreset.all: true + mcmmo.commands.skillreset.all: + description: Implies access to all mcmmo.commands.skillreset permissions + children: + mcmmo.commands.skillreset: true + mcmmo.commands.skillreset.acrobatics: true + mcmmo.commands.skillreset.archery: true + mcmmo.commands.skillreset.axes: true + mcmmo.commands.skillreset.excavation: true + mcmmo.commands.skillreset.fishing: true + mcmmo.commands.skillreset.herbalism: true + mcmmo.commands.skillreset.mining: true + mcmmo.commands.skillreset.others.all: true + mcmmo.commands.skillreset.repair: true + mcmmo.commands.skillreset.smelting: true + mcmmo.commands.skillreset.swords: true + mcmmo.commands.skillreset.taming: true + mcmmo.commands.skillreset.unarmed: true + mcmmo.commands.skillreset.woodcutting: true + mcmmo.commands.skillreset: + description: Allows access to the skillreset command + mcmmo.commands.skillreset.acrobatics: + description: Allows access to the skillreset command for acrobatics + mcmmo.commands.skillreset.archery: + description: Allows access to the skillreset command for archery + mcmmo.commands.skillreset.axes: + description: Allows access to the skillreset command for axes + mcmmo.commands.skillreset.excavation: + description: Allows access to the skillreset command for excavation + mcmmo.commands.skillreset.fishing: + description: Allows access to the skillreset command for fishing + mcmmo.commands.skillreset.herbalism: + description: Allows access to the skillreset command for herbalism + mcmmo.commands.skillreset.mining: + description: Allows access to the skillreset command for mining + mcmmo.commands.skillreset.others.*: + default: false + description: Implies access to all mcmmo.commands.skillreset.others permissions + children: + mcmmo.commands.skillreset.others.all: true + mcmmo.commands.skillreset.others.all: + description: Implies access to all mcmmo.commands.skillreset.others permissions + children: + mcmmo.commands.skillreset.others: true + mcmmo.commands.skillreset.others.acrobatics: true + mcmmo.commands.skillreset.others.archery: true + mcmmo.commands.skillreset.others.axes: true + mcmmo.commands.skillreset.others.excavation: true + mcmmo.commands.skillreset.others.fishing: true + mcmmo.commands.skillreset.others.herbalism: true + mcmmo.commands.skillreset.others.mining: true + mcmmo.commands.skillreset.others.repair: true + mcmmo.commands.skillreset.others.smelting: true + mcmmo.commands.skillreset.others.swords: true + mcmmo.commands.skillreset.others.taming: true + mcmmo.commands.skillreset.others.unarmed: true + mcmmo.commands.skillreset.others.woodcutting: true + mcmmo.commands.skillreset.others: + description: Allows access to the skillreset command for other players + mcmmo.commands.skillreset.others.acrobatics: + description: Allows access to the skillreset command for acrobatics for other players + mcmmo.commands.skillreset.others.archery: + description: Allows access to the skillreset command for archery for other players + mcmmo.commands.skillreset.others.axes: + description: Allows access to the skillreset command for axes for other players + mcmmo.commands.skillreset.others.excavation: + description: Allows access to the skillreset command for excavation for other players + mcmmo.commands.skillreset.others.fishing: + description: Allows access to the skillreset command for fishing for other players + mcmmo.commands.skillreset.others.herbalism: + description: Allows access to the skillreset command for herbalism for other players + mcmmo.commands.skillreset.others.mining: + description: Allows access to the skillreset command for mining for other players + mcmmo.commands.skillreset.others.repair: + description: Allows access to the skillreset command for repair for other players + mcmmo.commands.skillreset.others.smelting: + description: Allows access to the skillreset command for smelting for other players + mcmmo.commands.skillreset.others.swords: + description: Allows access to the skillreset command for swords for other players + mcmmo.commands.skillreset.others.taming: + description: Allows access to the skillreset command for taming for other players + mcmmo.commands.skillreset.others.unarmed: + description: Allows access to the skillreset command for unarmed for other players + mcmmo.commands.skillreset.others.woodcutting: + description: Allows access to the skillreset command for woodcutting for other players + mcmmo.commands.skillreset.repair: + description: Allows access to the skillreset command for repair + mcmmo.commands.skillreset.smelting: + description: Allows access to the skillreset command for smelting + mcmmo.commands.skillreset.swords: + description: Allows access to the skillreset command for swords + mcmmo.commands.skillreset.taming: + description: Allows access to the skillreset command for taming + mcmmo.commands.skillreset.unarmed: + description: Allows access to the skillreset command for unarmed + mcmmo.commands.skillreset.woodcutting: + description: Allows access to the skillreset command for woodcutting + mcmmo.commands.smelting: + description: Allows access to the smelting command + mcmmo.commands.swords: + description: Allows access to the swords command + mcmmo.commands.taming: + description: Allows access to the taming command + mcmmo.commands.unarmed: + description: Allows access to the unarmed command + mcmmo.commands.vampirism.*: + default: false + description: Implies access to all mcmmo.commands.vampirism permissions + children: + mcmmo.commands.vampirism.all: true + mcmmo.commands.vampirism.all: + description: Implies access to all mcmmo.commands.vampirism permissions + children: + mcmmo.commands.vampirism: true + mcmmo.commands.vampirism.modify: true + mcmmo.commands.vampirism.toggle: true + mcmmo.commands.vampirism: + description: Allows access to the vampirism command + mcmmo.commands.vampirism.modify: + description: Allows access to the vampirism command to modify the vampirism rate + mcmmo.commands.vampirism.toggle: + description: Allows access to the vampirism command to toggle vampirism on/off + mcmmo.commands.woodcutting: + description: Allows access to the woodcutting command + mcmmo.commands.xplock.*: + default: false + description: Implies access to all mcmmo.commands.xplock permissions + children: + mcmmo.commands.xplock.all: true + mcmmo.commands.xplock.all: + description: Implies access to all mcmmo.commands.xplock permissions + children: + mcmmo.commands.xplock: true + mcmmo.commands.xplock.acrobatics: true + mcmmo.commands.xplock.archery: true + mcmmo.commands.xplock.axes: true + mcmmo.commands.xplock.excavation: true + mcmmo.commands.xplock.fishing: true + mcmmo.commands.xplock.herbalism: true + mcmmo.commands.xplock.mining: true + mcmmo.commands.xplock.repair: true + mcmmo.commands.xplock.smelting: true + mcmmo.commands.xplock.swords: true + mcmmo.commands.xplock.taming: true + mcmmo.commands.xplock.unarmed: true + mcmmo.commands.xplock.woodcutting: true + mcmmo.commands.xplock: + description: Allows access to the xplock command + mcmmo.commands.xplock.acrobatics: + description: Allows access to the xplock command for acrobatics + mcmmo.commands.xplock.archery: + description: Allows access to the xplock command for archery + mcmmo.commands.xplock.axes: + description: Allows access to the xplock command for axes + mcmmo.commands.xplock.excavation: + description: Allows access to the xplock command for excavation + mcmmo.commands.xplock.fishing: + description: Allows access to the xplock command for fishing + mcmmo.commands.xplock.herbalism: + description: Allows access to the xplock command for herbalism + mcmmo.commands.xplock.mining: + description: Allows access to the xplock command for mining + mcmmo.commands.xplock.repair: + description: Allows access to the xplock command for repair + mcmmo.commands.xplock.smelting: + description: Allows access to the xplock command for smelting + mcmmo.commands.xplock.swords: + description: Allows access to the xplock command for swords + mcmmo.commands.xplock.taming: + description: Allows access to the xplock command for taming + mcmmo.commands.xplock.unarmed: + description: Allows access to the xplock command for unarmed + mcmmo.commands.xplock.woodcutting: + description: Allows access to the xplock command for woodcutting + mcmmo.commands.xprate.*: + default: false + description: Implies access to all mcmmo.commands.xprate permissions + children: + mcmmo.commands.xprate.all: true + mcmmo.commands.xprate.all: + description: Implies access to all mcmmo.commands.xprate permissions + children: + mcmmo.commands.xprate: true + mcmmo.commands.xprate.reset: true + mcmmo.commands.xprate.set: true + mcmmo.commands.xprate: + description: Allows access to the xprate command + mcmmo.commands.xprate.reset: + description: Allows access to the xprate reset command + mcmmo.commands.xprate.set: + description: Allows access to the xprate command to control xp events + mcmmo.defaults: + default: true + description: mcmmo permisions that default to true + children: + mcmmo.chat.partychat: true + mcmmo.commands.defaults: true + mcmmo.motd: true + mcmmo.skills.all: true + mcmmo.defaultsop: + default: op + description: mcmmo permissions that default to op + children: + mcmmo.chat.adminchat: true + mcmmo.commands.defaultsop: true + mcmmo.item.all: true + mcmmo.tools.updatecheck: true + mcmmo.item.*: + default: false + description: Implies all mcmmo.item permissions + children: + mcmmo.item.all: true + mcmmo.item.all: + description: Implies all mcmmo.item permissions + children: + mcmmo.item.chimaerawing: true + mcmmo.item.chimaerawing: + description: Allows use of Chimaera Wing item + mcmmo.motd: + description: Allows access to the motd + mcmmo.party.*: + default: false + description: Implies access to all mcmmo party permissions + children: + mcmmo.party.all: true + mcmmo.party.all: + default: false + description: Implies access to all mcmmo party permissions + children: + mcmmo.party.friendlyfire: true + mcmmo.party.friendlyfire: + default: false + description: Allows in-party friendly fire if both attacker and victim have this permission + mcmmo.perks.*: + default: false + description: implies access to all mcmmo perks + children: + mcmmo.perks.all: true + mcmmo.perks.all: + default: false + description: implies access to all mcmmo perks + children: + mcmmo.perks.activationtime.all: true + mcmmo.perks.cooldowns.all: true + mcmmo.perks.lucky.all: true + mcmmo.perks.xp.all: true + mcmmo.perks.activationtime.*: + default: false + description: Increased activation time perks typically given to donors or VIPs + children: + mcmmo.perks.activationtime.all: true + mcmmo.perks.activationtime.all: + default: false + description: Increased activation time perks typically given to donors or VIPs + children: + mcmmo.perks.activationtime.eightseconds: true + mcmmo.perks.activationtime.fourseconds: true + mcmmo.perks.activationtime.twelveseconds: true + mcmmo.perks.activationtime.eightseconds: + default: false + description: Increases activation time by 8 seconds + mcmmo.perks.activationtime.fourseconds: + default: false + description: Increases activation time by 4 seconds + mcmmo.perks.activationtime.twelveseconds: + default: false + description: Increases activation time by 12 seconds + mcmmo.perks.cooldowns.*: + default: false + description: Reduced cooldown perks typically given to donors or VIPs + children: + mcmmo.perks.cooldowns.all: true + mcmmo.perks.cooldowns.all: + default: false + description: Reduced cooldown perks typically given to donors or VIPs + children: + mcmmo.perks.cooldowns.halved: true + mcmmo.perks.cooldowns.quartered: true + mcmmo.perks.cooldowns.thirded: true + mcmmo.perks.cooldowns.halved: + default: false + description: Cuts cooldowns down by 1/2 + mcmmo.perks.cooldowns.quartered: + default: false + description: Cuts cooldowns down by 1/4 + mcmmo.perks.cooldowns.thirded: + default: false + description: Cuts cooldowns down by 1/3 + mcmmo.perks.lucky.*: + default: false + description: Gives all abilities & skills a 33.3% better chance to activate. + children: + mcmmo.perks.lucky.all: true + mcmmo.perks.lucky.all: + default: false + description: Gives all abilities & skills a 33.3% better chance to activate. + children: + mcmmo.perks.lucky.acrobatics: true + mcmmo.perks.lucky.archery: true + mcmmo.perks.lucky.axes: true + mcmmo.perks.lucky.excavation: true + mcmmo.perks.lucky.fishing: true + mcmmo.perks.lucky.herbalism: true + mcmmo.perks.lucky.mining: true + mcmmo.perks.lucky.repair: true + mcmmo.perks.lucky.smelting: true + mcmmo.perks.lucky.swords: true + mcmmo.perks.lucky.taming: true + mcmmo.perks.lucky.unarmed: true + mcmmo.perks.lucky.woodcutting: true + mcmmo.perks.lucky.acrobatics: + default: false + description: Gives Acrobatics abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.archery: + default: false + description: Gives Archery abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.axes: + default: false + description: Gives Axes abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.excavation: + default: false + description: Gives Excavation abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.fishing: + default: false + description: Gives Fishing abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.herbalism: + default: false + description: Gives Herbalism abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.mining: + default: false + description: Gives Mining abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.repair: + default: false + description: Gives Repair abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.smelting: + default: false + description: Gives Smelting abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.swords: + default: false + description: Gives Swords abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.taming: + default: false + description: Gives Taming abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.unarmed: + default: false + description: Gives Unarmed abilities & skills a 33.3% better chance to activate. + mcmmo.perks.lucky.woodcutting: + default: false + description: Gives Woodcutting abilities & skills a 33.3% better chance to activate. + mcmmo.perks.xp.*: + default: false + description: XP Perks typically given to donors or VIPs + children: + mcmmo.perks.xp.all: true + mcmmo.perks.xp.all: + default: false + description: XP Perks typically given to donors or VIPs + children: + mcmmo.perks.xp.150percentboost: true + mcmmo.perks.xp.50percentboost: true + mcmmo.perks.xp.double: true + mcmmo.perks.xp.quadruple: true + mcmmo.perks.xp.triple: true + mcmmo.perks.xp.150percentboost: + default: false + description: Mulitplies incoming XP by 2.5 + mcmmo.perks.xp.50percentboost: + default: false + description: Mulitplies incoming XP by 1.5 + mcmmo.perks.xp.double: + default: false + description: Doubles incoming XP + mcmmo.perks.xp.quadruple: + default: false + description: Quadruples incoming XP + mcmmo.perks.xp.triple: + default: false + description: Triples incoming XP + mcmmo.skillreset: + default: false + description: Allow reset of skill levels + children: + mcmmo.commands.skillreset.all: true + mcmmo.commands.skillreset.others.all: false + mcmmo.skills.*: + default: false + description: Implies all mcmmo.skills permissions. + children: + mcmmo.skills.all: true + mcmmo.skills.all: + description: Implies all mcmmo.skills permissions. + children: + mcmmo.skills.acrobatics: true + mcmmo.skills.archery: true + mcmmo.skills.axes: true + mcmmo.skills.excavation: true + mcmmo.skills.fishing: true + mcmmo.skills.herbalism: true + mcmmo.skills.mining: true + mcmmo.skills.repair: true + mcmmo.skills.swords: true + mcmmo.skills.smelting: true + mcmmo.skills.taming: true + mcmmo.skills.unarmed: true + mcmmo.skills.woodcutting: true + mcmmo.skills.acrobatics: + description: Allows access to the Acrobatics skill + children: + mcmmo.ability.acrobatics.all: true + mcmmo.commands.acrobatics: true + mcmmo.commands.xplock.acrobatics: true + mcmmo.skills.archery: + description: Allows access to the Archery skill + children: + mcmmo.ability.archery.all: true + mcmmo.commands.archery: true + mcmmo.commands.xplock.archery: true + mcmmo.skills.axes: + description: Allows access to the Axes skill + children: + mcmmo.ability.axes.all: true + mcmmo.commands.axes: true + mcmmo.commands.xplock.axes: true + mcmmo.skills.excavation: + description: Allows access to the Excavation skill + children: + mcmmo.ability.excavation.all: true + mcmmo.commands.excavation: true + mcmmo.commands.xplock.excavation: true + mcmmo.skills.fishing: + description: Allows access to the Fishing skill + children: + mcmmo.ability.fishing.all: true + mcmmo.commands.fishing: true + mcmmo.commands.xplock.fishing: true + mcmmo.skills.herbalism: + description: Allows access to the Herbalism skill + children: + mcmmo.ability.herbalism.all: true + mcmmo.commands.herbalism: true + mcmmo.commands.xplock.herbalism: true + mcmmo.skills.mining: + description: Allows access to the Mining skill + children: + mcmmo.ability.mining.all: true + mcmmo.commands.mining: true + mcmmo.commands.xplock.mining: true + mcmmo.skills.repair: + description: Allows access to the Repair skill + children: + mcmmo.ability.repair.all: true + mcmmo.commands.repair: true + mcmmo.commands.xplock.repair: true + mcmmo.skills.smelting: + description: Allows access to the Smelting skill + children: + mcmmo.ability.smelting.all: true + mcmmo.commands.smelting: true + mcmmo.commands.xplock.smelting: true + mcmmo.skills.swords: + description: Allows access to the Swords skill + children: + mcmmo.ability.swords.all: true + mcmmo.commands.swords: true + mcmmo.commands.xplock.swords: true + mcmmo.skills.taming: + description: Allows access to the Taming skill + children: + mcmmo.ability.taming.all: true + mcmmo.commands.taming: true + mcmmo.commands.xplock.taming: true + mcmmo.skills.unarmed: + description: Allows access to the Unarmed skill + children: + mcmmo.ability.unarmed.all: true + mcmmo.commands.unarmed: true + mcmmo.commands.xplock.unarmed: true + mcmmo.skills.woodcutting: + description: Allows access to the Woodcutting skill + children: + mcmmo.ability.woodcutting.all: true + mcmmo.commands.woodcutting: true + mcmmo.commands.xplock.woodcutting: true + mcmmo.tools.*: + default: false + description: Implies all mcmmo.tools permissions. + children: + mcmmo.tools.all: true + mcmmo.tools.all: + default: false + description: Implies all mcmmo.tools permissions. + children: + mcmmo.tools.mcgod: true + mcmmo.tools.mcrefresh: true + mcmmo.tools.mcremove: true + mcmmo.tools.mmoedit: true + mcmmo.tools.updatecheck: true + mcmmo.tools.mcgod: + default: false + description: Allows access to mcgod command + children: + mcmmo.commands.mcgod: true + mcmmo.tools.mcrefresh: + default: false + description: Allows access to mcrefresh command + children: + mcmmo.commands.mcrefresh: true + mcmmo.commands.mcrefresh.others: true + mcmmo.tools.mcremove: + default: false + decription: Allows access to mcremove and mcpurge command + children: + mcmmo.commands.mcremove: true + mcmmo.tools.mmoedit: + default: false + description: Allows access to mmoedit command + children: + mcmmo.commands.addlevels: true + mcmmo.commands.addlevels.others: true + mcmmo.commands.addxp: true + mcmmo.commands.addxp.others: true + mcmmo.commands.mcpurge: true + mcmmo.commands.mmoedit: true + mcmmo.commands.mmoedit.others: true + mcmmo.tools.updatecheck: + default: false + description: Notifies admins if there is a new version of mcMMO available diff --git a/src/main/resources/spout.yml b/src/main/resources/spout.yml index e9244bd2d..edb72711e 100644 --- a/src/main/resources/spout.yml +++ b/src/main/resources/spout.yml @@ -1,72 +1,72 @@ -Menu: - Key: KEY_M -XP: - Bar: - Enabled: true - X_POS: 95 - Y_POS: 6 - Icon: - Enabled: true - X_POS: 78 - Y_POS: 2 -HUD: - Show_Power_Level: true - Default: STANDARD - Retro: - Colors: - Swords: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Taming: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Acrobatics: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Border: - BLUE: 0.0 - GREEN: 0.0 - RED: 0.0 - Background: - BLUE: 0.75 - GREEN: 0.75 - RED: 0.75 - Woodcutting: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Archery: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Axes: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Repair: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Fishing: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Excavation: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Herbalism: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Unarmed: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 - Mining: - BLUE: 0.75 - GREEN: 0.3 - RED: 0.3 +Menu: + Key: KEY_M +XP: + Bar: + Enabled: true + X_POS: 95 + Y_POS: 6 + Icon: + Enabled: true + X_POS: 78 + Y_POS: 2 +HUD: + Show_Power_Level: true + Default: STANDARD + Retro: + Colors: + Swords: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Taming: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Acrobatics: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Border: + BLUE: 0.0 + GREEN: 0.0 + RED: 0.0 + Background: + BLUE: 0.75 + GREEN: 0.75 + RED: 0.75 + Woodcutting: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Archery: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Axes: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Repair: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Fishing: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Excavation: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Herbalism: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Unarmed: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 + Mining: + BLUE: 0.75 + GREEN: 0.3 + RED: 0.3 diff --git a/src/main/resources/tools.yml b/src/main/resources/tools.yml index 6fa579749..e3fe63efd 100644 --- a/src/main/resources/tools.yml +++ b/src/main/resources/tools.yml @@ -1,149 +1,149 @@ -# -# Settings for Axes -### -Axes: - Axe_1: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Axe_2: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - -# -# Settings for Bows -### -Bows: - Bow_1: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Bow_2: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - -# -# Settings for Hoes -### -Hoes: - Hoe_1: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Hoe_2: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - -# -# Settings for Pickaxes -### -Pickaxes: - Pickaxe_1: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Pickaxe_2: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - -# -# Settings for Shovels -### -Shovels: - Shovel_1: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Shovel_2: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - -# -# Settings for Swords -### -Swords: - Sword_1: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 - Sword_2: - ID: 999 - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material_ID: 99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 +# +# Settings for Axes +### +Axes: + Axe_1: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Axe_2: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + +# +# Settings for Bows +### +Bows: + Bow_1: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Bow_2: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + +# +# Settings for Hoes +### +Hoes: + Hoe_1: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Hoe_2: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + +# +# Settings for Pickaxes +### +Pickaxes: + Pickaxe_1: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Pickaxe_2: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + +# +# Settings for Shovels +### +Shovels: + Shovel_1: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Shovel_2: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + +# +# Settings for Swords +### +Swords: + Sword_1: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 + Sword_2: + ID: 999 + XP_Modifer: 1.0 + Ability_Enabled: true + Tier: 1 + Repairable: true + Repair_Material_ID: 99 + Repair_Material_Data_Value: 0 + Repair_Material_Quantity: 9 + Durability: 9999 diff --git a/src/main/resources/treasures.yml b/src/main/resources/treasures.yml index 7ec8647fc..f44983eee 100644 --- a/src/main/resources/treasures.yml +++ b/src/main/resources/treasures.yml @@ -1,971 +1,971 @@ -# -# Settings for Fishing -### -Fishing: - Treasure: - - Leather_Boots - - Leather_Helmet - - Leather_Leggings - - Leather_Chestplate - - Wooden_Sword - - Wooden_Shovel - - Wooden_Pickaxe - - Wooden_Axe - - Wooden_Hoe - - Stone_Sword - - Stone_Shovel - - Stone_Pickaxe - - Stone_Axe - - Stone_Hoe - - Iron_Sword - - Iron_Shovel - - Iron_Pickaxe - - Iron_Axe - - Iron_Hoe - - Iron_Boots - - Iron_Helmet - - Iron_Leggings - - Iron_Chestplate - - Ender_Pearl - - Gold_Sword - - Gold_Shovel - - Gold_Pickaxe - - Gold_Axe - - Gold_Hoe - - Gold_Boots - - Gold_Helmet - - Gold_Leggings - - Gold_Chestplate - - Blaze_Rod - - Record_3 - - Record_4 - - Record_5 - - Record_6 - - Record_7 - - Record_8 - - Record_9 - - Record_10 - - Record_11 - - Record_12 - - Diamond_Sword - - Diamond_Shovel - - Diamond_Pickaxe - - Diamond_Axe - - Diamond_Hoe - - Diamond_Boots - - Diamond_Helmet - - Diamond_Leggings - - Diamond_Chestplate - - Ghast_Tear - - Diamonds - - Iron_Ingots - - Gold_Ingots - - Lapis_Lazuli -# -# Settings for Excavation -### -Excavation: - Treasure: - - Cake - - Gunpowder - - Bone - - Apple - - Slimeball - - Bucket - - Netherrack - - Red_Mushroom - - Brown_Mushroom - - Egg - - Soul_Sand - - Clock - - Cobweb - - String - - Glowstone_Dust - - Gold_Music - - Green_Music - - Diamond - - Cocoa_Beans -# -# Settings for Hylian Luck -### -Hylian_Luck: - Treasure: - - Melon_Seeds - - Pumpkin_Seeds - - Cocoa - - Carrot - - Potato - - Apples - - Emeralds - - Diamond_Gem - - Gold_Nuggets -# -# Configuration to define Treasures -### -Treasures: - Cake: - ID: 354 - Data: 0 - Amount: 1 - XP: 3000 - Drop_Chance: 0.05 - Drop_Level: 750 - Drops_From: - Dirt: true - Grass: true - Sand: true - Gravel: true - Clay: true - Mycelium: true - Soul_Sand: true - Gunpowder: - ID: 289 - Data: 0 - Amount: 1 - XP: 30 - Drop_Chance: 10.0 - Drop_Level: 75 - Drops_From: - Gravel: true - Bone: - ID: 352 - Data: 0 - Amount: 1 - XP: 30 - Drop_Chance: 10.0 - Drop_Level: 175 - Drops_From: - Gravel: true - Apple: - ID: 260 - Data: 0 - Amount: 1 - XP: 100 - Drop_Chance: 0.1 - Drop_Level: 250 - Drops_From: - Grass: true - Mycelium: true - Slimeball: - ID: 341 - Data: 0 - Amount: 1 - XP: 100 - Drop_Chance: 5.0 - Drop_Level: 150 - Drops_From: - Clay: true - Bucket: - ID: 325 - Data: 0 - Amount: 1 - XP: 100 - Drop_Chance: 0.1 - Drop_Level: 500 - Drops_From: - Clay: true - Netherrack: - ID: 87 - Data: 0 - Amount: 1 - XP: 30 - Drop_Chance: 0.5 - Drop_Level: 850 - Drops_From: - Gravel: true - Red_Mushroom: - ID: 40 - Data: 0 - Amount: 1 - XP: 80 - Drop_Chance: 0.5 - Drop_Level: 500 - Drops_From: - Dirt: true - Grass: true - Mycelium: true - Brown_Mushroom: - ID: 39 - Data: 0 - Amount: 1 - XP: 80 - Drop_Chance: 0.5 - Drop_Level: 500 - Drops_From: - Dirt: true - Grass: true - Mycelium: true - Egg: - ID: 344 - Data: 0 - Amount: 1 - XP: 100 - Drop_Chance: 1.0 - Drop_Level: 250 - Drops_From: - Grass: true - Soul_Sand: - ID: 88 - Data: 0 - Amount: 1 - XP: 80 - Drop_Chance: 0.5 - Drop_Level: 650 - Drops_From: - Sand: true - Clock: - ID: 347 - Data: 0 - Amount: 1 - XP: 100 - Drop_Chance: 0.1 - Drop_Level: 500 - Drops_From: - Clay: true - Cobweb: - ID: 30 - Data: 0 - Amount: 1 - XP: 150 - Drop_Chance: 5.0 - Drop_Level: 750 - Drops_From: - Clay: true - String: - ID: 287 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 5.0 - Drop_Level: 250 - Drops_From: - Clay: true - Glowstone_Dust: - ID: 348 - Data: 0 - Amount: 1 - XP: 80 - Drop_Chance: 5.0 - Drop_Level: 25 - Drops_From: - Dirt: true - Grass: true - Sand: true - Mycelium: true - Gold_Music: - ID: 2256 - Data: 0 - Amount: 1 - XP: 3000 - Drop_Chance: 0.05 - Drop_Level: 250 - Drops_From: - Dirt: true - Grass: true - Sand: true - Gravel: true - Clay: true - Mycelium: true - Soul_Sand: true - Green_Music: - ID: 2257 - Data: 0 - Amount: 1 - XP: 3000 - Drop_Chance: 0.05 - Drop_Level: 250 - Drops_From: - Dirt: true - Grass: true - Sand: true - Gravel: true - Clay: true - Mycelium: true - Soul_Sand: true - Diamond: - ID: 264 - Data: 0 - Amount: 1 - XP: 1000 - Drop_Chance: 0.13 - Drop_Level: 350 - Drops_From: - Dirt: true - Grass: true - Sand: true - Gravel: true - Clay: true - Mycelium: true - Soul_Sand: true - Cocoa_Beans: - ID: 351 - Data: 3 - Amount: 1 - XP: 100 - Drop_Chance: 1.33 - Drop_Level: 350 - Drops_From: - Dirt: true - Grass: true - Mycelium: true - Leather_Boots: - ID: 301 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 400 - Drops_From: - Fishing: true - Leather_Helmet: - ID: 298 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 400 - Drops_From: - Fishing: true - Leather_Leggings: - ID: 300 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 400 - Drops_From: - Fishing: true - Leather_Chestplate: - ID: 299 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 400 - Drops_From: - Fishing: true - Wooden_Sword: - ID: 268 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 200 - Drops_From: - Fishing: true - Wooden_Shovel: - ID: 269 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 200 - Drops_From: - Fishing: true - Wooden_Pickaxe: - ID: 270 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 200 - Drops_From: - Fishing: true - Wooden_Axe: - ID: 271 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 200 - Drops_From: - Fishing: true - Wooden_Hoe: - ID: 290 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 200 - Drops_From: - Fishing: true - Stone_Sword: - ID: 272 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 400 - Drops_From: - Fishing: true - Stone_Shovel: - ID: 273 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 400 - Drops_From: - Fishing: true - Stone_Pickaxe: - ID: 274 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 400 - Drops_From: - Fishing: true - Stone_Axe: - ID: 275 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 400 - Drops_From: - Fishing: true - Stone_Hoe: - ID: 291 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 20.0 - Drop_Level: 0 - Max_Level: 400 - Drops_From: - Fishing: true - Iron_Sword: - ID: 267 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Iron_Shovel: - ID: 256 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Iron_Pickaxe: - ID: 257 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Iron_Axe: - ID: 258 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Iron_Hoe: - ID: 292 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Iron_Boots: - ID: 309 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Iron_Helmet: - ID: 306 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Iron_Leggings: - ID: 308 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Iron_Chestplate: - ID: 307 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Ender_Pearl: - ID: 368 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 25.0 - Drop_Level: 200 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Sword: - ID: 283 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Shovel: - ID: 284 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Pickaxe: - ID: 285 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Axe: - ID: 286 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Hoe: - ID: 294 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Boots: - ID: 317 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Helmet: - ID: 314 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Leggings: - ID: 316 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Chestplate: - ID: 315 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Blaze_Rod: - ID: 369 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Record_3: - ID: 2258 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Record_4: - ID: 2259 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Record_5: - ID: 2260 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 30.0 - Drop_Level: 400 - Max_Level: -1 - Drops_From: - Fishing: true - Diamond_Sword: - ID: 276 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Diamond_Shovel: - ID: 277 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Diamond_Pickaxe: - ID: 278 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Diamond_Axe: - ID: 279 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Diamond_Hoe: - ID: 293 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Diamond_Boots: - ID: 313 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Diamond_Helmet: - ID: 310 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Diamond_Leggings: - ID: 312 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Diamond_Chestplate: - ID: 311 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Record_6: - ID: 2261 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Record_7: - ID: 2262 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Record_8: - ID: 2263 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Record_9: - ID: 2264 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Record_10: - ID: 2265 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Record_11: - ID: 2266 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Record_12: - ID: 2267 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Ghast_Tear: - ID: 370 - Data: 0 - Amount: 1 - XP: 200 - Drop_Chance: 35.0 - Drop_Level: 600 - Max_Level: -1 - Drops_From: - Fishing: true - Diamonds: - ID: 264 - Data: 0 - Amount: 5 - XP: 200 - Drop_Chance: 40.0 - Drop_Level: 800 - Max_Level: -1 - Drops_From: - Fishing: true - Iron_Ingots: - ID: 265 - Data: 0 - Amount: 5 - XP: 200 - Drop_Chance: 40.0 - Drop_Level: 800 - Max_Level: -1 - Drops_From: - Fishing: true - Gold_Ingots: - ID: 266 - Data: 0 - Amount: 5 - XP: 200 - Drop_Chance: 40.0 - Drop_Level: 800 - Max_Level: -1 - Drops_From: - Fishing: true - Lapis_Lazuli: - ID: 351 - Data: 4 - Amount: 20 - XP: 200 - Drop_Chance: 40.0 - Drop_Level: 800 - Max_Level: -1 - Drops_From: - Fishing: true - Melon_Seeds: - ID: 362 - Data: 0 - Amount: 1 - XP: 0 - Drop_Chance: 100.0 - Drop_Level: 0 - Drops_From: - Bushes: true - Pumpkin_Seeds: - ID: 361 - Data: 0 - Amount: 1 - XP: 0 - Drop_Chance: 100.0 - Drop_Level: 0 - Drops_From: - Bushes: true - Cocoa: - ID: 351 - Data: 3 - Amount: 1 - XP: 0 - Drop_Chance: 100.0 - Drop_Level: 0 - Drops_From: - Bushes: true - Carrot: - ID: 391 - Data: 0 - Amount: 1 - XP: 0 - Drop_Chance: 100.0 - Drop_Level: 0 - Drops_From: - Flowers: true - Potato: - ID: 392 - Data: 0 - Amount: 1 - XP: 0 - Drop_Chance: 100.0 - Drop_Level: 0 - Drops_From: - Flowers: true - Apples: - ID: 260 - Data: 0 - Amount: 1 - XP: 0 - Drop_Chance: 100.0 - Drop_Level: 0 - Drops_From: - Flowers: true - Emeralds: - ID: 388 - Data: 0 - Amount: 1 - XP: 0 - Drop_Chance: 100.0 - Drop_Level: 0 - Drops_From: - Pots: true - Diamond_Gem: - ID: 264 - Data: 0 - Amount: 1 - XP: 0 - Drop_Chance: 100.0 - Drop_Level: 0 - Drops_From: - Pots: true - Gold_Nuggets: - ID: 371 - Data: 0 - Amount: 1 - XP: 0 - Drop_Chance: 100.0 - Drop_Level: 0 - Drops_From: +# +# Settings for Fishing +### +Fishing: + Treasure: + - Leather_Boots + - Leather_Helmet + - Leather_Leggings + - Leather_Chestplate + - Wooden_Sword + - Wooden_Shovel + - Wooden_Pickaxe + - Wooden_Axe + - Wooden_Hoe + - Stone_Sword + - Stone_Shovel + - Stone_Pickaxe + - Stone_Axe + - Stone_Hoe + - Iron_Sword + - Iron_Shovel + - Iron_Pickaxe + - Iron_Axe + - Iron_Hoe + - Iron_Boots + - Iron_Helmet + - Iron_Leggings + - Iron_Chestplate + - Ender_Pearl + - Gold_Sword + - Gold_Shovel + - Gold_Pickaxe + - Gold_Axe + - Gold_Hoe + - Gold_Boots + - Gold_Helmet + - Gold_Leggings + - Gold_Chestplate + - Blaze_Rod + - Record_3 + - Record_4 + - Record_5 + - Record_6 + - Record_7 + - Record_8 + - Record_9 + - Record_10 + - Record_11 + - Record_12 + - Diamond_Sword + - Diamond_Shovel + - Diamond_Pickaxe + - Diamond_Axe + - Diamond_Hoe + - Diamond_Boots + - Diamond_Helmet + - Diamond_Leggings + - Diamond_Chestplate + - Ghast_Tear + - Diamonds + - Iron_Ingots + - Gold_Ingots + - Lapis_Lazuli +# +# Settings for Excavation +### +Excavation: + Treasure: + - Cake + - Gunpowder + - Bone + - Apple + - Slimeball + - Bucket + - Netherrack + - Red_Mushroom + - Brown_Mushroom + - Egg + - Soul_Sand + - Clock + - Cobweb + - String + - Glowstone_Dust + - Gold_Music + - Green_Music + - Diamond + - Cocoa_Beans +# +# Settings for Hylian Luck +### +Hylian_Luck: + Treasure: + - Melon_Seeds + - Pumpkin_Seeds + - Cocoa + - Carrot + - Potato + - Apples + - Emeralds + - Diamond_Gem + - Gold_Nuggets +# +# Configuration to define Treasures +### +Treasures: + Cake: + ID: 354 + Data: 0 + Amount: 1 + XP: 3000 + Drop_Chance: 0.05 + Drop_Level: 750 + Drops_From: + Dirt: true + Grass: true + Sand: true + Gravel: true + Clay: true + Mycelium: true + Soul_Sand: true + Gunpowder: + ID: 289 + Data: 0 + Amount: 1 + XP: 30 + Drop_Chance: 10.0 + Drop_Level: 75 + Drops_From: + Gravel: true + Bone: + ID: 352 + Data: 0 + Amount: 1 + XP: 30 + Drop_Chance: 10.0 + Drop_Level: 175 + Drops_From: + Gravel: true + Apple: + ID: 260 + Data: 0 + Amount: 1 + XP: 100 + Drop_Chance: 0.1 + Drop_Level: 250 + Drops_From: + Grass: true + Mycelium: true + Slimeball: + ID: 341 + Data: 0 + Amount: 1 + XP: 100 + Drop_Chance: 5.0 + Drop_Level: 150 + Drops_From: + Clay: true + Bucket: + ID: 325 + Data: 0 + Amount: 1 + XP: 100 + Drop_Chance: 0.1 + Drop_Level: 500 + Drops_From: + Clay: true + Netherrack: + ID: 87 + Data: 0 + Amount: 1 + XP: 30 + Drop_Chance: 0.5 + Drop_Level: 850 + Drops_From: + Gravel: true + Red_Mushroom: + ID: 40 + Data: 0 + Amount: 1 + XP: 80 + Drop_Chance: 0.5 + Drop_Level: 500 + Drops_From: + Dirt: true + Grass: true + Mycelium: true + Brown_Mushroom: + ID: 39 + Data: 0 + Amount: 1 + XP: 80 + Drop_Chance: 0.5 + Drop_Level: 500 + Drops_From: + Dirt: true + Grass: true + Mycelium: true + Egg: + ID: 344 + Data: 0 + Amount: 1 + XP: 100 + Drop_Chance: 1.0 + Drop_Level: 250 + Drops_From: + Grass: true + Soul_Sand: + ID: 88 + Data: 0 + Amount: 1 + XP: 80 + Drop_Chance: 0.5 + Drop_Level: 650 + Drops_From: + Sand: true + Clock: + ID: 347 + Data: 0 + Amount: 1 + XP: 100 + Drop_Chance: 0.1 + Drop_Level: 500 + Drops_From: + Clay: true + Cobweb: + ID: 30 + Data: 0 + Amount: 1 + XP: 150 + Drop_Chance: 5.0 + Drop_Level: 750 + Drops_From: + Clay: true + String: + ID: 287 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 5.0 + Drop_Level: 250 + Drops_From: + Clay: true + Glowstone_Dust: + ID: 348 + Data: 0 + Amount: 1 + XP: 80 + Drop_Chance: 5.0 + Drop_Level: 25 + Drops_From: + Dirt: true + Grass: true + Sand: true + Mycelium: true + Gold_Music: + ID: 2256 + Data: 0 + Amount: 1 + XP: 3000 + Drop_Chance: 0.05 + Drop_Level: 250 + Drops_From: + Dirt: true + Grass: true + Sand: true + Gravel: true + Clay: true + Mycelium: true + Soul_Sand: true + Green_Music: + ID: 2257 + Data: 0 + Amount: 1 + XP: 3000 + Drop_Chance: 0.05 + Drop_Level: 250 + Drops_From: + Dirt: true + Grass: true + Sand: true + Gravel: true + Clay: true + Mycelium: true + Soul_Sand: true + Diamond: + ID: 264 + Data: 0 + Amount: 1 + XP: 1000 + Drop_Chance: 0.13 + Drop_Level: 350 + Drops_From: + Dirt: true + Grass: true + Sand: true + Gravel: true + Clay: true + Mycelium: true + Soul_Sand: true + Cocoa_Beans: + ID: 351 + Data: 3 + Amount: 1 + XP: 100 + Drop_Chance: 1.33 + Drop_Level: 350 + Drops_From: + Dirt: true + Grass: true + Mycelium: true + Leather_Boots: + ID: 301 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 400 + Drops_From: + Fishing: true + Leather_Helmet: + ID: 298 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 400 + Drops_From: + Fishing: true + Leather_Leggings: + ID: 300 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 400 + Drops_From: + Fishing: true + Leather_Chestplate: + ID: 299 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 400 + Drops_From: + Fishing: true + Wooden_Sword: + ID: 268 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 200 + Drops_From: + Fishing: true + Wooden_Shovel: + ID: 269 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 200 + Drops_From: + Fishing: true + Wooden_Pickaxe: + ID: 270 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 200 + Drops_From: + Fishing: true + Wooden_Axe: + ID: 271 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 200 + Drops_From: + Fishing: true + Wooden_Hoe: + ID: 290 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 200 + Drops_From: + Fishing: true + Stone_Sword: + ID: 272 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 400 + Drops_From: + Fishing: true + Stone_Shovel: + ID: 273 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 400 + Drops_From: + Fishing: true + Stone_Pickaxe: + ID: 274 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 400 + Drops_From: + Fishing: true + Stone_Axe: + ID: 275 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 400 + Drops_From: + Fishing: true + Stone_Hoe: + ID: 291 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 20.0 + Drop_Level: 0 + Max_Level: 400 + Drops_From: + Fishing: true + Iron_Sword: + ID: 267 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Iron_Shovel: + ID: 256 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Iron_Pickaxe: + ID: 257 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Iron_Axe: + ID: 258 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Iron_Hoe: + ID: 292 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Iron_Boots: + ID: 309 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Iron_Helmet: + ID: 306 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Iron_Leggings: + ID: 308 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Iron_Chestplate: + ID: 307 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Ender_Pearl: + ID: 368 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 25.0 + Drop_Level: 200 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Sword: + ID: 283 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Shovel: + ID: 284 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Pickaxe: + ID: 285 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Axe: + ID: 286 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Hoe: + ID: 294 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Boots: + ID: 317 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Helmet: + ID: 314 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Leggings: + ID: 316 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Chestplate: + ID: 315 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Blaze_Rod: + ID: 369 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Record_3: + ID: 2258 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Record_4: + ID: 2259 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Record_5: + ID: 2260 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 30.0 + Drop_Level: 400 + Max_Level: -1 + Drops_From: + Fishing: true + Diamond_Sword: + ID: 276 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Diamond_Shovel: + ID: 277 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Diamond_Pickaxe: + ID: 278 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Diamond_Axe: + ID: 279 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Diamond_Hoe: + ID: 293 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Diamond_Boots: + ID: 313 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Diamond_Helmet: + ID: 310 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Diamond_Leggings: + ID: 312 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Diamond_Chestplate: + ID: 311 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Record_6: + ID: 2261 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Record_7: + ID: 2262 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Record_8: + ID: 2263 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Record_9: + ID: 2264 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Record_10: + ID: 2265 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Record_11: + ID: 2266 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Record_12: + ID: 2267 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Ghast_Tear: + ID: 370 + Data: 0 + Amount: 1 + XP: 200 + Drop_Chance: 35.0 + Drop_Level: 600 + Max_Level: -1 + Drops_From: + Fishing: true + Diamonds: + ID: 264 + Data: 0 + Amount: 5 + XP: 200 + Drop_Chance: 40.0 + Drop_Level: 800 + Max_Level: -1 + Drops_From: + Fishing: true + Iron_Ingots: + ID: 265 + Data: 0 + Amount: 5 + XP: 200 + Drop_Chance: 40.0 + Drop_Level: 800 + Max_Level: -1 + Drops_From: + Fishing: true + Gold_Ingots: + ID: 266 + Data: 0 + Amount: 5 + XP: 200 + Drop_Chance: 40.0 + Drop_Level: 800 + Max_Level: -1 + Drops_From: + Fishing: true + Lapis_Lazuli: + ID: 351 + Data: 4 + Amount: 20 + XP: 200 + Drop_Chance: 40.0 + Drop_Level: 800 + Max_Level: -1 + Drops_From: + Fishing: true + Melon_Seeds: + ID: 362 + Data: 0 + Amount: 1 + XP: 0 + Drop_Chance: 100.0 + Drop_Level: 0 + Drops_From: + Bushes: true + Pumpkin_Seeds: + ID: 361 + Data: 0 + Amount: 1 + XP: 0 + Drop_Chance: 100.0 + Drop_Level: 0 + Drops_From: + Bushes: true + Cocoa: + ID: 351 + Data: 3 + Amount: 1 + XP: 0 + Drop_Chance: 100.0 + Drop_Level: 0 + Drops_From: + Bushes: true + Carrot: + ID: 391 + Data: 0 + Amount: 1 + XP: 0 + Drop_Chance: 100.0 + Drop_Level: 0 + Drops_From: + Flowers: true + Potato: + ID: 392 + Data: 0 + Amount: 1 + XP: 0 + Drop_Chance: 100.0 + Drop_Level: 0 + Drops_From: + Flowers: true + Apples: + ID: 260 + Data: 0 + Amount: 1 + XP: 0 + Drop_Chance: 100.0 + Drop_Level: 0 + Drops_From: + Flowers: true + Emeralds: + ID: 388 + Data: 0 + Amount: 1 + XP: 0 + Drop_Chance: 100.0 + Drop_Level: 0 + Drops_From: + Pots: true + Diamond_Gem: + ID: 264 + Data: 0 + Amount: 1 + XP: 0 + Drop_Chance: 100.0 + Drop_Level: 0 + Drops_From: + Pots: true + Gold_Nuggets: + ID: 371 + Data: 0 + Amount: 1 + XP: 0 + Drop_Chance: 100.0 + Drop_Level: 0 + Drops_From: Pots: true \ No newline at end of file diff --git a/src/test/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStoreTest.java b/src/test/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStoreTest.java index 7ebf4e47e..512a7a253 100644 --- a/src/test/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStoreTest.java +++ b/src/test/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStoreTest.java @@ -5,8 +5,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; -import com.gmail.nossr50.util.blockmeta.PrimitiveExChunkletStore; - public class PrimitiveExChunkletStoreTest { byte addresses[][] = new byte[16][16]; diff --git a/standards.md b/standards.md new file mode 100644 index 000000000..d742dc60f --- /dev/null +++ b/standards.md @@ -0,0 +1,95 @@ +* git enforced \n line endings +* 4-spaces instead of tabs for indentation +* Spaces after control statements before beginning parenthesis or brace + *
if (
+ *
for (
+ *
while (
+ *
do {
+ *
try {
+ *
public class SomeClass {
+* Spaces after closing parenthesis in a control statement +* No newline after closing parenthesis and space in a control statement: + *
if () {
+ *
for () {
+ *
while () {
+ *
catch () {
+ *
switch () {
+* Newlines before an else, else if, catch, and finally statement + *
}
+else {
+ *
}
+else if () {
+ *
}
+catch () {
+ *
}
+finally () {
+* Space after ; in for statement, not before + *
for (int i = 0; i < 10; i++) {
+* Spaces around operators + *
a + b
+ *
a == b
+ *
for (Type blah : blahs) {
+ *
"String " + "concatenation"
+* Spaces around { and } on one-line declarations + *
public boolean aMethod() { return something; }
+* Fewer extraneous parentheses, except when they increase readability + *
if (a == b || b == c)
+* Indent on case in switch case statements + *
switch () {
+            case 1:
+* Mandatory comment for when a case falls through, and when not stacking + *
switch () {
+            case 1:
+                // Fallthrough
+
+            case 2:
+ *
switch () {
+            case 1:
+            case 2:
+            case 3:
+            case 4:
+            case 5:
+                // Fallthrough
+
+            case 6:
+* Empty line between cases after break, return, or fallthrough + *
switch () {
+            case 1:
+                break;
+
+            case 2:
+* Whenever possible, check for a negative, rather than a positive + *
if (!something) {
+            // Do things
+        }
+
+        // Do other things
+* Java standard class and method naming, with exception to McMMO in a class name + *
thisIsAMethod()
+ *
ThisIsAClass
+ * Exception: +
McMMOCustomClass
+* No space before opening parenthesis for methods, or constructors + *
public void thisIsAMethod() {
+ *
public ThisIsAClass() {
+* Spaces after comma in method calls and constructors, not before + *
something.methodCall(variable, otherVariable);
+* Accessing of variables with this. only when necessary to resolve scope +* Class variables always defined at the top, before the constructor +* No empty line between class declaration and beginning of variable declaration +* Always a empty line at the end of a method or constructor definition +* Constructors come before methods, and are typically ordered from the ones with the least arguments to the most +* Methods should be ordered in this manner: + * override public + * public + * static public + * abstract public + * override protected + * protected + * static protected + * abstract protected + * override private + * private + * static private + * abstract private +* No one-line if statements, they should all have brackets \ No newline at end of file From 7814fa8d46b5e364065b3dfbdeb9948dd2812eba Mon Sep 17 00:00:00 2001 From: NuclearW Date: Fri, 1 Mar 2013 01:01:12 -0500 Subject: [PATCH 102/137] And now back to your regularly scheduled programming --- Changelog.txt | 2 ++ pom.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 77b5226e9..9d11da52f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,8 @@ Key: ! Change - Removal +Version 1.4.01-dev + Version 1.4.00 + Added new Child Skill - Smelting! + Added a version check, admins will get notified when a new version is available! diff --git a/pom.xml b/pom.xml index 3c0b7cc91..c804f4bf7 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.4.00 + 1.4.01-dev1 mcMMO https://github.com/mcMMO-Dev/mcMMO From a87336b7ee1be024f6d61c382dc01c2ddde229bc Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 1 Mar 2013 10:38:14 -0500 Subject: [PATCH 103/137] Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs. Fixes #748 --- Changelog.txt | 1 + .../nossr50/commands/player/MctopCommand.java | 18 ++++++++++++++++-- .../nossr50/commands/spout/XplockCommand.java | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 9d11da52f..426b2bae9 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,7 @@ Key: - Removal Version 1.4.01-dev + = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index 4d23bd9a2..d0fcea9e5 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -31,7 +31,14 @@ public class MctopCommand implements CommandExecutor { display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command); } else if (SkillUtils.isSkill(args[0])) { - display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command); + SkillType skill = SkillType.getSkill(args[0]); + + if (skill.isChildSkill()) { + sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this + return true; + } + + display(1, skill.toString(), sender, useMySQL, command); } else { sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); @@ -45,7 +52,14 @@ public class MctopCommand implements CommandExecutor { } if (SkillUtils.isSkill(args[0])) { - display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command); + SkillType skill = SkillType.getSkill(args[0]); + + if (skill.isChildSkill()) { + sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this + return true; + } + + display(Integer.parseInt(args[1]), skill.toString(), sender, useMySQL, command); } else { sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); diff --git a/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java index a69ea0cec..a6317d0ca 100644 --- a/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java @@ -39,6 +39,11 @@ public class XplockCommand extends SpoutCommand { SkillType skill = SkillType.getSkill(args[0]); + if (skill.isChildSkill()) { + sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this + return true; + } + if (!Permissions.xplock(sender, skill)) { sender.sendMessage(command.getPermissionMessage()); return true; From ae8b70be0f984e3a0a3283dc4059d66f86116843 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 1 Mar 2013 15:55:10 -0500 Subject: [PATCH 104/137] Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile. Fixes #750 --- Changelog.txt | 1 + .../java/com/gmail/nossr50/database/LeaderboardManager.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 426b2bae9..18545e179 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ Key: Version 1.4.01-dev = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs + = Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java b/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java index 247a189e6..a23daa114 100644 --- a/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java +++ b/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java @@ -36,6 +36,7 @@ public final class LeaderboardManager { } lastUpdate = System.currentTimeMillis(); // Log when the last update was run + powerLevels.clear(); // Clear old values from the power levels // Initialize lists List mining = new ArrayList(); @@ -50,7 +51,6 @@ public final class LeaderboardManager { List unarmed = new ArrayList(); List taming = new ArrayList(); List fishing = new ArrayList(); - List powerLevels = new ArrayList(); // Read from the FlatFile database and fill our arrays with information try { From 0d7c402c01d41401f789403e8a2665ce854dee5a Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 1 Mar 2013 18:45:44 -0500 Subject: [PATCH 105/137] Fixed bug where Smelting would throw consistent errors due to offline players. Fixes #754 --- Changelog.txt | 1 + .../java/com/gmail/nossr50/listeners/InventoryListener.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 18545e179..b5f758cad 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Key: Version 1.4.01-dev = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs = Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile + = Fixed bug where Smelting would throw consistent errors due to offline players Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 73573bb5e..0563a0af6 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -94,7 +94,7 @@ public class InventoryListener implements Listener { if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) { Player player = plugin.getFurnacePlayer(furnaceBlock); - if (!Misc.isNPCEntity(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -115,7 +115,7 @@ public class InventoryListener implements Listener { if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) { Player player = plugin.getFurnacePlayer(furnaceBlock); - if (!Misc.isNPCEntity(player)) { + if (Misc.isNPCEntity(player)) { return; } From cf82ae4c6694edfc6a6a998bfb3e336343191a68 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 2 Mar 2013 19:38:29 -0500 Subject: [PATCH 106/137] Fixed bug where repairing an mcMMO ability-buffed item with mcMMO repair could take the enchant but leave the lore tag --- Changelog.txt | 1 + .../com/gmail/nossr50/skills/repair/SimpleRepairManager.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index b5f758cad..ce1c350ea 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -11,6 +11,7 @@ Version 1.4.01-dev = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs = Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile = Fixed bug where Smelting would throw consistent errors due to offline players + = Fixed bug where repairing an mcMMO ability-buffed item with mcMMO repair could take the enchant but leave the lore tag Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java index bcdaca589..ffdb1aa28 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java @@ -15,6 +15,7 @@ import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.skills.SkillUtils; public class SimpleRepairManager implements RepairManager { private HashMap repairables; @@ -108,6 +109,9 @@ public class SimpleRepairManager implements RepairManager { return; } + // Clear ability buffs before trying to repair. + SkillUtils.removeAbilityBuff(item); + // Lets get down to business, // To defeat, the huns. int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters? From 2feba8f64c8028a0cb39b757bbd5f3e80f25fe3e Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 2 Mar 2013 20:07:01 -0500 Subject: [PATCH 107/137] Fixed bug where using '/party chat message...' would result in the first word of the message being printed repeatedly. Fixes #760 --- Changelog.txt | 1 + .../java/com/gmail/nossr50/commands/party/PartyCommand.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index ce1c350ea..03028bccd 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,6 +12,7 @@ Version 1.4.01-dev = Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile = Fixed bug where Smelting would throw consistent errors due to offline players = Fixed bug where repairing an mcMMO ability-buffed item with mcMMO repair could take the enchant but leave the lore tag + = Fixed bug where using '/party chat message...' would result in the first word of the message being printed repeatedly Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index 06bb51a27..8f765dc0f 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -146,7 +146,7 @@ public class PartyCommand implements CommandExecutor { String[] newArgs = new String[args.length - 1]; for (int i = 1; i < args.length; i++) { - newArgs[i - 1] = args[1]; + newArgs[i - 1] = args[i]; } return newArgs; From 0d2b87834c9cb121f73ebd1b57d7e11111ad6a7e Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 2 Mar 2013 20:59:29 -0500 Subject: [PATCH 108/137] Fixed bug where the wrong flag was being set when taking damage. --- Changelog.txt | 1 + .../java/com/gmail/nossr50/datatypes/player/PlayerProfile.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 03028bccd..c08b64d94 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -13,6 +13,7 @@ Version 1.4.01-dev = Fixed bug where Smelting would throw consistent errors due to offline players = Fixed bug where repairing an mcMMO ability-buffed item with mcMMO repair could take the enchant but leave the lore tag = Fixed bug where using '/party chat message...' would result in the first word of the message being printed repeatedly + = Fixed bug where the wrong flag was being set when taking damage Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 22b48e460..fbf64d1ed 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -915,7 +915,7 @@ public class PlayerProfile { } public void actualizeRecentlyHurt() { - respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + recentlyHurt = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); } /* From 31fff0623d4f583600d4182b3c72672bd562b476 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 2 Mar 2013 21:48:44 -0500 Subject: [PATCH 109/137] Fixed bug where the PTP cooldown was set improperly. --- Changelog.txt | 1 + .../java/com/gmail/nossr50/commands/party/PtpCommand.java | 2 +- .../com/gmail/nossr50/datatypes/player/PlayerProfile.java | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c08b64d94..cf1f588c6 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,6 +14,7 @@ Version 1.4.01-dev = Fixed bug where repairing an mcMMO ability-buffed item with mcMMO repair could take the enchant but leave the lore tag = Fixed bug where using '/party chat message...' would result in the first word of the message being printed repeatedly = Fixed bug where the wrong flag was being set when taking damage + = Fixed bug where the PTP cooldown was set improperly Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java index a84cd9d27..a5965300d 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java @@ -213,7 +213,7 @@ public class PtpCommand implements CommandExecutor { player.teleport(target); player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", target.getName())); target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", player.getName())); - mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis()); + mcMMOPlayer.getProfile().actualizeRecentlyHurt(); return true; } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index fbf64d1ed..3c7a91179 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -63,7 +63,7 @@ public class PlayerProfile { private boolean displaySkillNotifications = true; // Timestamps - private long recentlyHurt; + private int recentlyHurt; private int respawnATS; // mySQL Stuff @@ -906,11 +906,11 @@ public class PlayerProfile { * Recently Hurt */ - public long getRecentlyHurt() { + public int getRecentlyHurt() { return recentlyHurt; } - public void setRecentlyHurt(long value) { + public void setRecentlyHurt(int value) { recentlyHurt = value; } From 12c6bfc2e88f457c994909fbb7bc696a4eac1708 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 2 Mar 2013 23:34:39 -0500 Subject: [PATCH 110/137] Fix another potential issue with recentlyHurt & /ptp. --- src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java | 3 ++- src/main/java/com/gmail/nossr50/util/ChimaeraWing.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java index a5965300d..eb87959a3 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java @@ -57,8 +57,9 @@ public class PtpCommand implements CommandExecutor { } int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); + long recentlyHurt = playerProfile.getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR; - if (playerProfile.getRecentlyHurt() + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) { + if (System.currentTimeMillis() - recentlyHurt >= (ptpCooldown * Misc.TIME_CONVERSION_FACTOR)) { player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown)); return true; } diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 8ddd8d101..1a0c49dd0 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -30,7 +30,7 @@ public final class ChimaeraWing { PlayerProfile profile = UserManager.getPlayer(player).getProfile(); Block block = player.getLocation().getBlock(); int amount = inHand.getAmount(); - long recentlyHurt = profile.getRecentlyHurt(); + long recentlyHurt = profile.getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR; if (Permissions.chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) { if (SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) { From 79a5732c4d8847aad3b8c0ccdcd999b000dd0984 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 2 Mar 2013 23:53:25 -0500 Subject: [PATCH 111/137] Fixed bug where ptp permissions weren't being handled properly --- Changelog.txt | 1 + .../gmail/nossr50/util/commands/CommandRegistrationManager.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index cf1f588c6..4a39677b2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -15,6 +15,7 @@ Version 1.4.01-dev = Fixed bug where using '/party chat message...' would result in the first word of the message being printed repeatedly = Fixed bug where the wrong flag was being set when taking damage = Fixed bug where the PTP cooldown was set improperly + = Fixed bug where ptp permissions weren't being handled properly Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java index 080c44ab1..324f3d179 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -331,7 +331,7 @@ public final class CommandRegistrationManager { public static void registerPtpCommand() { PluginCommand command = mcMMO.p.getCommand("ptp"); command.setDescription(LocaleLoader.getString("Commands.Description.ptp")); - command.setPermission("mcmmo.commands.ptp;mcmmo.commands.ptp.accept;mcmmo.commands.ptp.acceptall;mcmmo.commands.ptp.toggle"); + command.setPermission("mcmmo.commands.ptp"); // Only need the main one, not the individual ones for toggle/accept/acceptall command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "ptp", "")); From d3ec976f44305e36d59ff14ae38adaf1c0c31856 Mon Sep 17 00:00:00 2001 From: bm01 Date: Sun, 3 Mar 2013 13:43:56 +0100 Subject: [PATCH 112/137] I'd say no But if the player can actually be off-line, be sure to add a comment explaining why. --- .../nossr50/listeners/EntityListener.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 5d486368e..1e3b460c8 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -103,26 +103,19 @@ public class EntityListener implements Listener { } } - if (defender instanceof Player) { + if (defender instanceof Player && attacker instanceof Player) { Player defendingPlayer = (Player) defender; + Player attackingPlayer = (Player) attacker; - // TODO: Is this even possible? - if (!defendingPlayer.isOnline()) { + // TODO: Why? + if (defendingPlayer == attackingPlayer) { return; } - - if (attacker instanceof Player) { - Player attackingPlayer = (Player) attacker; - - if (defendingPlayer == attackingPlayer) { + else if (PartyManager.inSameParty(defendingPlayer, attackingPlayer)) { + if (!(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { + event.setCancelled(true); return; } - else if (PartyManager.inSameParty(defendingPlayer, attackingPlayer)) { - if (!(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { - event.setCancelled(true); - return; - } - } } } @@ -163,8 +156,7 @@ public class EntityListener implements Listener { if (livingEntity instanceof Player) { Player player = (Player) entity; - // TODO: Is it even possible for the player to be off-line here? - if (!player.isOnline() || Misc.isNPCEntity(player)) { + if (Misc.isNPCEntity(player)) { return; } From b779258d695c19c416af8c4b27387d4fba165277 Mon Sep 17 00:00:00 2001 From: bm01 Date: Sun, 3 Mar 2013 14:21:19 +0100 Subject: [PATCH 113/137] Fixed Beast Lore not working, fixes #771 --- Changelog.txt | 1 + .../nossr50/util/skills/CombatUtils.java | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 4a39677b2..4422da366 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -16,6 +16,7 @@ Version 1.4.01-dev = Fixed bug where the wrong flag was being set when taking damage = Fixed bug where the PTP cooldown was set improperly = Fixed bug where ptp permissions weren't being handled properly + = Fixed bug where Beast Lore wouldn't work Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index e53aea1d4..c29f367a6 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -61,14 +61,19 @@ public final class CombatUtils { return; } - if (target instanceof Tameable && isFriendlyPet(player, (Tameable) target)) { - return; - } - ItemStack heldItem = player.getItemInHand(); - Material heldItemType = heldItem.getType(); - if (ItemUtils.isSword(heldItem)) { + if (target instanceof Tameable) { + if (heldItem.getType() == Material.BONE && Permissions.beastLore(player)) { + SkillManagerStore.getInstance().getTamingManager(player.getName()).beastLore(target); + event.setCancelled(true); + return; + } + else if (isFriendlyPet(player, (Tameable) target)) { + return; + } + } + else if (ItemUtils.isSword(heldItem)) { if (targetIsPlayer || targetIsTamedPet) { if (!SkillType.SWORDS.getPVPEnabled()) { return; @@ -133,7 +138,7 @@ public final class CombatUtils { startGainXp(axeManager.getMcMMOPlayer(), target, SkillType.AXES); } } - else if (heldItemType == Material.AIR) { + else if (heldItem.getType() == Material.AIR) { if (targetIsPlayer || targetIsTamedPet) { if (!SkillType.UNARMED.getPVPEnabled()) { return; @@ -173,9 +178,6 @@ public final class CombatUtils { startGainXp(mcMMOPlayer, target, SkillType.UNARMED); } } - else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) { - SkillManagerStore.getInstance().getTamingManager(player.getName()).beastLore(target); - } } switch (damager.getType()) { From 37395a70e68139728a4b4a4fd7361d1bca32d38f Mon Sep 17 00:00:00 2001 From: bm01 Date: Sun, 3 Mar 2013 14:38:00 +0100 Subject: [PATCH 114/137] Combat skills should work on wild wolves / cats Bug introduced in my previous commit --- src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index c29f367a6..3826f715d 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -73,7 +73,8 @@ public final class CombatUtils { return; } } - else if (ItemUtils.isSword(heldItem)) { + + if (ItemUtils.isSword(heldItem)) { if (targetIsPlayer || targetIsTamedPet) { if (!SkillType.SWORDS.getPVPEnabled()) { return; From 077431630ae2c7737758121eeaef011f41d1946c Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sun, 3 Mar 2013 17:02:11 +0100 Subject: [PATCH 115/137] We don't need this here. --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0a3f32e7f..7466dcc75 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -336,7 +336,7 @@ Experience: Wither: 7.0 Witch: 4.0 Iron_Golem: 2.0 - Wither_Skeleton: 4.0; + Wither_Skeleton: 4.0 # # Settings for commands ### From 10e227a5ac734e00d0f5bbfa65f09e7d0c83982b Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sun, 3 Mar 2013 17:03:16 +0100 Subject: [PATCH 116/137] Fixed bug where Chimaera Wing would always teleport to spawn --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/util/ChimaeraWing.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 4422da366..7d9a3a205 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -17,6 +17,7 @@ Version 1.4.01-dev = Fixed bug where the PTP cooldown was set improperly = Fixed bug where ptp permissions weren't being handled properly = Fixed bug where Beast Lore wouldn't work + = Fixed bug where Chimaera Wing would always teleport to spawn, even when the player had a valid bed spawn location Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 1a0c49dd0..f3b861466 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -44,7 +44,7 @@ public final class ChimaeraWing { } } - if (player.getBedSpawnLocation() != null && player.getBedSpawnLocation().getBlock().getType() == Material.BED_BLOCK) { + if (player.getBedSpawnLocation() != null) { player.teleport(player.getBedSpawnLocation()); } else { From f8b44120497445d3da8209bf65890b5d687ab21a Mon Sep 17 00:00:00 2001 From: bm01 Date: Sun, 3 Mar 2013 16:09:41 +0100 Subject: [PATCH 117/137] Each McMMOPlayer now store its SkillManager objects Should fix a recent memory leak --- .../commands/skills/FishingCommand.java | 6 +- .../commands/skills/MiningCommand.java | 4 +- .../commands/skills/SmeltingCommand.java | 4 +- .../nossr50/datatypes/player/McMMOPlayer.java | 91 ++++++++++++- .../nossr50/datatypes/skills/SkillType.java | 53 +++++--- .../nossr50/listeners/BlockListener.java | 26 ++-- .../nossr50/listeners/EntityListener.java | 26 ++-- .../nossr50/listeners/InventoryListener.java | 7 +- .../nossr50/listeners/PlayerListener.java | 25 ++-- .../nossr50/skills/SkillManagerStore.java | 128 ------------------ .../{AxeManager.java => AxesManager.java} | 4 +- .../nossr50/util/skills/CombatUtils.java | 96 +++++++------ 12 files changed, 234 insertions(+), 236 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java rename src/main/java/com/gmail/nossr50/skills/axes/{AxeManager.java => AxesManager.java} (98%) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index 603b09203..0c1f6c1e1 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -3,9 +3,9 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; public class FishingCommand extends SkillCommand { private int lootTier; @@ -27,7 +27,7 @@ public class FishingCommand extends SkillCommand { @Override protected void dataCalculations() { - lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier(); + lootTier = UserManager.getPlayer(player).getFishingManager().getLootTier(); // TREASURE HUNTER double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier(); @@ -42,7 +42,7 @@ public class FishingCommand extends SkillCommand { magicChanceLucky = treasureHunterStrings[1]; // SHAKE - String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability()); + String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability()); shakeChance = shakeStrings[0]; shakeChanceLucky = shakeStrings[1]; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java index 3c2a67db2..096756600 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java @@ -3,10 +3,10 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.mining.Mining; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; public class MiningCommand extends SkillCommand { private String doubleDropChance; @@ -45,7 +45,7 @@ public class MiningCommand extends SkillCommand { doubleDropChanceLucky = doubleDropStrings[1]; // BLAST MINING - MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); + MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); blastMiningRank = miningManager.getBlastMiningTier(); bonusTNTDrops = miningManager.getDropMultiplier(); oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30% diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java index 09a647af3..c87298471 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java @@ -3,9 +3,9 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.smelting.Smelting; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; public class SmeltingCommand extends SkillCommand { private String burnTimeModifier; @@ -41,7 +41,7 @@ public class SmeltingCommand extends SkillCommand { fluxMiningChanceLucky = fluxMiningStrings[1]; // VANILLA XP BOOST - vanillaXPModifier = SkillManagerStore.getInstance().getSmeltingManager(player.getName()).getVanillaXpMultiplier(); + vanillaXPModifier = UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier(); } @Override diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 54a5929e2..6d436fc52 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.datatypes.player; +import java.util.HashMap; +import java.util.Map; import java.util.Set; import org.bukkit.GameMode; @@ -15,7 +17,19 @@ import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.ShareHandler; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; +import com.gmail.nossr50.skills.archery.ArcheryManager; +import com.gmail.nossr50.skills.axes.AxesManager; import com.gmail.nossr50.skills.child.FamilyTree; +import com.gmail.nossr50.skills.excavation.ExcavationManager; +import com.gmail.nossr50.skills.fishing.FishingManager; +import com.gmail.nossr50.skills.herbalism.HerbalismManager; +import com.gmail.nossr50.skills.mining.MiningManager; +import com.gmail.nossr50.skills.smelting.SmeltingManager; +import com.gmail.nossr50.skills.swords.SwordsManager; +import com.gmail.nossr50.skills.taming.TamingManager; +import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ModUtils; import com.gmail.nossr50.util.Permissions; @@ -26,6 +40,15 @@ public class McMMOPlayer { private Player player; private PlayerProfile profile; + /* + * Since SkillManager isn't a "polymorphic type" we may prefer to have one field for each of our + * class inheriting from SkillManager. This would also prevent the need for casting. + * However, by using the map and the loop in the constructor + * we make sure that all class inheriting from SkillManager are instanced. + * Which solution is better, I let you decide. - bm01 + */ + private Map skillManagers = new HashMap(); + private Party party; private Party invite; @@ -43,8 +66,72 @@ public class McMMOPlayer { String playerName = player.getName(); this.player = player; - this.profile = new PlayerProfile(playerName, true); - this.party = PartyManager.getPlayerParty(playerName); + profile = new PlayerProfile(playerName, true); + party = PartyManager.getPlayerParty(playerName); + + /* + * I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually), + * but I actually have no idea about the performance impact, if there is any. + * If in the future someone wants to remove this, don't forget to also remove what is in the SkillType enum. - bm01 + */ + try { + for (SkillType skillType : SkillType.values()) { + Class skillManagerClass = skillType.getManagerClass(); + + // TODO: The null check is needed only because currently some SkillType doesn't have a valid skillManagerClass + if (skillManagerClass != null) { + skillManagers.put(skillType, skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this)); + } + } + } + catch (Exception e) { + e.printStackTrace(); + mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p); + } + } + + public AcrobaticsManager getAcrobaticsManager() { + return (AcrobaticsManager) skillManagers.get(SkillType.ACROBATICS); + } + + public ArcheryManager getArcheryManager() { + return (ArcheryManager) skillManagers.get(SkillType.ARCHERY); + } + + public AxesManager getAxesManager() { + return (AxesManager) skillManagers.get(SkillType.AXES); + } + + public ExcavationManager getExcavationManager() { + return (ExcavationManager) skillManagers.get(SkillType.EXCAVATION); + } + + public FishingManager getFishingManager() { + return (FishingManager) skillManagers.get(SkillType.FISHING); + } + + public HerbalismManager getHerbalismManager() { + return (HerbalismManager) skillManagers.get(SkillType.HERBALISM); + } + + public MiningManager getMiningManager() { + return (MiningManager) skillManagers.get(SkillType.MINING); + } + + public SmeltingManager getSmeltingManager() { + return (SmeltingManager) skillManagers.get(SkillType.SMELTING); + } + + public SwordsManager getSwordsManager() { + return (SwordsManager) skillManagers.get(SkillType.SWORDS); + } + + public TamingManager getTamingManager() { + return (TamingManager) skillManagers.get(SkillType.TAMING); + } + + public UnarmedManager getUnarmedManager() { + return (UnarmedManager) skillManagers.get(SkillType.UNARMED); } /** diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java index ecc9b55f1..565ee66de 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java @@ -3,36 +3,55 @@ package com.gmail.nossr50.datatypes.skills; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; +import com.gmail.nossr50.skills.archery.ArcheryManager; +import com.gmail.nossr50.skills.axes.AxesManager; +import com.gmail.nossr50.skills.excavation.ExcavationManager; +import com.gmail.nossr50.skills.fishing.FishingManager; +import com.gmail.nossr50.skills.herbalism.HerbalismManager; +import com.gmail.nossr50.skills.mining.MiningManager; +import com.gmail.nossr50.skills.smelting.SmeltingManager; +import com.gmail.nossr50.skills.swords.SwordsManager; +import com.gmail.nossr50.skills.taming.TamingManager; +import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.util.StringUtils; public enum SkillType { - ACROBATICS, - ARCHERY, - AXES(AbilityType.SKULL_SPLITTER, ToolType.AXE), - EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL), - FISHING, - HERBALISM(AbilityType.GREEN_TERRA, ToolType.HOE), - MINING(AbilityType.SUPER_BREAKER, ToolType.PICKAXE), - REPAIR, - SMELTING, - SWORDS(AbilityType.SERRATED_STRIKES, ToolType.SWORD), - TAMING, - UNARMED(AbilityType.BERSERK, ToolType.FISTS), - WOODCUTTING(AbilityType.TREE_FELLER, ToolType.AXE); + ACROBATICS(AcrobaticsManager.class), + ARCHERY(ArcheryManager.class), + AXES(AxesManager.class, AbilityType.SKULL_SPLITTER, ToolType.AXE), + EXCAVATION(ExcavationManager.class, AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL), + FISHING(FishingManager.class), + HERBALISM(HerbalismManager.class, AbilityType.GREEN_TERRA, ToolType.HOE), + MINING(MiningManager.class, AbilityType.SUPER_BREAKER, ToolType.PICKAXE), + REPAIR(null), // TODO: Create a proper RepairManager class + SMELTING(SmeltingManager.class), + SWORDS(SwordsManager.class, AbilityType.SERRATED_STRIKES, ToolType.SWORD), + TAMING(TamingManager.class), + UNARMED(UnarmedManager.class, AbilityType.BERSERK, ToolType.FISTS), + WOODCUTTING(null, AbilityType.TREE_FELLER, ToolType.AXE); // TODO: Create a proper WoodcuttingManager class + private Class managerClass; private AbilityType ability; private ToolType tool; - private SkillType() { - this.ability = null; - this.tool = null; + private SkillType(Class managerClass) { + this.managerClass = managerClass; + ability = null; + tool = null; } - private SkillType(AbilityType ability, ToolType tool) { + private SkillType(Class managerClass, AbilityType ability, ToolType tool) { + this.managerClass = managerClass; this.ability = ability; this.tool = tool; } + public Class getManagerClass() { + return managerClass; + } + public AbilityType getAbility() { return ability; } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 940ccc24e..39f15e147 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -31,12 +31,12 @@ import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.runnables.StickyPistonTrackerTask; -import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; +import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.unarmed.Unarmed; import com.gmail.nossr50.skills.woodcutting.Woodcutting; import com.gmail.nossr50.util.BlockUtils; @@ -152,7 +152,7 @@ public class BlockListener implements Listener { /* HERBALISM */ if (BlockUtils.affectedByGreenTerra(blockState)) { - HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName()); + HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager(); /* Green Terra */ if (herbalismManager.canActivateAbility()) { @@ -177,7 +177,7 @@ public class BlockListener implements Listener { /* MINING */ else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) { - MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); + MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); miningManager.miningBlockCheck(blockState); if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) { @@ -204,7 +204,7 @@ public class BlockListener implements Listener { /* EXCAVATION */ else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) { - ExcavationManager excavationManager = SkillManagerStore.getInstance().getExcavationManager(player.getName()); + ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager(); excavationManager.excavationBlockCheck(blockState); if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { @@ -235,17 +235,19 @@ public class BlockListener implements Listener { return; } - String playerName = player.getName(); BlockState blockState = event.getBlock().getState(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); + SmeltingManager smeltingManager = mcMMOPlayer.getSmeltingManager(); - if (SkillManagerStore.getInstance().getHerbalismManager(playerName).canUseHylianLuck()) { - if (SkillManagerStore.getInstance().getHerbalismManager(playerName).processHylianLuck(blockState)) { + if (herbalismManager.canUseHylianLuck()) { + if (herbalismManager.processHylianLuck(blockState)) { blockState.update(true); event.setCancelled(true); } } - else if (SkillManagerStore.getInstance().getSmeltingManager(playerName).canUseFluxMining(blockState)) { - if (SkillManagerStore.getInstance().getSmeltingManager(playerName).processFluxMining(blockState)) { + else if (smeltingManager.canUseFluxMining(blockState)) { + if (smeltingManager.processFluxMining(blockState)) { blockState.update(true); event.setCancelled(true); } @@ -335,20 +337,20 @@ public class BlockListener implements Listener { return; } - String playerName = player.getName(); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); ItemStack heldItem = player.getItemInHand(); Block block = event.getBlock(); BlockState blockState = block.getState(); + HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); /* * ABILITY TRIGGER CHECKS * * We don't need to check permissions here because they've already been checked for the ability to even activate. */ - if (SkillManagerStore.getInstance().getHerbalismManager(playerName).canGreenTerraBlock(blockState)) { - if (SkillManagerStore.getInstance().getHerbalismManager(playerName).processGreenTerra(blockState)) { + if (herbalismManager.canGreenTerraBlock(blockState)) { + if (herbalismManager.processGreenTerra(blockState)) { blockState.update(true); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 1e3b460c8..b9b29071f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -33,7 +33,7 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.runnables.skills.BleedTimerTask; -import com.gmail.nossr50.skills.SkillManagerStore; +import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; @@ -171,8 +171,10 @@ public class EntityListener implements Listener { switch (cause) { case FALL: - if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canRoll()) { - event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).rollCheck(event.getDamage())); + AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager(); + + if (acrobaticsManager.canRoll()) { + event.setDamage(acrobaticsManager.rollCheck(event.getDamage())); if (event.getDamage() == 0) { event.setCancelled(true); @@ -182,7 +184,7 @@ public class EntityListener implements Listener { break; case BLOCK_EXPLOSION: - MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName()); + MiningManager miningManager = mcMMOPlayer.getMiningManager(); if (miningManager.canUseDemolitionsExpertise()) { event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage())); @@ -318,7 +320,8 @@ public class EntityListener implements Listener { int id = entity.getEntityId(); if (plugin.tntIsTracked(id)) { - MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(plugin.getTNTPlayer(id).getName()); + + MiningManager miningManager = UserManager.getPlayer(plugin.getTNTPlayer(id)).getMiningManager(); if (miningManager.canUseBiggerBombs()) { event.setRadius(miningManager.biggerBombs(event.getRadius())); @@ -340,7 +343,7 @@ public class EntityListener implements Listener { int id = entity.getEntityId(); if (plugin.tntIsTracked(id)) { - MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(plugin.getTNTPlayer(id).getName()); + MiningManager miningManager = UserManager.getPlayer(plugin.getTNTPlayer(id)).getMiningManager(); if (miningManager.canUseBlastMining()) { miningManager.blastMiningDropProcessing(event.getYield(), event.blockList()); @@ -387,7 +390,7 @@ public class EntityListener implements Listener { case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ if (Permissions.farmersDiet(player)) { - event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel)); + event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel)); } return; @@ -396,19 +399,19 @@ public class EntityListener implements Listener { case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ if (Permissions.farmersDiet(player)) { - event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel)); + event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel)); } return; case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ if (Permissions.fishermansDiet(player)) { - event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel)); + event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel)); } return; case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ if (Permissions.fishermansDiet(player)) { - event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel)); + event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel)); } return; @@ -435,7 +438,7 @@ public class EntityListener implements Listener { LivingEntity entity = event.getEntity(); if (entity != null && !entity.hasMetadata(mcMMO.entityMetadataKey)) { - SkillManagerStore.getInstance().getTamingManager(player.getName()).awardTamingXP(entity); + UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity); } } @@ -449,6 +452,7 @@ public class EntityListener implements Listener { // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party // So we can make some assumptions here, about our casting and our check Player owner = (Player) tameable.getOwner(); + if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire(owner))) { event.setCancelled(true); return; diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 0563a0af6..ebf852a39 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -20,7 +20,6 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SkillType; -import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -99,7 +98,7 @@ public class InventoryListener implements Listener { } if (Permissions.fuelEfficiency(player)) { - event.setBurnTime(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event.getBurnTime())); + event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime())); } } } @@ -120,7 +119,7 @@ public class InventoryListener implements Listener { } if (Permissions.skillEnabled(player, SkillType.SMELTING)) { - event.setResult(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event.getSource().getType(), event.getResult())); + event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(event.getSource().getType(), event.getResult())); } } } @@ -137,7 +136,7 @@ public class InventoryListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(event.getPlayer()); if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) { - event.setExpToDrop(SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event.getExpToDrop())); + event.setExpToDrop(mcMMOPlayer.getSmeltingManager().vanillaXPBoost(event.getExpToDrop())); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 30858a1a9..0de27e591 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -36,11 +36,12 @@ import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.runnables.skills.BleedTimerTask; -import com.gmail.nossr50.skills.SkillManagerStore; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; +import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; +import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.HardcoreManager; @@ -162,7 +163,7 @@ public class PlayerListener implements Listener { return; } - FishingManager fishingManager = SkillManagerStore.getInstance().getFishingManager(player.getName()); + FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); switch (event.getState()) { case CAUGHT_FISH: @@ -278,6 +279,8 @@ public class PlayerListener implements Listener { Block block = event.getClickedBlock(); ItemStack heldItem = player.getItemInHand(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + MiningManager miningManager = mcMMOPlayer.getMiningManager(); switch (event.getAction()) { case RIGHT_CLICK_BLOCK: @@ -285,7 +288,7 @@ public class PlayerListener implements Listener { /* REPAIR CHECKS */ if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairManager.isRepairable(heldItem)) { - mcMMO.repairManager.handleRepair(UserManager.getPlayer(player), heldItem); + mcMMO.repairManager.handleRepair(mcMMOPlayer, heldItem); event.setCancelled(true); player.updateInventory(); } @@ -296,12 +299,12 @@ public class PlayerListener implements Listener { player.updateInventory(); } /* BLAST MINING CHECK */ - else if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) { + else if (miningManager.canDetonate()) { if (blockID == Material.TNT.getId()) { event.setCancelled(true); // Don't detonate the TNT if they're too close } else { - SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation(); + miningManager.remoteDetonation(); } } @@ -309,8 +312,8 @@ public class PlayerListener implements Listener { case RIGHT_CLICK_AIR: /* BLAST MINING CHECK */ - if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) { - SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation(); + if (miningManager.canDetonate()) { + miningManager.remoteDetonation(); } break; @@ -334,6 +337,7 @@ public class PlayerListener implements Listener { } ItemStack heldItem = player.getItemInHand(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); switch (event.getAction()) { case RIGHT_CLICK_BLOCK: @@ -359,7 +363,7 @@ public class PlayerListener implements Listener { } /* GREEN THUMB CHECK */ - HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName()); + HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); if (herbalismManager.canGreenThumbBlock(blockState)) { player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1)); @@ -401,12 +405,13 @@ public class PlayerListener implements Listener { /* CALL OF THE WILD CHECKS */ if (player.isSneaking()) { Material type = heldItem.getType(); + TamingManager tamingManager = mcMMOPlayer.getTamingManager(); if (type == Material.RAW_FISH) { - SkillManagerStore.getInstance().getTamingManager(player.getName()).summonOcelot(); + tamingManager.summonOcelot(); } else if (type == Material.BONE) { - SkillManagerStore.getInstance().getTamingManager(player.getName()).summonWolf(); + tamingManager.summonWolf(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java b/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java deleted file mode 100644 index e8dcdcf62..000000000 --- a/src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.gmail.nossr50.skills; - -import java.util.HashMap; - -import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; -import com.gmail.nossr50.skills.archery.ArcheryManager; -import com.gmail.nossr50.skills.axes.AxeManager; -import com.gmail.nossr50.skills.excavation.ExcavationManager; -import com.gmail.nossr50.skills.fishing.FishingManager; -import com.gmail.nossr50.skills.herbalism.HerbalismManager; -import com.gmail.nossr50.skills.mining.MiningManager; -import com.gmail.nossr50.skills.smelting.SmeltingManager; -import com.gmail.nossr50.skills.swords.SwordsManager; -import com.gmail.nossr50.skills.taming.TamingManager; -import com.gmail.nossr50.skills.unarmed.UnarmedManager; -import com.gmail.nossr50.util.player.UserManager; - -public class SkillManagerStore { - private static SkillManagerStore instance; - - private HashMap acrobaticsManagers = new HashMap(); - private HashMap archeryManagers = new HashMap(); - private HashMap axeManagers = new HashMap(); - private HashMap excavationManagers = new HashMap(); - private HashMap fishingManagers = new HashMap(); - private HashMap herbalismManagers = new HashMap(); - private HashMap miningManagers = new HashMap(); - private HashMap smeltingManagers = new HashMap(); - private HashMap swordsManagers = new HashMap(); - private HashMap tamingManagers = new HashMap(); - private HashMap unarmedManagers = new HashMap(); - - public static SkillManagerStore getInstance() { - if (instance == null) { - instance = new SkillManagerStore(); - } - - return instance; - } - - public AcrobaticsManager getAcrobaticsManager(String playerName) { - if (!acrobaticsManagers.containsKey(playerName)) { - acrobaticsManagers.put(playerName, new AcrobaticsManager(UserManager.getPlayer(playerName))); - } - - return acrobaticsManagers.get(playerName); - } - - public ArcheryManager getArcheryManager(String playerName) { - if (!archeryManagers.containsKey(playerName)) { - archeryManagers.put(playerName, new ArcheryManager(UserManager.getPlayer(playerName))); - } - - return archeryManagers.get(playerName); - } - - public AxeManager getAxeManager(String playerName) { - if (!axeManagers.containsKey(playerName)) { - axeManagers.put(playerName, new AxeManager(UserManager.getPlayer(playerName))); - } - - return axeManagers.get(playerName); - } - - public ExcavationManager getExcavationManager(String playerName) { - if (!excavationManagers.containsKey(playerName)) { - excavationManagers.put(playerName, new ExcavationManager(UserManager.getPlayer(playerName))); - } - - return excavationManagers.get(playerName); - } - - public FishingManager getFishingManager(String playerName) { - if (!fishingManagers.containsKey(playerName)) { - fishingManagers.put(playerName, new FishingManager(UserManager.getPlayer(playerName))); - } - - return fishingManagers.get(playerName); - } - - public HerbalismManager getHerbalismManager(String playerName) { - if (!herbalismManagers.containsKey(playerName)) { - herbalismManagers.put(playerName, new HerbalismManager(UserManager.getPlayer(playerName))); - } - - return herbalismManagers.get(playerName); - } - - public MiningManager getMiningManager(String playerName) { - if (!miningManagers.containsKey(playerName)) { - miningManagers.put(playerName, new MiningManager(UserManager.getPlayer(playerName))); - } - - return miningManagers.get(playerName); - } - - public SmeltingManager getSmeltingManager(String playerName) { - if (!smeltingManagers.containsKey(playerName)) { - smeltingManagers.put(playerName, new SmeltingManager(UserManager.getPlayer(playerName))); - } - - return smeltingManagers.get(playerName); - } - - public SwordsManager getSwordsManager(String playerName) { - if (!swordsManagers.containsKey(playerName)) { - swordsManagers.put(playerName, new SwordsManager(UserManager.getPlayer(playerName))); - } - - return swordsManagers.get(playerName); - } - - public TamingManager getTamingManager(String playerName) { - if (!tamingManagers.containsKey(playerName)) { - tamingManagers.put(playerName, new TamingManager(UserManager.getPlayer(playerName))); - } - - return tamingManagers.get(playerName); - } - - public UnarmedManager getUnarmedManager(String playerName) { - if (!unarmedManagers.containsKey(playerName)) { - unarmedManagers.put(playerName, new UnarmedManager(UserManager.getPlayer(playerName))); - } - - return unarmedManagers.get(playerName); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java similarity index 98% rename from src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java rename to src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index 98b3027ee..b322947fe 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -19,8 +19,8 @@ import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.SkillUtils; -public class AxeManager extends SkillManager { - public AxeManager(McMMOPlayer mcMMOPlayer) { +public class AxesManager extends SkillManager { + public AxesManager(McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, SkillType.AXES); } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 3826f715d..c10caf468 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -31,10 +31,14 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.runnables.skills.AwardCombatXpTask; import com.gmail.nossr50.runnables.skills.BleedTimerTask; -import com.gmail.nossr50.skills.SkillManagerStore; -import com.gmail.nossr50.skills.axes.AxeManager; +import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; +import com.gmail.nossr50.skills.archery.ArcheryManager; +import com.gmail.nossr50.skills.axes.AxesManager; import com.gmail.nossr50.skills.swords.Swords; +import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.Taming; +import com.gmail.nossr50.skills.taming.TamingManager; +import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ModUtils; @@ -56,6 +60,7 @@ public final class CombatUtils { if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) { Player player = (Player) attacker; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); if (Misc.isNPCEntity(player)) { return; @@ -65,7 +70,7 @@ public final class CombatUtils { if (target instanceof Tameable) { if (heldItem.getType() == Material.BONE && Permissions.beastLore(player)) { - SkillManagerStore.getInstance().getTamingManager(player.getName()).beastLore(target); + mcMMOPlayer.getTamingManager().beastLore(target); event.setCancelled(true); return; } @@ -85,21 +90,21 @@ public final class CombatUtils { } if (Permissions.skillEnabled(player, SkillType.SWORDS)) { - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - String playerName = player.getName(); boolean canSerratedStrike = Permissions.serratedStrikes(player); // So we don't have to check the same permission twice if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) { SkillUtils.abilityCheck(player, SkillType.SWORDS); } + SwordsManager swordsManager = mcMMOPlayer.getSwordsManager(); + if (Permissions.bleed(player)) { - SkillManagerStore.getInstance().getSwordsManager(playerName).bleedCheck(target); + swordsManager.bleedCheck(target); } if (profile.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) { - SkillManagerStore.getInstance().getSwordsManager(playerName).serratedStrikes(target, event.getDamage()); + swordsManager.serratedStrikes(target, event.getDamage()); } startGainXp(mcMMOPlayer, target, SkillType.SWORDS); @@ -111,32 +116,32 @@ public final class CombatUtils { } if (Permissions.skillEnabled(player, SkillType.AXES)) { - AxeManager axeManager = SkillManagerStore.getInstance().getAxeManager(player.getName()); + AxesManager axesManager = mcMMOPlayer.getAxesManager(); - if (axeManager.canActivateAbility()) { + if (axesManager.canActivateAbility()) { SkillUtils.abilityCheck(player, SkillType.AXES); } - if (axeManager.canUseAxeMastery()) { - event.setDamage(axeManager.axeMasteryCheck(event.getDamage())); + if (axesManager.canUseAxeMastery()) { + event.setDamage(axesManager.axeMasteryCheck(event.getDamage())); } - if (axeManager.canCriticalHit(target)) { - event.setDamage(axeManager.criticalHitCheck(target, event.getDamage())); + if (axesManager.canCriticalHit(target)) { + event.setDamage(axesManager.criticalHitCheck(target, event.getDamage())); } - if (axeManager.canImpact(target)) { - axeManager.impactCheck(target); + if (axesManager.canImpact(target)) { + axesManager.impactCheck(target); } - else if (axeManager.canGreaterImpact(target)) { - event.setDamage(axeManager.greaterImpactCheck(target, event.getDamage())); + else if (axesManager.canGreaterImpact(target)) { + event.setDamage(axesManager.greaterImpactCheck(target, event.getDamage())); } - if (axeManager.canUseSkullSplitter(target)) { - axeManager.skullSplitterCheck(target, event.getDamage()); + if (axesManager.canUseSkullSplitter(target)) { + axesManager.skullSplitterCheck(target, event.getDamage()); } - startGainXp(axeManager.getMcMMOPlayer(), target, SkillType.AXES); + startGainXp(axesManager.getMcMMOPlayer(), target, SkillType.AXES); } } else if (heldItem.getType() == Material.AIR) { @@ -150,9 +155,7 @@ public final class CombatUtils { } if (Permissions.skillEnabled(player, SkillType.UNARMED)) { - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - String playerName = player.getName(); boolean canBerserk = Permissions.berserk(player); // So we don't have to check the same permission twice @@ -160,19 +163,21 @@ public final class CombatUtils { SkillUtils.abilityCheck(player, SkillType.UNARMED); } + UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager(); + if (Permissions.bonusDamage(player, SkillType.UNARMED)) { - event.setDamage(SkillManagerStore.getInstance().getUnarmedManager(playerName).ironArmCheck(event.getDamage())); + event.setDamage(unarmedManager.ironArmCheck(event.getDamage())); } if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) { - event.setDamage(SkillManagerStore.getInstance().getUnarmedManager(playerName).berserkDamage(event.getDamage())); + event.setDamage(unarmedManager.berserkDamage(event.getDamage())); } if (target instanceof Player && Permissions.disarm(player)) { Player defender = (Player) target; if (defender.getItemInHand().getType() != Material.AIR) { - SkillManagerStore.getInstance().getUnarmedManager(playerName).disarmCheck((Player) target); + unarmedManager.disarmCheck((Player) target); } } @@ -203,18 +208,19 @@ public final class CombatUtils { if (Permissions.skillEnabled(master, SkillType.TAMING)) { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master); - int skillLevel = SkillManagerStore.getInstance().getTamingManager(master.getName()).getSkillLevel(); + TamingManager tamingManager = mcMMOPlayer.getTamingManager(); + int skillLevel = tamingManager.getSkillLevel(); if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) { - SkillManagerStore.getInstance().getTamingManager(master.getName()).fastFoodService(wolf, event.getDamage()); + tamingManager.fastFoodService(wolf, event.getDamage()); } if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) { - SkillManagerStore.getInstance().getTamingManager(master.getName()).sharpenedClaws(event); + tamingManager.sharpenedClaws(event); } if (Permissions.gore(master)) { - SkillManagerStore.getInstance().getTamingManager(master.getName()).gore(event); + tamingManager.gore(event); } startGainXp(mcMMOPlayer, target, SkillType.TAMING); @@ -254,20 +260,23 @@ public final class CombatUtils { return; } - ItemStack heldItem = player.getItemInHand(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager(); - if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canDodge(damager)) { - event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event.getDamage())); + if (acrobaticsManager.canDodge(damager)) { + event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage())); } + ItemStack heldItem = player.getItemInHand(); + if (damager instanceof Player) { if (SkillType.SWORDS.getPVPEnabled() && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) { - SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); + mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage()); } } else { if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) { - SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage()); + mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage()); } } } @@ -286,29 +295,30 @@ public final class CombatUtils { } if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) { - String playerName = shooter.getName(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(shooter); + ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager(); - if (SkillManagerStore.getInstance().getArcheryManager(playerName).canSkillShot()) { - event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).skillShotCheck(event.getDamage())); + if (archeryManager.canSkillShot()) { + event.setDamage(archeryManager.skillShotCheck(event.getDamage())); } if (target instanceof Player && SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) { - event.setCancelled(SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck()); + event.setCancelled(mcMMOPlayer.getUnarmedManager().deflectCheck()); if (event.isCancelled()) { return; } } - if (SkillManagerStore.getInstance().getArcheryManager(playerName).canDaze(target)) { - event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).dazeCheck((Player) target, event.getDamage())); + if (archeryManager.canDaze(target)) { + event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage())); } - if (SkillManagerStore.getInstance().getArcheryManager(playerName).canTrackArrows()) { - SkillManagerStore.getInstance().getArcheryManager(playerName).trackArrows(target); + if (archeryManager.canTrackArrows()) { + archeryManager.trackArrows(target); } - SkillManagerStore.getInstance().getArcheryManager(playerName).distanceXpBonus(target); + archeryManager.distanceXpBonus(target); startGainXp(UserManager.getPlayer(shooter), target, SkillType.ARCHERY); } } From c0b7f8a32370d1ac9f3bd7d7fec54fcd3f24aaab Mon Sep 17 00:00:00 2001 From: bm01 Date: Sun, 3 Mar 2013 17:06:05 +0100 Subject: [PATCH 118/137] Moved everything that could be moved from PlayerProfile to McMMOPlayer PlayerProfile now only store stored (flatfile or MySQL) data --- .../com/gmail/nossr50/api/AbilityAPI.java | 20 +- .../nossr50/commands/McabilityCommand.java | 19 +- .../gmail/nossr50/commands/McgodCommand.java | 21 +- .../nossr50/commands/McnotifyCommand.java | 8 +- .../nossr50/commands/McrefreshCommand.java | 28 +- .../nossr50/commands/party/PtpCommand.java | 14 +- .../nossr50/datatypes/player/McMMOPlayer.java | 235 +++++++++- .../datatypes/player/PlayerProfile.java | 406 +----------------- .../nossr50/listeners/BlockListener.java | 43 +- .../nossr50/listeners/EntityListener.java | 6 +- .../nossr50/listeners/PlayerListener.java | 14 +- .../runnables/skills/SkillMonitorTask.java | 8 +- .../skills/acrobatics/AcrobaticsManager.java | 7 +- .../skills/archery/ArcheryManager.java | 4 +- .../nossr50/skills/axes/AxesManager.java | 8 +- .../skills/herbalism/HerbalismManager.java | 12 +- .../nossr50/skills/mining/MiningManager.java | 5 +- .../gmail/nossr50/skills/repair/Repair.java | 6 +- .../gmail/nossr50/skills/repair/Salvage.java | 8 +- .../nossr50/skills/swords/SwordsManager.java | 4 +- .../nossr50/skills/taming/TamingManager.java | 6 +- .../com/gmail/nossr50/util/ChimaeraWing.java | 4 +- .../nossr50/util/skills/CombatUtils.java | 22 +- .../gmail/nossr50/util/skills/SkillUtils.java | 100 +++-- 24 files changed, 405 insertions(+), 603 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/api/AbilityAPI.java b/src/main/java/com/gmail/nossr50/api/AbilityAPI.java index 515bf14f3..52743f42e 100644 --- a/src/main/java/com/gmail/nossr50/api/AbilityAPI.java +++ b/src/main/java/com/gmail/nossr50/api/AbilityAPI.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.api; import org.bukkit.entity.Player; -import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.util.player.UserManager; @@ -10,38 +10,38 @@ public final class AbilityAPI { private AbilityAPI() {} public static boolean berserkEnabled(Player player) { - return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.BERSERK); + return UserManager.getPlayer(player).getAbilityMode(AbilityType.BERSERK); } public static boolean gigaDrillBreakerEnabled(Player player) { - return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.GIGA_DRILL_BREAKER); + return UserManager.getPlayer(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER); } public static boolean greenTerraEnabled(Player player) { - return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.GREEN_TERRA); + return UserManager.getPlayer(player).getAbilityMode(AbilityType.GREEN_TERRA); } public static boolean serratedStrikesEnabled(Player player) { - return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.SERRATED_STRIKES); + return UserManager.getPlayer(player).getAbilityMode(AbilityType.SERRATED_STRIKES); } public static boolean skullSplitterEnabled(Player player) { - return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER); + return UserManager.getPlayer(player).getAbilityMode(AbilityType.SKULL_SPLITTER); } public static boolean superBreakerEnabled(Player player) { - return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.SUPER_BREAKER); + return UserManager.getPlayer(player).getAbilityMode(AbilityType.SUPER_BREAKER); } public static boolean treeFellerEnabled(Player player) { - return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.TREE_FELLER); + return UserManager.getPlayer(player).getAbilityMode(AbilityType.TREE_FELLER); } public static boolean isAnyAbilityEnabled(Player player) { - PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); for (AbilityType ability : AbilityType.values()) { - if (profile.getAbilityMode(ability)) { + if (mcMMOPlayer.getAbilityMode(ability)) { return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java b/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java index 69016d96a..aeaf06e9a 100644 --- a/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java @@ -14,7 +14,7 @@ import com.gmail.nossr50.util.player.UserManager; public class McabilityCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; + McMMOPlayer mcMMOPlayer; switch (args.length) { case 0: @@ -23,16 +23,16 @@ public class McabilityCommand implements CommandExecutor { return true; } - profile = UserManager.getPlayer((Player) sender).getProfile(); + mcMMOPlayer = UserManager.getPlayer((Player) sender); - if (profile.getAbilityUse()) { + if (mcMMOPlayer.getAbilityUse()) { sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off")); } else { sender.sendMessage(LocaleLoader.getString("Commands.Ability.On")); } - profile.toggleAbilityUse(); + mcMMOPlayer.toggleAbilityUse(); return true; case 1: @@ -41,12 +41,12 @@ public class McabilityCommand implements CommandExecutor { return true; } - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + mcMMOPlayer = UserManager.getPlayer(args[0]); if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); + PlayerProfile playerProfile = new PlayerProfile(args[0], false); - if (!profile.isLoaded()) { + if (!playerProfile.isLoaded()) { sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); return true; } @@ -56,21 +56,20 @@ public class McabilityCommand implements CommandExecutor { } Player player = mcMMOPlayer.getPlayer(); - profile = mcMMOPlayer.getProfile(); if (!player.isOnline()) { sender.sendMessage(LocaleLoader.getString("Commands.Offline")); return true; } - if (profile.getAbilityUse()) { + if (mcMMOPlayer.getAbilityUse()) { player.sendMessage(LocaleLoader.getString("Commands.Ability.Off")); } else { player.sendMessage(LocaleLoader.getString("Commands.Ability.On")); } - profile.toggleAbilityUse(); + mcMMOPlayer.toggleAbilityUse(); return true; default: diff --git a/src/main/java/com/gmail/nossr50/commands/McgodCommand.java b/src/main/java/com/gmail/nossr50/commands/McgodCommand.java index 10ea58a24..b89b15b70 100644 --- a/src/main/java/com/gmail/nossr50/commands/McgodCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McgodCommand.java @@ -14,7 +14,7 @@ import com.gmail.nossr50.util.player.UserManager; public class McgodCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; + McMMOPlayer mcMMOPlayer; switch (args.length) { case 0: @@ -27,21 +27,21 @@ public class McgodCommand implements CommandExecutor { return false; } - profile = UserManager.getPlayer((Player) sender).getProfile(); + mcMMOPlayer = UserManager.getPlayer((Player) sender); - if (profile == null) { + if (mcMMOPlayer == null) { sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); return true; } - if (profile.getGodMode()) { + if (mcMMOPlayer.getGodMode()) { sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled")); } else { sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled")); } - profile.toggleGodMode(); + mcMMOPlayer.toggleGodMode(); return true; case 1: @@ -50,12 +50,12 @@ public class McgodCommand implements CommandExecutor { return true; } - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + mcMMOPlayer = UserManager.getPlayer(args[0]); if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); + PlayerProfile playerProfile = new PlayerProfile(args[0], false); - if (!profile.isLoaded()) { + if (!playerProfile.isLoaded()) { sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); return true; } @@ -64,7 +64,6 @@ public class McgodCommand implements CommandExecutor { return true; } - profile = mcMMOPlayer.getProfile(); Player player = mcMMOPlayer.getPlayer(); if (!player.isOnline()) { @@ -72,14 +71,14 @@ public class McgodCommand implements CommandExecutor { return true; } - if (profile.getGodMode()) { + if (mcMMOPlayer.getGodMode()) { player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled")); } else { player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled")); } - profile.toggleGodMode(); + mcMMOPlayer.toggleGodMode(); return true; default: diff --git a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java index da3a42dcd..11a664cb4 100644 --- a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java @@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.player.UserManager; @@ -14,16 +14,16 @@ public class McnotifyCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: - PlayerProfile profile = UserManager.getPlayer((Player) sender).getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); - if (profile.useChatNotifications()) { + if (mcMMOPlayer.useChatNotifications()) { sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off")); } else { sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On")); } - profile.toggleChatNotifications(); + mcMMOPlayer.toggleChatNotifications(); return true; default: diff --git a/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java b/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java index 2ca351d4e..b6bf8b8b2 100644 --- a/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java @@ -14,7 +14,7 @@ import com.gmail.nossr50.util.player.UserManager; public class McrefreshCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; + McMMOPlayer mcMMOPlayer; switch (args.length) { case 0: @@ -27,12 +27,12 @@ public class McrefreshCommand implements CommandExecutor { return false; } - profile = UserManager.getPlayer(sender.getName()).getProfile(); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); - profile.setRecentlyHurt(0); - profile.resetCooldowns(); - profile.resetToolPrepMode(); - profile.resetAbilityMode(); + mcMMOPlayer.setRecentlyHurt(0); + mcMMOPlayer.getProfile().resetCooldowns(); + mcMMOPlayer.resetToolPrepMode(); + mcMMOPlayer.resetAbilityMode(); sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); return true; @@ -43,12 +43,12 @@ public class McrefreshCommand implements CommandExecutor { return true; } - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); + mcMMOPlayer = UserManager.getPlayer(args[0]); if (mcMMOPlayer == null) { - profile = new PlayerProfile(args[0], false); + PlayerProfile playerProfile = new PlayerProfile(args[0], false); - if (!profile.isLoaded()) { + if (!playerProfile.isLoaded()) { sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); return true; } @@ -56,7 +56,7 @@ public class McrefreshCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.Offline")); return true; } - profile = mcMMOPlayer.getProfile(); + Player player = mcMMOPlayer.getPlayer(); if (!player.isOnline()) { @@ -64,10 +64,10 @@ public class McrefreshCommand implements CommandExecutor { return true; } - profile.setRecentlyHurt(0); - profile.resetCooldowns(); - profile.resetToolPrepMode(); - profile.resetAbilityMode(); + mcMMOPlayer.setRecentlyHurt(0); + mcMMOPlayer.getProfile().resetCooldowns(); + mcMMOPlayer.resetToolPrepMode(); + mcMMOPlayer.resetAbilityMode(); player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0])); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java index eb87959a3..4d446d39f 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java @@ -9,7 +9,6 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.PartyManager; @@ -21,7 +20,6 @@ import com.gmail.nossr50.util.player.UserManager; public class PtpCommand implements CommandExecutor { private Player player; private McMMOPlayer mcMMOPlayer; - private PlayerProfile playerProfile; private Player target; private McMMOPlayer mcMMOTarget; @@ -34,10 +32,6 @@ public class PtpCommand implements CommandExecutor { switch (args.length) { case 1: - player = (Player) sender; - mcMMOPlayer = UserManager.getPlayer(player); - playerProfile = mcMMOPlayer.getProfile(); - if (args[0].equalsIgnoreCase("toggle")) { if (!Permissions.partyTeleportToggle(sender)) { sender.sendMessage(command.getPermissionMessage()); @@ -56,8 +50,9 @@ public class PtpCommand implements CommandExecutor { return acceptAnyTeleportRequest(); } + player = (Player) sender; int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); - long recentlyHurt = playerProfile.getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR; + long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR; if (System.currentTimeMillis() - recentlyHurt >= (ptpCooldown * Misc.TIME_CONVERSION_FACTOR)) { player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown)); @@ -94,6 +89,7 @@ public class PtpCommand implements CommandExecutor { player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout(); + target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire)); return true; @@ -203,8 +199,8 @@ public class PtpCommand implements CommandExecutor { private boolean handlePartyTeleportEvent(Player player, Player target) { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName()); + mcMMO.p.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -214,7 +210,7 @@ public class PtpCommand implements CommandExecutor { player.teleport(target); player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", target.getName())); target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", player.getName())); - mcMMOPlayer.getProfile().actualizeRecentlyHurt(); + mcMMOPlayer.actualizeRecentlyHurt(); return true; } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 6d436fc52..f1d4d4c90 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -12,7 +12,9 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.mods.CustomTool; import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; import com.gmail.nossr50.party.PartyManager; @@ -49,8 +51,9 @@ public class McMMOPlayer { */ private Map skillManagers = new HashMap(); - private Party party; - private Party invite; + private Party party; + private Party invite; + private int itemShareModifier; private Player ptpRequest; private boolean ptpEnabled = true; @@ -59,8 +62,20 @@ public class McMMOPlayer { private boolean partyChatMode; private boolean adminChatMode; + private boolean displaySkillNotifications = true; - private int itemShareModifier; + private boolean abilityUse = true; + private boolean placedAnvil; + private boolean placedSalvageAnvil; + private boolean godMode; + + private Map abilityMode = new HashMap(); + private Map abilityInformed = new HashMap(); + private Map toolPreparationMode = new HashMap(); + private Map toolATS = new HashMap(); + + private int recentlyHurt; + private int respawnATS; public McMMOPlayer(Player player) { String playerName = player.getName(); @@ -88,6 +103,16 @@ public class McMMOPlayer { e.printStackTrace(); mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p); } + + for (AbilityType abilityType : AbilityType.values()) { + abilityMode.put(abilityType, false); + abilityInformed.put(abilityType, true); // This is intended + } + + for (ToolType toolType : ToolType.values()) { + toolPreparationMode.put(toolType, false); + toolATS.put(toolType, 0); + } } public AcrobaticsManager getAcrobaticsManager() { @@ -134,6 +159,198 @@ public class McMMOPlayer { return (UnarmedManager) skillManagers.get(SkillType.UNARMED); } + /* + * Abilities + */ + + /** + * Reset the mode of all abilities. + */ + public void resetAbilityMode() { + for (AbilityType ability : AbilityType.values()) { + setAbilityMode(ability, false); + } + } + + /** + * Get the mode of an ability. + * + * @param ability The ability to check + * @return true if the ability is enabled, false otherwise + */ + public boolean getAbilityMode(AbilityType ability) { + return abilityMode.get(ability); + } + + /** + * Set the mode of an ability. + * + * @param ability The ability to check + * @param bool True if the ability is active, false otherwise + */ + public void setAbilityMode(AbilityType ability, boolean bool) { + abilityMode.put(ability, bool); + } + + /** + * Get the informed state of an ability + * + * @param ability The ability to check + * @return true if the ability is informed, false otherwise + */ + public boolean getAbilityInformed(AbilityType ability) { + return abilityInformed.get(ability); + } + + /** + * Set the informed state of an ability. + * + * @param ability The ability to check + * @param bool True if the ability is informed, false otherwise + */ + public void setAbilityInformed(AbilityType ability, boolean bool) { + abilityInformed.put(ability, bool); + } + + /** + * Get the current prep mode of a tool. + * + * @param tool Tool to get the mode for + * @return true if the tool is prepped, false otherwise + */ + public boolean getToolPreparationMode(ToolType tool) { + return toolPreparationMode.get(tool); + } + + public boolean getAbilityUse() { + return abilityUse; + } + + public void toggleAbilityUse() { + abilityUse = !abilityUse; + } + + /* + * Tools + */ + + /** + * Reset the prep modes of all tools. + */ + public void resetToolPrepMode() { + for (ToolType tool : ToolType.values()) { + setToolPreparationMode(tool, false); + } + } + + /** + * Set the current prep mode of a tool. + * + * @param tool Tool to set the mode for + * @param bool true if the tool should be prepped, false otherwise + */ + public void setToolPreparationMode(ToolType tool, boolean bool) { + toolPreparationMode.put(tool, bool); + } + + /** + * Get the current prep ATS of a tool. + * + * @param tool Tool to get the ATS for + * @return the ATS for the tool + */ + public long getToolPreparationATS(ToolType tool) { + return toolATS.get(tool); + } + + /** + * Set the current prep ATS of a tool. + * + * @param tool Tool to set the ATS for + * @param ATS the ATS of the tool + */ + public void setToolPreparationATS(ToolType tool, long ATS) { + int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR); + + toolATS.put(tool, startTime); + } + + /* + * Recently Hurt + */ + + public int getRecentlyHurt() { + return recentlyHurt; + } + + public void setRecentlyHurt(int value) { + recentlyHurt = value; + } + + public void actualizeRecentlyHurt() { + recentlyHurt = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + + /* + * Exploit Prevention + */ + + public int getRespawnATS() { + return respawnATS; + } + + public void actualizeRespawnATS() { + respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + + /* + * Repair Anvil Placement + */ + + public void togglePlacedAnvil() { + placedAnvil = !placedAnvil; + } + + public Boolean getPlacedAnvil() { + return placedAnvil; + } + + /* + * Salvage Anvil Placement + */ + + public void togglePlacedSalvageAnvil() { + placedSalvageAnvil = !placedSalvageAnvil; + } + + public Boolean getPlacedSalvageAnvil() { + return placedSalvageAnvil; + } + + /* + * God Mode + */ + + public boolean getGodMode() { + return godMode; + } + + public void toggleGodMode() { + godMode = !godMode; + } + + /* + * Skill notifications + */ + + public boolean useChatNotifications() { + return displaySkillNotifications; + } + + public void toggleChatNotifications() { + displaySkillNotifications = !displaySkillNotifications; + } + /** * Gets the power level of this player. * @@ -223,7 +440,9 @@ public class McMMOPlayer { SkillUtils.xpCheckSkill(skillType, player, profile); } - // Players & Profiles + /* + * Players & Profiles + */ public Player getPlayer() { return player; @@ -237,7 +456,9 @@ public class McMMOPlayer { return profile; } - // Party Stuff + /* + * Party Stuff + */ public void setPartyInvite(Party invite) { this.invite = invite; @@ -339,6 +560,10 @@ public class McMMOPlayer { itemShareModifier = modifier; } + /* + * Chat modes + */ + public boolean getAdminChatMode() { return adminChatMode; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 3c7a91179..8b36d2cf0 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -6,6 +6,7 @@ import java.io.FileReader; import java.io.FileWriter; import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; import java.util.Set; import com.gmail.nossr50.mcMMO; @@ -14,7 +15,6 @@ import com.gmail.nossr50.config.spout.SpoutConfig; import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; -import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.spout.huds.HudType; import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; import com.gmail.nossr50.skills.child.FamilyTree; @@ -28,51 +28,14 @@ public class PlayerProfile { private McMMOHud spoutHud; private HudType hudType; - // Toggles - private boolean loaded; - private boolean godMode; - - private boolean placedAnvil; - private boolean placedSalvageAnvil; - - private boolean hoePreparationMode; - private boolean shovelPreparationMode; - private boolean swordsPreparationMode; - private boolean fistsPreparationMode; - private boolean pickaxePreparationMode; - private boolean axePreparationMode; - - private boolean greenTerraMode; - private boolean treeFellerMode; - private boolean superBreakerMode; - private boolean gigaDrillBreakerMode; - private boolean serratedStrikesMode; - private boolean skullSplitterMode; - private boolean berserkMode; - - private boolean greenTerraInformed = true; - private boolean berserkInformed = true; - private boolean skullSplitterInformed = true; - private boolean gigaDrillBreakerInformed = true; - private boolean superBreakerInformed = true; - private boolean blastMiningInformed = true; - private boolean serratedStrikesInformed = true; - private boolean treeFellerInformed = true; - - private boolean abilityUse = true; - private boolean displaySkillNotifications = true; - - // Timestamps - private int recentlyHurt; - private int respawnATS; - // mySQL Stuff private int userId; - private HashMap skills = new HashMap(); // Skills and Levels - private HashMap skillsXp = new HashMap(); // Skills and Xp - private HashMap skillsDATS = new HashMap(); - private HashMap toolATS = new HashMap(); + private boolean loaded; + + private Map skills = new HashMap(); // Skills and Levels + private Map skillsXp = new HashMap(); // Skills and Xp + private Map skillsDATS = new HashMap(); private final static String location = mcMMO.getUsersFilePath(); @@ -565,42 +528,6 @@ public class PlayerProfile { return loaded; } - /* - * God Mode - */ - - public boolean getGodMode() { - return godMode; - } - - public void toggleGodMode() { - godMode = !godMode; - } - - /* - * Repair Anvil Placement - */ - - public void togglePlacedAnvil() { - placedAnvil = !placedAnvil; - } - - public Boolean getPlacedAnvil() { - return placedAnvil; - } - - /* - * Salvage Anvil Placement - */ - - public void togglePlacedSalvageAnvil() { - placedSalvageAnvil = !placedSalvageAnvil; - } - - public Boolean getPlacedSalvageAnvil() { - return placedSalvageAnvil; - } - /* * HUD Stuff */ @@ -621,315 +548,6 @@ public class PlayerProfile { this.hudType = hudType; } - /* - * Tools - */ - - /** - * Reset the prep modes of all tools. - */ - public void resetToolPrepMode() { - for (ToolType tool : ToolType.values()) { - setToolPreparationMode(tool, false); - } - } - - /** - * Get the current prep mode of a tool. - * - * @param tool Tool to get the mode for - * @return true if the tool is prepped, false otherwise - */ - public boolean getToolPreparationMode(ToolType tool) { - switch (tool) { - case AXE: - return axePreparationMode; - - case FISTS: - return fistsPreparationMode; - - case HOE: - return hoePreparationMode; - - case PICKAXE: - return pickaxePreparationMode; - - case SHOVEL: - return shovelPreparationMode; - - case SWORD: - return swordsPreparationMode; - - default: - return false; - } - } - - /** - * Set the current prep mode of a tool. - * - * @param tool Tool to set the mode for - * @param bool true if the tool should be prepped, false otherwise - */ - public void setToolPreparationMode(ToolType tool, boolean bool) { - switch (tool) { - case AXE: - axePreparationMode = bool; - break; - - case FISTS: - fistsPreparationMode = bool; - break; - - case HOE: - hoePreparationMode = bool; - break; - - case PICKAXE: - pickaxePreparationMode = bool; - break; - - case SHOVEL: - shovelPreparationMode = bool; - break; - - case SWORD: - swordsPreparationMode = bool; - break; - - default: - break; - } - } - - /** - * Get the current prep ATS of a tool. - * - * @param tool Tool to get the ATS for - * @return the ATS for the tool - */ - public long getToolPreparationATS(ToolType tool) { - return toolATS.get(tool); - } - - /** - * Set the current prep ATS of a tool. - * - * @param tool Tool to set the ATS for - * @param ATS the ATS of the tool - */ - public void setToolPreparationATS(ToolType tool, long ATS) { - int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR); - - toolATS.put(tool, startTime); - } - - /* - * Abilities - */ - - /** - * Reset the prep modes of all tools. - */ - public void resetAbilityMode() { - for (AbilityType ability : AbilityType.values()) { - setAbilityMode(ability, false); - } - } - - /** - * Get the mode of an ability. - * - * @param ability The ability to check - * @return true if the ability is enabled, false otherwise - */ - public boolean getAbilityMode(AbilityType ability) { - switch (ability) { - case BERSERK: - return berserkMode; - - case SUPER_BREAKER: - return superBreakerMode; - - case GIGA_DRILL_BREAKER: - return gigaDrillBreakerMode; - - case GREEN_TERRA: - return greenTerraMode; - - case SKULL_SPLITTER: - return skullSplitterMode; - - case TREE_FELLER: - return treeFellerMode; - - case SERRATED_STRIKES: - return serratedStrikesMode; - - default: - return false; - } - } - - /** - * Set the mode of an ability. - * - * @param ability The ability to check - * @param bool True if the ability is active, false otherwise - */ - public void setAbilityMode(AbilityType ability, boolean bool) { - switch (ability) { - case BERSERK: - berserkMode = bool; - break; - - case SUPER_BREAKER: - superBreakerMode = bool; - break; - - case GIGA_DRILL_BREAKER: - gigaDrillBreakerMode = bool; - break; - - case GREEN_TERRA: - greenTerraMode = bool; - break; - - case SKULL_SPLITTER: - skullSplitterMode = bool; - break; - - case TREE_FELLER: - treeFellerMode = bool; - break; - - case SERRATED_STRIKES: - serratedStrikesMode = bool; - break; - - default: - break; - } - } - - /** - * Get the informed state of an ability - * - * @param ability The ability to check - * @return true if the ability is informed, false otherwise - */ - public boolean getAbilityInformed(AbilityType ability) { - switch (ability) { - case BERSERK: - return berserkInformed; - - case BLAST_MINING: - return blastMiningInformed; - - case SUPER_BREAKER: - return superBreakerInformed; - - case GIGA_DRILL_BREAKER: - return gigaDrillBreakerInformed; - - case GREEN_TERRA: - return greenTerraInformed; - - case SKULL_SPLITTER: - return skullSplitterInformed; - - case TREE_FELLER: - return treeFellerInformed; - - case SERRATED_STRIKES: - return serratedStrikesInformed; - - default: - return false; - } - } - - /** - * Set the informed state of an ability. - * - * @param ability The ability to check - * @param bool True if the ability is informed, false otherwise - */ - public void setAbilityInformed(AbilityType ability, boolean bool) { - switch (ability) { - case BERSERK: - berserkInformed = bool; - break; - - case BLAST_MINING: - blastMiningInformed = bool; - break; - - case SUPER_BREAKER: - superBreakerInformed = bool; - break; - - case GIGA_DRILL_BREAKER: - gigaDrillBreakerInformed = bool; - break; - - case GREEN_TERRA: - greenTerraInformed = bool; - break; - - case SKULL_SPLITTER: - skullSplitterInformed = bool; - break; - - case TREE_FELLER: - treeFellerInformed = bool; - break; - - case SERRATED_STRIKES: - serratedStrikesInformed = bool; - break; - - default: - break; - } - } - - public boolean getAbilityUse() { - return abilityUse; - } - - public void toggleAbilityUse() { - abilityUse = !abilityUse; - } - - /* - * Recently Hurt - */ - - public int getRecentlyHurt() { - return recentlyHurt; - } - - public void setRecentlyHurt(int value) { - recentlyHurt = value; - } - - public void actualizeRecentlyHurt() { - recentlyHurt = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); - } - - /* - * Ability Notifications - */ - - public boolean useChatNotifications() { - return displaySkillNotifications; - } - - public void toggleChatNotifications() { - displaySkillNotifications = !displaySkillNotifications; - } - /* * Cooldowns */ @@ -965,18 +583,6 @@ public class PlayerProfile { } } - /* - * Exploit Prevention - */ - - public int getRespawnATS() { - return respawnATS; - } - - public void actualizeRespawnATS() { - respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); - } - /* * Xp Functions */ diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 39f15e147..5274d8ca0 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -23,7 +23,6 @@ import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.ToolType; @@ -145,7 +144,6 @@ public class BlockListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - PlayerProfile profile = mcMMOPlayer.getProfile(); BlockState blockState = event.getBlock().getState(); ItemStack heldItem = player.getItemInHand(); @@ -156,7 +154,7 @@ public class BlockListener implements Listener { /* Green Terra */ if (herbalismManager.canActivateAbility()) { - SkillUtils.abilityCheck(player, SkillType.HERBALISM); + SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM); } /* @@ -180,14 +178,14 @@ public class BlockListener implements Listener { MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); miningManager.miningBlockCheck(blockState); - if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) { + if (mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) { miningManager.miningBlockCheck(blockState); } } /* WOOD CUTTING */ else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) { - if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) { + if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) { Woodcutting.beginTreeFeller(blockState, player); } else { @@ -207,7 +205,7 @@ public class BlockListener implements Listener { ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager(); excavationManager.excavationBlockCheck(blockState); - if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { + if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { excavationManager.gigaDrillBreaker(blockState); } } @@ -271,7 +269,7 @@ public class BlockListener implements Listener { return; } - PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); BlockState blockState = event.getBlock().getState(); /* @@ -283,30 +281,30 @@ public class BlockListener implements Listener { ItemStack heldItem = player.getItemInHand(); if (HiddenConfig.getInstance().useEnchantmentBuffs()) { - if ((ItemUtils.isPickaxe(heldItem) && !profile.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) { + if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) { SkillUtils.removeAbilityBuff(heldItem); } } else { - if ((profile.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) { + if ((mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) { SkillUtils.handleAbilitySpeedDecrease(player); } } - if (profile.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) { - SkillUtils.abilityCheck(player, SkillType.HERBALISM); + if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) { + SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM); } - else if (profile.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) { - SkillUtils.abilityCheck(player, SkillType.WOODCUTTING); + else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) { + SkillUtils.abilityCheck(mcMMOPlayer, SkillType.WOODCUTTING); } - else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) { - SkillUtils.abilityCheck(player, SkillType.MINING); + else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) { + SkillUtils.abilityCheck(mcMMOPlayer, SkillType.MINING); } - else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) { - SkillUtils.abilityCheck(player, SkillType.EXCAVATION); + else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) { + SkillUtils.abilityCheck(mcMMOPlayer, SkillType.EXCAVATION); } - else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) { - SkillUtils.abilityCheck(player, SkillType.UNARMED); + else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) { + SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED); } } @@ -315,7 +313,7 @@ public class BlockListener implements Listener { * * We don't need to check permissions here because they've already been checked for the ability to even activate. */ - if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState)) { + if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState)) { player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH); } } @@ -338,7 +336,6 @@ public class BlockListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - PlayerProfile profile = mcMMOPlayer.getProfile(); ItemStack heldItem = player.getItemInHand(); Block block = event.getBlock(); BlockState blockState = block.getState(); @@ -354,7 +351,7 @@ public class BlockListener implements Listener { blockState.update(true); } } - else if (profile.getAbilityMode(AbilityType.BERSERK)) { + else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) { if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) { if (heldItem.getType() == Material.AIR) { plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player)); @@ -370,7 +367,7 @@ public class BlockListener implements Listener { } } } - else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockUtils.isLeaves(blockState)) { + else if ((mcMMOPlayer.getProfile().getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockUtils.isLeaves(blockState)) { if (SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) { if (Config.getInstance().getWoodcuttingRequiresTool()) { if (ItemUtils.isAxe(heldItem)) { diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index b9b29071f..0448977b9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -28,7 +28,6 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.party.PartyManager; @@ -161,10 +160,9 @@ public class EntityListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - PlayerProfile profile = mcMMOPlayer.getProfile(); /* Check for invincibility */ - if (profile.getGodMode()) { + if (mcMMOPlayer.getGodMode()) { event.setCancelled(true); return; } @@ -201,7 +199,7 @@ public class EntityListener implements Listener { } if (event.getDamage() >= 1) { - profile.actualizeRecentlyHurt(); + mcMMOPlayer.actualizeRecentlyHurt(); } } else if (livingEntity instanceof Tameable) { diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 0de27e591..8af4d21f5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -30,7 +30,6 @@ import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; @@ -101,10 +100,9 @@ public class PlayerListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - PlayerProfile profile = mcMMOPlayer.getProfile(); - if (profile.getGodMode() && !Permissions.mcgod(player)) { - profile.toggleGodMode(); + if (mcMMOPlayer.getGodMode() && !Permissions.mcgod(player)) { + mcMMOPlayer.toggleGodMode(); player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden")); } @@ -128,7 +126,7 @@ public class PlayerListener implements Listener { return; } - UserManager.addUser(player).getProfile().actualizeRespawnATS(); + UserManager.addUser(player).actualizeRespawnATS(); } } @@ -140,9 +138,9 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerDropItemEvent(PlayerDropItemEvent event) { Player player = event.getPlayer(); - PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) { + if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) { event.setCancelled(true); return; } @@ -261,7 +259,7 @@ public class PlayerListener implements Listener { return; } - UserManager.getPlayer(player).getProfile().actualizeRespawnATS(); + UserManager.getPlayer(player).actualizeRespawnATS(); } /** diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java index 5d8c9f137..dffbba9ca 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java @@ -3,7 +3,7 @@ package com.gmail.nossr50.runnables.skills; import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.util.Misc; @@ -20,14 +20,14 @@ public class SkillMonitorTask implements Runnable { continue; } - PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); /* * MONITOR SKILLS */ for (SkillType skill : SkillType.values()) { if (skill.getTool() != null && skill.getAbility() != null) { - SkillUtils.monitorSkill(player, profile, curTime, skill); + SkillUtils.monitorSkill(mcMMOPlayer, curTime, skill); } } @@ -36,7 +36,7 @@ public class SkillMonitorTask implements Runnable { */ for (AbilityType ability : AbilityType.values()) { if (ability.getCooldown() > 0) { - SkillUtils.watchCooldown(player, profile, ability); + SkillUtils.watchCooldown(mcMMOPlayer, ability); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 93350b314..c9df41cd9 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -6,7 +6,6 @@ import org.bukkit.entity.LightningStrike; import org.bukkit.entity.Player; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; @@ -52,14 +51,12 @@ public class AcrobaticsManager extends SkillManager { if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) { ParticleEffectUtils.playDodgeEffect(player); - PlayerProfile playerProfile = getProfile(); - - if (playerProfile.useChatNotifications()) { + if (mcMMOPlayer.useChatNotifications()) { player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc")); } // Why do we check respawn cooldown here? - if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) { + if (System.currentTimeMillis() >= mcMMOPlayer.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) { applyXpGain(damage * Acrobatics.dodgeXpModifier); } diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 3d6e610bb..15d5053a6 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -86,11 +86,11 @@ public class ArcheryManager extends SkillManager { defender.teleport(dazedLocation); defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10)); - if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) { + if (UserManager.getPlayer(defender).useChatNotifications()) { defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy")); } - if (getProfile().useChatNotifications()) { + if (mcMMOPlayer.useChatNotifications()) { attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed")); } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index b322947fe..f579307a7 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -41,11 +41,11 @@ public class AxesManager extends SkillManager { } public boolean canUseSkullSplitter(LivingEntity target) { - return target.isValid() && getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer()); + return target.isValid() && mcMMOPlayer.getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer()); } public boolean canActivateAbility() { - return getProfile().getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer()); + return mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer()); } /** @@ -118,14 +118,14 @@ public class AxesManager extends SkillManager { ParticleEffectUtils.playGreaterImpactEffect(target); target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier)); - if (getProfile().useChatNotifications()) { + if (mcMMOPlayer.useChatNotifications()) { player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc")); } if (target instanceof Player) { Player defender = (Player) target; - if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) { + if (UserManager.getPlayer(defender).useChatNotifications()) { defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck")); } } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 5919d5bc4..4f6171589 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -15,7 +15,6 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.treasure.TreasureConfig; import com.gmail.nossr50.datatypes.mods.CustomBlock; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.ToolType; @@ -30,7 +29,6 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ModUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; public class HerbalismManager extends SkillManager { @@ -62,15 +60,15 @@ public class HerbalismManager extends SkillManager { } public boolean canGreenTerraBlock(BlockState blockState) { - return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState); + return mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState); } public boolean canActivateAbility() { - return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer()); + return mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer()); } public boolean canGreenTerraPlant() { - return getProfile().getAbilityMode(AbilityType.GREEN_TERRA); + return mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA); } /** @@ -288,9 +286,7 @@ public class HerbalismManager extends SkillManager { return; } - PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); - - if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) { + if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA)) { playerInventory.removeItem(seed); player.updateInventory(); // Needed until replacement available diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index a5a1f8116..80b51025f 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -86,7 +86,6 @@ public class MiningManager extends SkillManager{ return; } - PlayerProfile profile = getProfile(); TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class); SkillUtils.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player)); @@ -97,8 +96,8 @@ public class MiningManager extends SkillManager{ targetBlock.setData((byte) 0x0); targetBlock.setType(Material.AIR); - profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis()); - profile.setAbilityInformed(AbilityType.BLAST_MINING, false); + getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis()); + mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java index 64607d624..b8e658c93 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -204,9 +204,9 @@ public class Repair { * @param anvilID The item ID of the anvil block */ public static void placedAnvilCheck(Player player, int anvilID) { - PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - if (!profile.getPlacedAnvil()) { + if (!mcMMOPlayer.getPlacedAnvil()) { if (mcMMO.spoutEnabled) { SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); @@ -219,7 +219,7 @@ public class Repair { } player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - profile.togglePlacedAnvil(); + mcMMOPlayer.togglePlacedAnvil(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java index fabd1146c..912abf387 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -11,7 +11,7 @@ import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.ItemUtils; @@ -59,9 +59,9 @@ public class Salvage { * @param anvilID The item ID of the anvil block */ public static void placedAnvilCheck(final Player player, final int anvilID) { - final PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - if (!profile.getPlacedSalvageAnvil()) { + if (!mcMMOPlayer.getPlacedSalvageAnvil()) { if (mcMMO.spoutEnabled) { final SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); @@ -74,7 +74,7 @@ public class Salvage { } player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - profile.togglePlacedSalvageAnvil(); + mcMMOPlayer.togglePlacedSalvageAnvil(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 51e359895..6f181ad2b 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -34,14 +34,14 @@ public class SwordsManager extends SkillManager { BleedTimerTask.add(target, Swords.bleedBaseTicks); } - if (getProfile().useChatNotifications()) { + if (mcMMOPlayer.useChatNotifications()) { player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); } if (target instanceof Player) { Player defender = (Player) target; - if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) { + if (UserManager.getPlayer(defender).useChatNotifications()) { defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started")); } } 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 b907b5bdb..b09f392b8 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -108,7 +108,7 @@ public class TamingManager extends SkillManager { * @param livingEntity The entity to examine */ public void beastLore(LivingEntity livingEntity) { - BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(mcMMOPlayer.getPlayer(), livingEntity); + BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(getPlayer(), livingEntity); eventHandler.sendInspectMessage(); } @@ -119,11 +119,11 @@ public class TamingManager extends SkillManager { * @param summonAmount The amount of material needed to summon the entity */ private void callOfTheWild(EntityType type, int summonAmount) { - if (!Permissions.callOfTheWild(mcMMOPlayer.getPlayer())) { + if (!Permissions.callOfTheWild(getPlayer())) { return; } - CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(mcMMOPlayer.getPlayer(), type, summonAmount); + CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(getPlayer(), type, summonAmount); ItemStack inHand = eventHandler.inHand; int inHandAmount = inHand.getAmount(); diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index f3b861466..db05ac465 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -6,7 +6,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.metrics.MetricsManager; import com.gmail.nossr50.util.player.UserManager; @@ -27,10 +26,9 @@ public final class ChimaeraWing { return; } - PlayerProfile profile = UserManager.getPlayer(player).getProfile(); Block block = player.getLocation().getBlock(); int amount = inHand.getAmount(); - long recentlyHurt = profile.getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR; + long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR; if (Permissions.chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) { if (SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index c10caf468..293fc7f65 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -21,7 +21,6 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.ToolType; @@ -90,11 +89,10 @@ public final class CombatUtils { } if (Permissions.skillEnabled(player, SkillType.SWORDS)) { - PlayerProfile profile = mcMMOPlayer.getProfile(); boolean canSerratedStrike = Permissions.serratedStrikes(player); // So we don't have to check the same permission twice - if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) { - SkillUtils.abilityCheck(player, SkillType.SWORDS); + if (mcMMOPlayer.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) { + SkillUtils.abilityCheck(mcMMOPlayer, SkillType.SWORDS); } SwordsManager swordsManager = mcMMOPlayer.getSwordsManager(); @@ -103,7 +101,7 @@ public final class CombatUtils { swordsManager.bleedCheck(target); } - if (profile.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) { + if (mcMMOPlayer.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) { swordsManager.serratedStrikes(target, event.getDamage()); } @@ -119,7 +117,7 @@ public final class CombatUtils { AxesManager axesManager = mcMMOPlayer.getAxesManager(); if (axesManager.canActivateAbility()) { - SkillUtils.abilityCheck(player, SkillType.AXES); + SkillUtils.abilityCheck(mcMMOPlayer, SkillType.AXES); } if (axesManager.canUseAxeMastery()) { @@ -155,12 +153,10 @@ public final class CombatUtils { } if (Permissions.skillEnabled(player, SkillType.UNARMED)) { - PlayerProfile profile = mcMMOPlayer.getProfile(); - boolean canBerserk = Permissions.berserk(player); // So we don't have to check the same permission twice - if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) { - SkillUtils.abilityCheck(player, SkillType.UNARMED); + if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && canBerserk) { + SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED); } UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager(); @@ -169,7 +165,7 @@ public final class CombatUtils { event.setDamage(unarmedManager.ironArmCheck(event.getDamage())); } - if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) { + if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && canBerserk) { event.setDamage(unarmedManager.berserkDamage(event.getDamage())); } @@ -450,7 +446,7 @@ public final class CombatUtils { Player defender = (Player) target; - if (System.currentTimeMillis() >= UserManager.getPlayer(defender).getProfile().getRespawnATS() + 5) { + if (System.currentTimeMillis() >= UserManager.getPlayer(defender).getRespawnATS() + 5) { baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP(); } } @@ -538,7 +534,7 @@ public final class CombatUtils { if (entity instanceof Player) { Player defender = (Player) entity; - if (!defender.getWorld().getPVP() || defender == player || UserManager.getPlayer(defender).getProfile().getGodMode()) { + if (!defender.getWorld().getPVP() || defender == player || UserManager.getPlayer(defender).getGodMode()) { return false; } diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index 5c313d246..251b7574a 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -21,6 +21,7 @@ import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.config.spout.SpoutConfig; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; @@ -87,17 +88,18 @@ public class SkillUtils { /** * Sends a message to the player when the cooldown expires. * - * @param player The player to send a message to - * @param profile The profile of the player + * @param mcMMOPlayer The player to send a message to * @param ability The ability to watch cooldowns for */ - public static void watchCooldown(Player player, PlayerProfile profile, AbilityType ability) { - if (player == null || profile == null || ability == null) { + public static void watchCooldown(McMMOPlayer mcMMOPlayer, AbilityType ability) { + if (mcMMOPlayer == null || ability == null) { return; } - if (!profile.getAbilityInformed(ability) && cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { - profile.setAbilityInformed(ability, true); + Player player = mcMMOPlayer.getPlayer(); + + if (!mcMMOPlayer.getAbilityInformed(ability) && cooldownOver(mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { + mcMMOPlayer.setAbilityInformed(ability, true); player.sendMessage(ability.getAbilityRefresh()); } } @@ -113,7 +115,7 @@ public class SkillUtils { return; } - PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); AbilityType ability = skill.getAbility(); ToolType tool = skill.getTool(); ItemStack inHand = player.getItemInHand(); @@ -122,29 +124,26 @@ public class SkillUtils { return; } - /* Check if any abilities are active */ - if (profile == null) { + if (!mcMMOPlayer.getAbilityUse()) { return; } - if (!profile.getAbilityUse()) { - return; - } - - for (AbilityType x : AbilityType.values()) { - if (profile.getAbilityMode(x)) { + for (AbilityType abilityType : AbilityType.values()) { + if (mcMMOPlayer.getAbilityMode(abilityType)) { return; } } + PlayerProfile playerProfile = mcMMOPlayer.getProfile(); + /* * Woodcutting & Axes need to be treated differently. * Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action */ - if (ability.getPermissions(player) && tool.inHand(inHand) && !profile.getToolPreparationMode(tool)) { + if (ability.getPermissions(player) && tool.inHand(inHand) && !mcMMOPlayer.getToolPreparationMode(tool)) { if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) { - if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { - player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); + if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { + player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); return; } } @@ -153,39 +152,36 @@ public class SkillUtils { player.sendMessage(tool.getRaiseTool()); } - profile.setToolPreparationATS(tool, System.currentTimeMillis()); - profile.setToolPreparationMode(tool, true); + mcMMOPlayer.setToolPreparationATS(tool, System.currentTimeMillis()); + mcMMOPlayer.setToolPreparationMode(tool, true); } } /** * Monitors various things relating to skill abilities. * - * @param player The player using the skill + * @param mcMMOPlayer The player using the skill * @param profile The profile of the player * @param curTime The current system time * @param skill The skill being monitored */ - public static void monitorSkill(Player player, PlayerProfile profile, long curTime, SkillType skill) { + public static void monitorSkill(McMMOPlayer mcMMOPlayer, long curTime, SkillType skill) { final int FOUR_SECONDS = 4000; - ToolType tool = skill.getTool(); - AbilityType ability = skill.getAbility(); - if (profile == null) { - return; - } - - if (profile.getToolPreparationMode(tool) && curTime - (profile.getToolPreparationATS(tool) * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) { - profile.setToolPreparationMode(tool, false); + if (mcMMOPlayer.getToolPreparationMode(tool) && curTime - (mcMMOPlayer.getToolPreparationATS(tool) * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) { + mcMMOPlayer.setToolPreparationMode(tool, false); if (Config.getInstance().getAbilityMessagesEnabled()) { - player.sendMessage(tool.getLowerTool()); + mcMMOPlayer.getPlayer().sendMessage(tool.getLowerTool()); } } + AbilityType ability = skill.getAbility(); + Player player = mcMMOPlayer.getPlayer(); + if (ability.getPermissions(player)) { - if (profile.getAbilityMode(ability) && (profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) { + if (mcMMOPlayer.getAbilityMode(ability) && (mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) { if (ability == AbilityType.BERSERK) { player.setCanPickupItems(true); } @@ -193,12 +189,12 @@ public class SkillUtils { handleAbilitySpeedDecrease(player); } - profile.setAbilityMode(ability, false); - profile.setAbilityInformed(ability, false); + mcMMOPlayer.setAbilityMode(ability, false); + mcMMOPlayer.setAbilityInformed(ability, false); ParticleEffectUtils.playAbilityDisabledEffect(player); - if (profile.useChatNotifications()) { + if (mcMMOPlayer.useChatNotifications()) { player.sendMessage(ability.getAbilityOff()); } @@ -368,40 +364,42 @@ public class SkillUtils { /** * Check to see if an ability can be activated. * - * @param player The player activating the ability + * @param mcMMOPlayer The player activating the ability * @param type The skill the ability is based on */ - public static void abilityCheck(Player player, SkillType type) { - PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + public static void abilityCheck(McMMOPlayer mcMMOPlayer, SkillType type) { ToolType tool = type.getTool(); AbilityType ability = type.getAbility(); - profile.setToolPreparationMode(tool, false); + mcMMOPlayer.setToolPreparationMode(tool, false); + + Player player = mcMMOPlayer.getPlayer(); + PlayerProfile playerProfile = mcMMOPlayer.getProfile(); /* * Axes and Woodcutting are odd because they share the same tool. * We show them the too tired message when they take action. */ if (type == SkillType.WOODCUTTING || type == SkillType.AXES) { - if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { - player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); + if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { + player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); return; } } - if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) { - int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks()); + if (!mcMMOPlayer.getAbilityMode(ability) && cooldownOver(playerProfile.getSkillDATS(ability), ability.getCooldown(), player)) { + int ticks = PerksUtils.handleActivationPerks(player, 2 + (playerProfile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks()); ParticleEffectUtils.playAbilityEnabledEffect(player); - if (profile.useChatNotifications()) { + if (mcMMOPlayer.useChatNotifications()) { player.sendMessage(ability.getAbilityOn()); } SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player)); - profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); - profile.setAbilityMode(ability, true); + playerProfile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); + mcMMOPlayer.setAbilityMode(ability, true); if (ability == AbilityType.BERSERK) { player.setCanPickupItems(false); @@ -514,14 +512,14 @@ public class SkillUtils { } } - PlayerProfile profile = UserManager.getPlayer(player).getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); int ticks = 0; - if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) { - ticks = ((int) (profile.getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; + if (mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) { + ticks = ((int) (mcMMOPlayer.getProfile().getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; } - else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { - ticks = ((int) (profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; + else if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { + ticks = ((int) (mcMMOPlayer.getProfile().getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR; } PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10); From cbe9cae4ea26f3d2e7226720a8d60a4aaa439c04 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 1 Mar 2013 15:49:24 -0500 Subject: [PATCH 119/137] Straighten up the Taming classes in order to stop passing events around quite so much. Also reordered some checks in our EntityDamage listeners for readability & efficiency purposes. --- .../nossr50/listeners/EntityListener.java | 205 ++++++++++-------- .../nossr50/listeners/PlayerListener.java | 2 +- .../skills/taming/BeastLoreEventHandler.java | 54 ----- .../taming/CallOfTheWildEventHandler.java | 108 --------- .../taming/FastFoodServiceEventHandler.java | 27 --- .../skills/taming/GoreEventHandler.java | 44 ---- .../taming/SharpenedClawsEventHandler.java | 15 -- .../gmail/nossr50/skills/taming/Taming.java | 78 ++++--- .../nossr50/skills/taming/TamingManager.java | 122 +++++++---- .../nossr50/util/skills/CombatUtils.java | 11 +- 10 files changed, 242 insertions(+), 424 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/taming/FastFoodServiceEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/taming/GoreEventHandler.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/taming/SharpenedClawsEventHandler.java diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 0448977b9..6538157e5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -38,6 +38,7 @@ import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.taming.Taming; +import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; @@ -59,16 +60,19 @@ public class EntityListener implements Listener { public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) { Entity entity = event.getEntity(); - if (entity instanceof FallingBlock) { - Block block = event.getBlock(); + if (!(entity instanceof FallingBlock)) { + return; + } - if (mcMMO.placeStore.isTrue(block) && !entity.hasMetadata(mcMMO.entityMetadataKey)) { - mcMMO.placeStore.setFalse(block); - entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); - } - else if (entity.hasMetadata(mcMMO.entityMetadataKey)) { - mcMMO.placeStore.setTrue(block); - } + Block block = event.getBlock(); + boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey); + + if (mcMMO.placeStore.isTrue(block) && !isTracked) { + mcMMO.placeStore.setFalse(block); + entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); + } + else if (isTracked) { + mcMMO.placeStore.setTrue(block); } } @@ -85,11 +89,12 @@ public class EntityListener implements Listener { Entity defender = event.getEntity(); - if (Misc.isNPCEntity(defender) || defender.isDead()) { + if (Misc.isNPCEntity(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) { return; } Entity attacker = event.getDamager(); + LivingEntity target = (LivingEntity) defender; if (attacker instanceof Projectile) { attacker = ((Projectile) attacker).getShooter(); @@ -102,6 +107,10 @@ public class EntityListener implements Listener { } } + if (CombatUtils.isInvincible(target, event.getDamage())) { + return; + } + if (defender instanceof Player && attacker instanceof Player) { Player defendingPlayer = (Player) defender; Player attackingPlayer = (Player) attacker; @@ -110,22 +119,14 @@ public class EntityListener implements Listener { if (defendingPlayer == attackingPlayer) { return; } - else if (PartyManager.inSameParty(defendingPlayer, attackingPlayer)) { - if (!(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { - event.setCancelled(true); - return; - } + + if (PartyManager.inSameParty(defendingPlayer, attackingPlayer) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { + event.setCancelled(true); + return; } } - /* Check for invincibility */ - if (defender instanceof LivingEntity) { - LivingEntity livingDefender = (LivingEntity) defender; - - if (!CombatUtils.isInvincible(livingDefender, event.getDamage())) { - CombatUtils.combatChecks(event, attacker, livingDefender); - } - } + CombatUtils.combatChecks(event, attacker, target); } /** @@ -210,24 +211,26 @@ public class EntityListener implements Listener { Player player = (Player) owner; Wolf wolf = (Wolf) pet; + TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager(); + switch (cause) { case CONTACT: case FIRE: case LAVA: - if (Taming.canUseEnvironmentallyAware(player)) { - Taming.processEnvironmentallyAware(player, wolf, event.getDamage()); + if (tamingManager.canUseEnvironmentallyAware()) { + tamingManager.processEnvironmentallyAware(wolf, event.getDamage()); } return; case FALL: - if (Taming.canUseEnvironmentallyAware(player)) { + if (tamingManager.canUseEnvironmentallyAware()) { event.setCancelled(true); } return; case ENTITY_ATTACK: case PROJECTILE: - if (Taming.canUseThickFur(player)) { + if (tamingManager.canUseThickFur()) { event.setDamage(Taming.processThickFur(wolf, event.getDamage())); if (event.getDamage() == 0) { @@ -237,7 +240,7 @@ public class EntityListener implements Listener { return; case FIRE_TICK: - if (Taming.canUseThickFur(player)) { + if (tamingManager.canUseThickFur()) { Taming.processThickFurFire(wolf); } return; @@ -245,7 +248,7 @@ public class EntityListener implements Listener { case MAGIC: case POISON: case WITHER: - if (Taming.canUseHolyHound(player)) { + if (tamingManager.canUseHolyHound()) { Taming.processHolyHound(wolf, event.getDamage()); } return; @@ -253,7 +256,7 @@ public class EntityListener implements Listener { case BLOCK_EXPLOSION: case ENTITY_EXPLOSION: case LIGHTNING: - if (Taming.canUseShockProof(player)) { + if (tamingManager.canUseShockProof()) { event.setDamage(Taming.processShockProof(wolf, event.getDamage())); if (event.getDamage() == 0) { @@ -294,7 +297,7 @@ public class EntityListener implements Listener { */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { - if (Misc.isSpawnerXPEnabled || event.getEntity() == null) { + if (Misc.isSpawnerXPEnabled) { return; } @@ -317,13 +320,14 @@ public class EntityListener implements Listener { if (entity instanceof TNTPrimed) { int id = entity.getEntityId(); - if (plugin.tntIsTracked(id)) { - - MiningManager miningManager = UserManager.getPlayer(plugin.getTNTPlayer(id)).getMiningManager(); + if (!plugin.tntIsTracked(id)) { + return; + } - if (miningManager.canUseBiggerBombs()) { - event.setRadius(miningManager.biggerBombs(event.getRadius())); - } + MiningManager miningManager = UserManager.getPlayer(plugin.getTNTPlayer(id)).getMiningManager(); + + if (miningManager.canUseBiggerBombs()) { + event.setRadius(miningManager.biggerBombs(event.getRadius())); } } } @@ -340,16 +344,18 @@ public class EntityListener implements Listener { if (entity instanceof TNTPrimed) { int id = entity.getEntityId(); - if (plugin.tntIsTracked(id)) { - MiningManager miningManager = UserManager.getPlayer(plugin.getTNTPlayer(id)).getMiningManager(); - - if (miningManager.canUseBlastMining()) { - miningManager.blastMiningDropProcessing(event.getYield(), event.blockList()); - event.setYield(0); - } - - plugin.removeFromTNTTracker(id); + if (!plugin.tntIsTracked(id)) { + return; } + + MiningManager miningManager = UserManager.getPlayer(plugin.getTNTPlayer(id)).getMiningManager(); + + if (miningManager.canUseBlastMining()) { + miningManager.blastMiningDropProcessing(event.getYield(), event.blockList()); + event.setYield(0); + } + + plugin.removeFromTNTTracker(id); } } @@ -373,49 +379,51 @@ public class EntityListener implements Listener { int newFoodLevel = event.getFoodLevel(); int foodChange = newFoodLevel - currentFoodLevel; + if (foodChange <= 0) { + return; + } + /* * Some foods have 3 ranks * Some foods have 5 ranks * The number of ranks is based on how 'common' the item is * We can adjust this quite easily if we find something is giving too much of a bonus */ - if (foodChange > 0) { - switch (player.getItemInHand().getType()) { - case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ - case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ - case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */ - case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ - case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ - case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ - if (Permissions.farmersDiet(player)) { - event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel)); - } - return; + switch (player.getItemInHand().getType()) { + case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ + case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ + case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */ + case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ + case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ + case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ + if (Permissions.farmersDiet(player)) { + event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel)); + } + return; - case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ - case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ - case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ - case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ - if (Permissions.farmersDiet(player)) { - event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel)); - } - return; + case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ + case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ + case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ + case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ + if (Permissions.farmersDiet(player)) { + event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel)); + } + return; - case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ - if (Permissions.fishermansDiet(player)) { - event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel)); - } - return; + case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ + if (Permissions.fishermansDiet(player)) { + event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel)); + } + return; - case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ - if (Permissions.fishermansDiet(player)) { - event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel)); - } - return; + case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ + if (Permissions.fishermansDiet(player)) { + event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel)); + } + return; - default: - return; - } + default: + return; } } } @@ -428,33 +436,38 @@ public class EntityListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityTame(EntityTameEvent event) { Player player = (Player) event.getOwner(); + LivingEntity entity = event.getEntity(); - if (Misc.isNPCEntity(player)) { + if (Misc.isNPCEntity(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) { return; } - LivingEntity entity = event.getEntity(); - - if (entity != null && !entity.hasMetadata(mcMMO.entityMetadataKey)) { - UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity); - } + UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity); } + /** + * Handle EntityTarget events. + * + * @param event The event to process + */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityTarget(EntityTargetEvent event) { - if (event.getEntity() instanceof Tameable && event.getTarget() instanceof Player) { - Player player = (Player) event.getTarget(); - Tameable tameable = (Tameable) event.getEntity(); + Entity entity = event.getEntity(); + Entity target = event.getTarget(); - if (CombatUtils.isFriendlyPet(player, tameable)) { - // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party - // So we can make some assumptions here, about our casting and our check - Player owner = (Player) tameable.getOwner(); + if (entity instanceof Tameable && target instanceof Player) { + Player player = (Player) target; + Tameable tameable = (Tameable) entity; - if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire(owner))) { - event.setCancelled(true); - return; - } + if (!CombatUtils.isFriendlyPet(player, tameable)) { + return; + } + + // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party + // So we can make some assumptions here, about our casting and our check + if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) { + event.setCancelled(true); + return; } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 8af4d21f5..76760c682 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -401,7 +401,7 @@ public class PlayerListener implements Listener { case LEFT_CLICK_BLOCK: /* CALL OF THE WILD CHECKS */ - if (player.isSneaking()) { + if (player.isSneaking() && Permissions.callOfTheWild(player)) { Material type = heldItem.getType(); TamingManager tamingManager = mcMMOPlayer.getTamingManager(); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java deleted file mode 100644 index 35765fa3e..000000000 --- a/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.AnimalTamer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Tameable; - -import com.gmail.nossr50.locale.LocaleLoader; - -public class BeastLoreEventHandler { - private Player player; - private LivingEntity livingEntity; - private Tameable beast; - - protected BeastLoreEventHandler(Player player, LivingEntity livingEntity) { - this.player = player; - this.livingEntity = livingEntity; - this.beast = (Tameable) livingEntity; - } - - protected void sendInspectMessage() { - if (player == null) { - return; - } - - String message = LocaleLoader.getString("Combat.BeastLore") + " "; - - if (beast.isTamed()) { - message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", getOwnerName()) + " "); - } - - message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", livingEntity.getHealth(), livingEntity.getMaxHealth())); - player.sendMessage(message); - } - - /** - * Get the name of a tameable animal's owner. - * - * @return the name of the animal's owner - */ - private String getOwnerName() { - AnimalTamer tamer = beast.getOwner(); - - if (tamer instanceof Player) { - return ((Player) tamer).getName(); - } - else if (tamer instanceof OfflinePlayer) { - return ((OfflinePlayer) tamer).getName(); - } - - return "Unknown Master"; - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java deleted file mode 100644 index 0aff2d7c8..000000000 --- a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Ocelot; -import org.bukkit.entity.Player; -import org.bukkit.entity.Tameable; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.StringUtils; - -public class CallOfTheWildEventHandler { - protected Player player; - protected ItemStack inHand; - protected EntityType type; - protected int summonAmount; - - protected CallOfTheWildEventHandler(Player player, EntityType type, int summonAmount) { - this.player = player; - this.inHand = player.getItemInHand(); - this.type = type; - this.summonAmount = summonAmount; - } - - protected void sendInsufficientAmountMessage() { - if (player == null) { - return; - } - - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(inHand.getTypeId()))); - } - - protected boolean nearbyEntityExists() { - if (player == null) { - return false; - } - - boolean entityExists = false; - - for (Entity entity : player.getNearbyEntities(40, 40, 40)) { - if (entity.getType() == type) { - entityExists = true; - break; - } - } - - return entityExists; - } - - protected void sendFailureMessage() { - if (player == null) { - return; - } - - if (type == EntityType.OCELOT) { - player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot")); - } - else { - player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Wolf")); - } - } - - protected void spawnCreature() { - if (player == null) { - return; - } - - LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type); - entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); - - ((Tameable) entity).setOwner(player); - - if (type == EntityType.OCELOT) { - ((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3))); - } - else { - entity.setHealth(entity.getMaxHealth()); - } - } - - protected void processResourceCost() { - if (player == null) { - return; - } - - int newAmount = inHand.getAmount() - summonAmount; - - if (newAmount == 0) { - player.setItemInHand(new ItemStack(Material.AIR)); - } - else { - player.getItemInHand().setAmount(inHand.getAmount() - summonAmount); - } - } - - protected void sendSuccessMessage() { - if (player == null) { - return; - } - - player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete")); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/FastFoodServiceEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/FastFoodServiceEventHandler.java deleted file mode 100644 index ecbd99dad..000000000 --- a/src/main/java/com/gmail/nossr50/skills/taming/FastFoodServiceEventHandler.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.entity.Wolf; - -public class FastFoodServiceEventHandler { - private Wolf wolf; - - public FastFoodServiceEventHandler(Wolf wolf) { - this.wolf = wolf; - } - - protected void modifyHealth(int damage) { - int health = wolf.getHealth(); - int maxHealth = wolf.getMaxHealth(); - - if (health < maxHealth) { - int newHealth = health + damage; - - if (newHealth <= maxHealth) { - wolf.setHealth(newHealth); - } - else { - wolf.setHealth(maxHealth); - } - } - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/GoreEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/GoreEventHandler.java deleted file mode 100644 index 583425d75..000000000 --- a/src/main/java/com/gmail/nossr50/skills/taming/GoreEventHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; - -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.runnables.skills.BleedTimerTask; -import com.gmail.nossr50.util.skills.SkillUtils; - -public class GoreEventHandler { - private TamingManager manager; - private EntityDamageEvent event; - private Entity entity; - protected int skillModifier; - - protected GoreEventHandler(TamingManager manager, EntityDamageEvent event) { - this.manager = manager; - this.event = event; - this.entity = event.getEntity(); - calculateSkillModifier(); - } - - protected void calculateSkillModifier() { - this.skillModifier = SkillUtils.skillCheck(manager.getSkillLevel(), Taming.goreMaxBonusLevel); - } - - protected void modifyEventDamage() { - event.setDamage(event.getDamage() * Taming.goreModifier); - } - - protected void sendAbilityMessage() { - if (entity instanceof Player) { - ((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore")); - } - - manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore")); - } - - protected void applyBleed() { - BleedTimerTask.add((LivingEntity) entity, Taming.goreBleedTicks); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/SharpenedClawsEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/SharpenedClawsEventHandler.java deleted file mode 100644 index a7d20fe62..000000000 --- a/src/main/java/com/gmail/nossr50/skills/taming/SharpenedClawsEventHandler.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gmail.nossr50.skills.taming; - -import org.bukkit.event.entity.EntityDamageEvent; - -public class SharpenedClawsEventHandler { - private EntityDamageEvent event; - - public SharpenedClawsEventHandler(EntityDamageEvent event) { - this.event = event; - } - - protected void modifyEventDamage() { - event.setDamage(event.getDamage() + Taming.sharpenedClawsBonusDamage); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java index 06ea2bb25..2f15da2dd 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java @@ -1,29 +1,28 @@ package com.gmail.nossr50.skills.taming; import org.bukkit.EntityEffect; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.AnimalTamer; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; import org.bukkit.entity.Wolf; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.skills.SkillUtils; public class Taming { public static int environmentallyAwareUnlockLevel = AdvancedConfig.getInstance().getEnviromentallyAwareUnlock(); public static int holyHoundUnlockLevel = AdvancedConfig.getInstance().getHolyHoundUnlock(); - public static int fastFoodServiceUnlockLevel = AdvancedConfig.getInstance().getFastFoodUnlock(); + public static int fastFoodServiceUnlockLevel = AdvancedConfig.getInstance().getFastFoodUnlock(); public static double fastFoodServiceActivationChance = AdvancedConfig.getInstance().getFastFoodChance(); - public static int goreBleedTicks = AdvancedConfig.getInstance().getGoreBleedTicks(); + public static int goreBleedTicks = AdvancedConfig.getInstance().getGoreBleedTicks(); public static int goreMaxBonusLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel(); - public static int goreModifier = AdvancedConfig.getInstance().getGoreModifier(); - public static double goreMaxChance = AdvancedConfig.getInstance().getGoreChanceMax(); + public static int goreModifier = AdvancedConfig.getInstance().getGoreModifier(); + public static double goreMaxChance = AdvancedConfig.getInstance().getGoreChanceMax(); public static int sharpenedClawsUnlockLevel = AdvancedConfig.getInstance().getSharpenedClawsUnlock(); public static int sharpenedClawsBonusDamage = AdvancedConfig.getInstance().getSharpenedClawsBonus(); @@ -41,22 +40,6 @@ public class Taming { return pet.isTamed() && owner instanceof Player && pet instanceof Wolf; } - public static boolean canUseThickFur(Player player) { - return SkillUtils.unlockLevelReached(player, SkillType.TAMING, thickFurUnlockLevel) && Permissions.thickFur(player); - } - - public static boolean canUseEnvironmentallyAware(Player player) { - return SkillUtils.unlockLevelReached(player, SkillType.TAMING, environmentallyAwareUnlockLevel) && Permissions.environmentallyAware(player); - } - - public static boolean canUseShockProof(Player player) { - return SkillUtils.unlockLevelReached(player, SkillType.TAMING, shockProofUnlockLevel) && Permissions.shockProof(player); - } - - public static boolean canUseHolyHound(Player player) { - return SkillUtils.unlockLevelReached(player, SkillType.TAMING, holyHoundUnlockLevel) && Permissions.holyHound(player); - } - public static int processThickFur(Wolf wolf, int damage) { wolf.playEffect(EntityEffect.WOLF_SHAKE); return damage / thickFurModifier; @@ -67,24 +50,55 @@ public class Taming { wolf.setFireTicks(0); } - public static void processEnvironmentallyAware(Player player, Wolf wolf, int damage) { - if (damage > wolf.getHealth()) { - return; - } - - wolf.teleport(player); - player.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf")); - } - public static int processShockProof(Wolf wolf, int damage) { wolf.playEffect(EntityEffect.WOLF_SHAKE); return damage / shockProofModifier; } + /** + * Apply the Sharpened Claws ability. + * + * @param event The event to modify + */ + public static int sharpenedClaws(int damage) { + return damage + Taming.sharpenedClawsBonusDamage; + } + public static void processHolyHound(Wolf wolf, int damage) { int modifiedHealth = Math.min(wolf.getHealth() + damage, wolf.getMaxHealth()); wolf.setHealth(modifiedHealth); wolf.playEffect(EntityEffect.WOLF_HEARTS); } + + /** + * Get the name of a tameable animal's owner. + * + * @return the name of the animal's owner + */ + protected static String getOwnerName(Tameable beast) { + AnimalTamer tamer = beast.getOwner(); + + if (tamer instanceof Player) { + return ((Player) tamer).getName(); + } + else if (tamer instanceof OfflinePlayer) { + return ((OfflinePlayer) tamer).getName(); + } + + return "Unknown Master"; + } + + protected static String getCallOfTheWildFailureMessage(EntityType type) { + switch (type) { + case OCELOT: + return LocaleLoader.getString("Taming.Summon.Fail.Ocelot"); + + case WOLF: + return LocaleLoader.getString("Taming.Summon.Fail.Wolf"); + + default: + return ""; + } + } } 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 b09f392b8..1ae842f7e 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -1,17 +1,24 @@ package com.gmail.nossr50.skills.taming; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Ocelot; +import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; import org.bukkit.entity.Wolf; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.skills.SkillUtils; public class TamingManager extends SkillManager { @@ -19,6 +26,22 @@ public class TamingManager extends SkillManager { super(mcMMOPlayer, SkillType.TAMING); } + public boolean canUseThickFur() { + return getSkillLevel() > Taming.thickFurUnlockLevel && Permissions.thickFur(getPlayer()); + } + + public boolean canUseEnvironmentallyAware() { + return getSkillLevel() > Taming.environmentallyAwareUnlockLevel && Permissions.environmentallyAware(getPlayer()); + } + + public boolean canUseShockProof() { + return getSkillLevel() > Taming.shockProofUnlockLevel && Permissions.shockProof(getPlayer()); + } + + public boolean canUseHolyHound() { + return getSkillLevel() > Taming.holyHoundUnlockLevel && Permissions.holyHound(getPlayer()); + } + /** * Award XP for taming. * @@ -58,34 +81,26 @@ public class TamingManager extends SkillManager { } } - /** - * Apply the Sharpened Claws ability. - * - * @param event The event to modify - */ - public void sharpenedClaws(EntityDamageEvent event) { - SharpenedClawsEventHandler eventHandler = new SharpenedClawsEventHandler(event); - eventHandler.modifyEventDamage(); - } - /** * Apply the Gore ability. * * @param event The event to modify */ - public void gore(EntityDamageEvent event) { - GoreEventHandler eventHandler = new GoreEventHandler(this, event); + public int gore(LivingEntity target, int damage) { + Player owner = getPlayer(); - float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * getSkillLevel()); - if (chance > Taming.goreMaxChance) { - chance = (float) Taming.goreMaxChance; + if (SkillUtils.activationSuccessful(owner, skill, Taming.goreMaxChance, Taming.goreMaxBonusLevel)) { + BleedTimerTask.add(target, Taming.goreBleedTicks); + + if (target instanceof Player) { + ((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore")); + } + + owner.sendMessage(LocaleLoader.getString("Combat.Gore")); + return damage * Taming.goreModifier; } - if (chance > Misc.getRandom().nextInt(activationChance)) { - eventHandler.modifyEventDamage(); - eventHandler.applyBleed(); - eventHandler.sendAbilityMessage(); - } + return damage; } /** @@ -105,11 +120,31 @@ public class TamingManager extends SkillManager { /** * Handle the Beast Lore ability. * - * @param livingEntity The entity to examine + * @param target The entity to examine */ - public void beastLore(LivingEntity livingEntity) { - BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(getPlayer(), livingEntity); - eventHandler.sendInspectMessage(); + public void beastLore(LivingEntity target) { + Player player = getPlayer(); + Tameable beast = (Tameable) target; + + String message = LocaleLoader.getString("Combat.BeastLore") + " "; + + if (beast.isTamed()) { + message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", Taming.getOwnerName(beast)) + " "); + } + + message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth())); + player.sendMessage(message); + } + + public void processEnvironmentallyAware(Wolf wolf, int damage) { + if (damage > wolf.getHealth()) { + return; + } + + Player owner = getPlayer(); + + wolf.teleport(owner); + owner.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf")); } /** @@ -119,27 +154,36 @@ public class TamingManager extends SkillManager { * @param summonAmount The amount of material needed to summon the entity */ private void callOfTheWild(EntityType type, int summonAmount) { - if (!Permissions.callOfTheWild(getPlayer())) { + Player player = getPlayer(); + + ItemStack heldItem = player.getItemInHand(); + int heldItemAmount = heldItem.getAmount(); + + if (heldItemAmount < summonAmount) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getTypeId()))); return; } - CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(getPlayer(), type, summonAmount); - - ItemStack inHand = eventHandler.inHand; - int inHandAmount = inHand.getAmount(); - - if (inHandAmount < summonAmount) { - eventHandler.sendInsufficientAmountMessage(); - return; + for (Entity entity : player.getNearbyEntities(40, 40, 40)) { + if (entity.getType() == type) { + player.sendMessage(Taming.getCallOfTheWildFailureMessage(type)); + return; + } } - if (eventHandler.nearbyEntityExists()) { - eventHandler.sendFailureMessage(); + LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type); + + entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); + ((Tameable) entity).setOwner(player); + + if (type == EntityType.OCELOT) { + ((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3))); } else { - eventHandler.spawnCreature(); - eventHandler.processResourceCost(); - eventHandler.sendSuccessMessage(); + entity.setHealth(entity.getMaxHealth()); } + + player.setItemInHand(new ItemStack(heldItem.getType(), heldItemAmount - summonAmount)); + player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete")); } } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 293fc7f65..badd6d018 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -79,12 +79,7 @@ public final class CombatUtils { } if (ItemUtils.isSword(heldItem)) { - if (targetIsPlayer || targetIsTamedPet) { - if (!SkillType.SWORDS.getPVPEnabled()) { - return; - } - } - else if (!SkillType.SWORDS.getPVEEnabled()) { + if (((targetIsPlayer || targetIsTamedPet) && !SkillType.SWORDS.getPVPEnabled()) || (!targetIsPlayer && !targetIsTamedPet && !SkillType.SWORDS.getPVEEnabled())) { return; } @@ -212,11 +207,11 @@ public final class CombatUtils { } if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) { - tamingManager.sharpenedClaws(event); + event.setDamage(Taming.sharpenedClaws(event.getDamage())); } if (Permissions.gore(master)) { - tamingManager.gore(event); + event.setDamage(tamingManager.gore(target, event.getDamage())); } startGainXp(mcMMOPlayer, target, SkillType.TAMING); From 7c28be5e62774fcae8c64eb41b22cccdb98f6659 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 3 Mar 2013 01:31:14 -0500 Subject: [PATCH 120/137] Straightening up our InventoryListener, SwordsManager, TamingManager, and UnarmedManager. --- .../nossr50/listeners/InventoryListener.java | 22 ++++----- .../nossr50/skills/swords/SwordsManager.java | 15 ++++++ .../nossr50/skills/taming/TamingManager.java | 4 ++ .../skills/unarmed/UnarmedManager.java | 19 ++++++++ .../nossr50/util/skills/CombatUtils.java | 48 ++++++++----------- 5 files changed, 68 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index ebf852a39..88f293b9a 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -18,8 +18,8 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -93,13 +93,11 @@ public class InventoryListener implements Listener { if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) { Player player = plugin.getFurnacePlayer(furnaceBlock); - if (Misc.isNPCEntity(player)) { + if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) { return; } - if (Permissions.fuelEfficiency(player)) { - event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime())); - } + event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime())); } } } @@ -114,13 +112,11 @@ public class InventoryListener implements Listener { if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) { Player player = plugin.getFurnacePlayer(furnaceBlock); - if (Misc.isNPCEntity(player)) { + if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) { return; } - if (Permissions.skillEnabled(player, SkillType.SMELTING)) { - event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(event.getSource().getType(), event.getResult())); - } + event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(event.getSource().getType(), event.getResult())); } } } @@ -133,10 +129,12 @@ public class InventoryListener implements Listener { ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult(); if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemUtils.isSmelted(result)) { - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(event.getPlayer()); + Player player = event.getPlayer(); - if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) { - event.setExpToDrop(mcMMOPlayer.getSmeltingManager().vanillaXPBoost(event.getExpToDrop())); + SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager(); + + if (smeltingManager.canUseVanillaXpBoost()) { + event.setExpToDrop(smeltingManager.vanillaXPBoost(event.getExpToDrop())); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 6f181ad2b..f60fb0c3b 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -4,10 +4,13 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -17,6 +20,18 @@ public class SwordsManager extends SkillManager { super(mcMMOPlayer, SkillType.SWORDS); } + public boolean canActivateAbility() { + return mcMMOPlayer.getToolPreparationMode(ToolType.SWORD) && Permissions.serratedStrikes(getPlayer()); + } + + public boolean canUseBleed() { + return Permissions.bleed(getPlayer()); + } + + public boolean canUseSerratedStrike() { + return mcMMOPlayer.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.serratedStrikes(getPlayer()); + } + /** * Check for Bleed effect. * 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 1ae842f7e..48e922e92 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -42,6 +42,10 @@ public class TamingManager extends SkillManager { return getSkillLevel() > Taming.holyHoundUnlockLevel && Permissions.holyHound(getPlayer()); } + public boolean canUseBeastLore(LivingEntity target) { + return target instanceof Tameable && Permissions.beastLore(getPlayer()); + } + /** * Award XP for taming. * diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index 0212a533c..f86fec269 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -1,12 +1,15 @@ package com.gmail.nossr50.skills.unarmed; import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; @@ -19,6 +22,22 @@ public class UnarmedManager extends SkillManager { super(mcMMOPlayer, SkillType.UNARMED); } + public boolean canActivateAbility() { + return mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && Permissions.berserk(getPlayer()); + } + + public boolean canUseIronArm() { + return Permissions.bonusDamage(getPlayer(), skill); + } + + public boolean canUseBerserk() { + return mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && Permissions.berserk(getPlayer()); + } + + public boolean canDisarm(LivingEntity target) { + return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.disarm(getPlayer()); + } + /** * Check for disarm. * diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index badd6d018..bfef02099 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -21,9 +21,7 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; -import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.locale.LocaleLoader; @@ -84,23 +82,21 @@ public final class CombatUtils { } if (Permissions.skillEnabled(player, SkillType.SWORDS)) { - boolean canSerratedStrike = Permissions.serratedStrikes(player); // So we don't have to check the same permission twice + SwordsManager swordsManager = mcMMOPlayer.getSwordsManager(); - if (mcMMOPlayer.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) { + if (swordsManager.canActivateAbility()) { SkillUtils.abilityCheck(mcMMOPlayer, SkillType.SWORDS); } - SwordsManager swordsManager = mcMMOPlayer.getSwordsManager(); - - if (Permissions.bleed(player)) { + if (swordsManager.canUseBleed()) { swordsManager.bleedCheck(target); } - if (mcMMOPlayer.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) { + if (swordsManager.canUseSerratedStrike()) { swordsManager.serratedStrikes(target, event.getDamage()); } - startGainXp(mcMMOPlayer, target, SkillType.SWORDS); + startGainXp(swordsManager.getMcMMOPlayer(), target, SkillType.SWORDS); } } else if (ItemUtils.isAxe(heldItem)) { @@ -138,41 +134,37 @@ public final class CombatUtils { } } else if (heldItem.getType() == Material.AIR) { - if (targetIsPlayer || targetIsTamedPet) { - if (!SkillType.UNARMED.getPVPEnabled()) { - return; - } - } - else if (!SkillType.UNARMED.getPVEEnabled()) { + if (((targetIsPlayer || targetIsTamedPet) && !SkillType.UNARMED.getPVPEnabled()) || (!targetIsPlayer && !targetIsTamedPet && !SkillType.UNARMED.getPVEEnabled())) { return; } if (Permissions.skillEnabled(player, SkillType.UNARMED)) { - boolean canBerserk = Permissions.berserk(player); // So we don't have to check the same permission twice + UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager(); - if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && canBerserk) { + if (unarmedManager.canActivateAbility()) { SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED); } - UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager(); - - if (Permissions.bonusDamage(player, SkillType.UNARMED)) { + if (unarmedManager.canUseIronArm()) { event.setDamage(unarmedManager.ironArmCheck(event.getDamage())); } - if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && canBerserk) { + if (unarmedManager.canUseBerserk()) { event.setDamage(unarmedManager.berserkDamage(event.getDamage())); } - if (target instanceof Player && Permissions.disarm(player)) { - Player defender = (Player) target; - - if (defender.getItemInHand().getType() != Material.AIR) { - unarmedManager.disarmCheck((Player) target); - } + if (unarmedManager.canDisarm(target)) { + unarmedManager.disarmCheck((Player) target); } - startGainXp(mcMMOPlayer, target, SkillType.UNARMED); + startGainXp(unarmedManager.getMcMMOPlayer(), target, SkillType.UNARMED); + } + } + else if (heldItem.getType() == Material.BONE) { + TamingManager tamingManager = mcMMOPlayer.getTamingManager(); + + if (tamingManager.canUseBeastLore(target)) { + tamingManager.beastLore(target); } } } From 1fc3c8fab23d100599703b7551d4d8a11604b3a5 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 3 Mar 2013 15:22:40 -0500 Subject: [PATCH 121/137] AnimalTamer already has a getName() method. --- .../gmail/nossr50/skills/taming/Taming.java | 19 ------------------- .../nossr50/skills/taming/TamingManager.java | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java index 2f15da2dd..a6e312680 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/Taming.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.taming; import org.bukkit.EntityEffect; -import org.bukkit.OfflinePlayer; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -71,24 +70,6 @@ public class Taming { wolf.playEffect(EntityEffect.WOLF_HEARTS); } - /** - * Get the name of a tameable animal's owner. - * - * @return the name of the animal's owner - */ - protected static String getOwnerName(Tameable beast) { - AnimalTamer tamer = beast.getOwner(); - - if (tamer instanceof Player) { - return ((Player) tamer).getName(); - } - else if (tamer instanceof OfflinePlayer) { - return ((OfflinePlayer) tamer).getName(); - } - - return "Unknown Master"; - } - protected static String getCallOfTheWildFailureMessage(EntityType type) { switch (type) { case OCELOT: 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 48e922e92..e45343127 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -133,7 +133,7 @@ public class TamingManager extends SkillManager { String message = LocaleLoader.getString("Combat.BeastLore") + " "; if (beast.isTamed()) { - message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", Taming.getOwnerName(beast)) + " "); + message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", beast.getOwner().getName()) + " "); } message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth())); From 1b461ac96a28807ee885d27ee0f0c3393b641c90 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 3 Mar 2013 15:42:56 -0500 Subject: [PATCH 122/137] Cleaning up more combat checks. --- .../nossr50/listeners/EntityListener.java | 8 ++-- .../nossr50/util/skills/CombatUtils.java | 37 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 6538157e5..211348a32 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -96,6 +96,10 @@ public class EntityListener implements Listener { Entity attacker = event.getDamager(); LivingEntity target = (LivingEntity) defender; + if (CombatUtils.isInvincible(target, event.getDamage())) { + return; + } + if (attacker instanceof Projectile) { attacker = ((Projectile) attacker).getShooter(); } @@ -107,10 +111,6 @@ public class EntityListener implements Listener { } } - if (CombatUtils.isInvincible(target, event.getDamage())) { - return; - } - if (defender instanceof Player && attacker instanceof Player) { Player defendingPlayer = (Player) defender; Player attackingPlayer = (Player) attacker; diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index bfef02099..f1cedbfaf 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -51,8 +51,6 @@ public final class CombatUtils { * @param event The event to run the combat checks on. */ public static void combatChecks(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) { - boolean targetIsPlayer = (target.getType() == EntityType.PLAYER); - boolean targetIsTamedPet = (target instanceof Tameable) ? ((Tameable) target).isTamed() : false; Entity damager = event.getDamager(); if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) { @@ -77,7 +75,7 @@ public final class CombatUtils { } if (ItemUtils.isSword(heldItem)) { - if (((targetIsPlayer || targetIsTamedPet) && !SkillType.SWORDS.getPVPEnabled()) || (!targetIsPlayer && !targetIsTamedPet && !SkillType.SWORDS.getPVEEnabled())) { + if (!shouldProcessSkill(target, SkillType.SWORDS)) { return; } @@ -100,7 +98,7 @@ public final class CombatUtils { } } else if (ItemUtils.isAxe(heldItem)) { - if (((targetIsPlayer || targetIsTamedPet) && !SkillType.AXES.getPVPEnabled()) || (!targetIsPlayer && !targetIsTamedPet && !SkillType.AXES.getPVEEnabled())) { + if (!shouldProcessSkill(target, SkillType.AXES)) { return; } @@ -134,7 +132,7 @@ public final class CombatUtils { } } else if (heldItem.getType() == Material.AIR) { - if (((targetIsPlayer || targetIsTamedPet) && !SkillType.UNARMED.getPVPEnabled()) || (!targetIsPlayer && !targetIsTamedPet && !SkillType.UNARMED.getPVEEnabled())) { + if (!shouldProcessSkill(target, SkillType.UNARMED)) { return; } @@ -180,12 +178,7 @@ public final class CombatUtils { return; } - if (targetIsPlayer || targetIsTamedPet) { - if (!SkillType.TAMING.getPVPEnabled()) { - return; - } - } - else if (!SkillType.TAMING.getPVEEnabled()) { + if (!shouldProcessSkill(target, SkillType.TAMING)) { return; } @@ -220,12 +213,7 @@ public final class CombatUtils { break; } - if (targetIsPlayer || targetIsTamedPet) { - if (!SkillType.ARCHERY.getPVPEnabled()) { - return; - } - } - else if (!SkillType.ARCHERY.getPVEEnabled()) { + if (!shouldProcessSkill(target, SkillType.ARCHERY)) { return; } @@ -236,7 +224,7 @@ public final class CombatUtils { break; } - if (targetIsPlayer) { + if (target instanceof Player) { Player player = (Player) target; if (Misc.isNPCEntity(player)) { @@ -593,4 +581,17 @@ public final class CombatUtils { return false; } + + private static boolean shouldProcessSkill(LivingEntity target, SkillType skill) { + boolean process; + + if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) { + process = skill.getPVPEnabled(); + } + else { + process = skill.getPVEEnabled(); + } + + return process; + } } From e3e4cf988445bb1732e9fa999750a59d4952da7f Mon Sep 17 00:00:00 2001 From: NuclearW Date: Sun, 3 Mar 2013 19:32:00 -0500 Subject: [PATCH 123/137] Do not attempt to load an empty treasure config --- .../gmail/nossr50/config/treasure/TreasureConfig.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java index d43a1d5c2..32f1a3ca1 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -52,6 +52,11 @@ public class TreasureConfig extends ConfigLoader { protected void loadKeys() { Map treasures = new HashMap(); ConfigurationSection treasureSection = config.getConfigurationSection("Treasures"); + + if (treasureSection == null) { + return; + } + Set treasureConfigSet = treasureSection.getKeys(false); for (String treasureName : treasureConfigSet) { @@ -211,14 +216,14 @@ public class TreasureConfig extends ConfigLoader { Treasure treasure = nextEntry.getValue(); if (treasure instanceof FishingTreasure) { - if (!fishingTreasures.contains(treasureKey)) { + if (fishingTreasures == null || !fishingTreasures.contains(treasureKey)) { continue; } fishingRewards.add((FishingTreasure) treasure); } else if (treasure instanceof HylianTreasure) { - if (!hylianTreasures.contains(treasureKey)) { + if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) { continue; } @@ -237,7 +242,7 @@ public class TreasureConfig extends ConfigLoader { } } else if (treasure instanceof ExcavationTreasure) { - if (!excavationTreasures.contains(treasureKey)) { + if (excavationTreasures == null || !excavationTreasures.contains(treasureKey)) { continue; } From d2cb55befa0d8bdf7aecd518347ba8ee728525b8 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 3 Mar 2013 23:02:37 -0500 Subject: [PATCH 124/137] Fixed bug with /ptp display strings when trying to teleport after having been hurt or recently teleporting. --- src/main/resources/locale/locale_en_US.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 5aa71ee97..3f4b864ab 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -543,7 +543,7 @@ Party.Player.InSameParty=[[RED]]{0} already is in your party! Party.PlayerNotInParty=[[DARK_RED]]{0} is not in a party Party.Specify=[[RED]]You must specify a party. Party.Teleport.Dead=[[RED]]You can't teleport to a dead player. -Party.Teleport.Hurt=[[RED]]You've been hurt in the last {0} seconds and cannnot teleport. +Party.Teleport.Hurt=[[RED]]You have been hurt in the last {0} seconds and cannot teleport. Party.Teleport.Player=[[GREEN]]You have teleported to {0}. Party.Teleport.Self=[[RED]]You can't teleport to yourself! Party.Teleport.Target=[[GREEN]]{0} has teleported to you. From 2f491b24e2e6b2e506cdacbc8c3d27d603f140ab Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 3 Mar 2013 23:18:46 -0500 Subject: [PATCH 125/137] Updated locale files. --- Changelog.txt | 1 + .../resources/locale/locale_cs_CZ.properties | 47 +++++++--- .../resources/locale/locale_cy.properties | 12 --- .../resources/locale/locale_da.properties | 12 --- .../resources/locale/locale_de.properties | 12 --- .../resources/locale/locale_es.properties | 12 --- .../resources/locale/locale_fi.properties | 2 - .../resources/locale/locale_fr.properties | 12 --- .../resources/locale/locale_hu_HU.properties | 22 ++++- .../resources/locale/locale_it.properties | 27 +++--- .../resources/locale/locale_ko.properties | 6 ++ .../resources/locale/locale_nl.properties | 88 ++++++++++++++++++- .../resources/locale/locale_pl.properties | 3 - .../resources/locale/locale_pt_BR.properties | 2 - .../resources/locale/locale_ru.properties | 65 +++++++++----- .../resources/locale/locale_zh_CN.properties | 15 +--- .../resources/locale/locale_zh_TW.properties | 58 +++++++++--- 17 files changed, 252 insertions(+), 144 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 7d9a3a205..a1ebcb941 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -18,6 +18,7 @@ Version 1.4.01-dev = Fixed bug where ptp permissions weren't being handled properly = Fixed bug where Beast Lore wouldn't work = Fixed bug where Chimaera Wing would always teleport to spawn, even when the player had a valid bed spawn location + = Updated locale files Version 1.4.00 + Added new Child Skill - Smelting! diff --git a/src/main/resources/locale/locale_cs_CZ.properties b/src/main/resources/locale/locale_cs_CZ.properties index 8425df775..e94de5483 100644 --- a/src/main/resources/locale/locale_cs_CZ.properties +++ b/src/main/resources/locale/locale_cs_CZ.properties @@ -32,7 +32,6 @@ Axes.Ability.Bonus.4=Vyssi ucinek Axes.Ability.Bonus.5=Zpusobi bonusove zraneni o velkosi {0} vsem neozbrojenym nepratelum Axes.Ability.Lower=[[GRAY]]**ODLOZIL JSI SVOU SEKERU** Axes.Ability.Ready=[[GREEN]]**P\u0158IPRAVUJE\u0160 SI SVOJ\u00cd SEKERU!** -Axes.Combat.Cleave.Proc=[[DARK_RED]]Zas\u00e1hnut ROZ\u0160T\u00cdPNUT\u00cdM! Axes.Combat.CritStruck=[[DARK_RED]]Byl jsi KRITICKY zasazen! Axes.Combat.CritChance=[[RED]]Sance na kriticky uder: [[YELLOW]]{0}% Axes.Combat.CriticalHit=[[RED]]KRITICK\u00dd Z\u00c1SAH! @@ -73,13 +72,16 @@ Excavation.Skills.GigaDrillBreaker.Other.Off=[[RED]]Ni\u010ditel hl\u00edny[[GRE Excavation.Skills.GigaDrillBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] pou\u017eil [[RED]]Giga Vrta\u010dku! Excavation.Skillup=[[YELLOW]]Dovednost v kopani byla navysena o {0}. Celkem ({1}) Fishing.Ability.Info=[[RED]]Magick\u00fd lovec: [[GRAY]] **Zvy\u0161uje se s dovednost\u00ed Lovec poklad\u016f** +Fishing.Ability.Locked.0=Uzam\u010deno do {0}+ schopnosti (Prot\u0159ep\u00e1n\u00ed) Fishing.Ability.Rank=[[RED]]Lovec Poklad\u016f Level: [[YELLOW]]{0}/5 +Fishing.Ability.FD=[[RED]]Ryb\u00e1\u0159\u016fv apetit: [[YELLOW]]Rank {0} Fishing.Effect.0=Lovec pokladu (pasivni) Fishing.Effect.1=Fish up misc. objects Fishing.Effect.2=Magicky Lovec Fishing.Effect.3=Na\u0161el si o\u010darovanou v\u011bc Fishing.Effect.4=Shake (vs. Entities) Fishing.Effect.5=Vyklepni p\u0159edm\u011bty z p\u0159\u00ed\u0161er s prutem +Fishing.Effect.6=Ryb\u00e1\u0159\u016fv apetit Fishing.Enchant.Chance=[[RED]]\u0160ance na magick\u00e9ho lovce: [[YELLOW]]{0} Fishing.ItemFound=[[GRAY]]Nasel si poklad! Fishing.Listener=Rybareni: @@ -96,6 +98,7 @@ Herbalism.Ability.Ready=[[GREEN]]**PRIPRAVIL JSI SVOU MOTYKU** Herbalism.Effect.0=Green Terra (SCHOPNOST) Herbalism.Effect.1=\u0160\u00ed\u0159en\u00ed planety, 3x v\u00edce drop\u016f Herbalism.Effect.2=Zahradnik (Wheat) +Herbalism.Effect.3=Automaticky sazi plodiny pri sklizeni Herbalism.Effect.4=Zahradn\u00edk (Cobble/Stone Brick/Dirt) Herbalism.Effect.5=Zar\u016fst cihly mechem, nebo nebo nechat vyr\u016fst tr\u00e1vu Herbalism.Effect.6=Farm\u00e1\u0159\u016fv apetit @@ -115,7 +118,7 @@ Mining.Ability.Lower=[[GRAY]]**SLOZIL SI SVUJ KRUMPAC** Mining.Ability.Ready=[[GREEN]]**KRUMPAC PRIPRAVEN** Mining.Effect.0=Super Breaker (SCHOPNOST) Mining.Effect.1=Rychlost+, sance na trojnasobny zisk -Mining.Effect.2=Dvojnasobne zisky +Mining.Effect.2=Dvojn\u00e1sobn\u00fd zisk Mining.Effect.3=Zdvojnasobi normalni zisk Mining.Effect.4=Tezeni vybuchem Mining.Effect.5=Bonusy za tezeni s TNT @@ -134,14 +137,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] has used [[RED]]M Mining.Skills.SuperBreaker.Refresh=[[GREEN]]Schopnost [[YELLOW]]Super Breaker [[GREEN]]obnovena! Mining.Skillup=[[YELLOW]]Dovednost v dolovani byla navysena o {0}. Celkem ({1}) Mining.Blast.Boom=[[GRAY]]**VYBUCH** -Mining.Blast.Effect.0=+35% rud -Mining.Blast.Effect.1=+40% rud -Mining.Blast.Effect.2=+45% rud, bez suti -Mining.Blast.Effect.3=+50% rud, bez suti -Mining.Blast.Effect.4=+55% rud, bez suti, dvojit\u00e9 dropy -Mining.Blast.Effect.5=+60% rud, bez suti, dvojit\u00e9 dropy -Mining.Blast.Effect.6=+65% rud, bez suti, trojit\u00e9 dropy -Mining.Blast.Effect.7=+70% rud, bez suti, trojit\u00e9 dropy Mining.Blast.Radius.Increase=[[RED]]Navyseni radiusu vybuchu: [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]V\u00fdbu\u0161n\u00e9 t\u011b\u017een\u00ed [[YELLOW]] Rank {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] pou\u017eil [[RED]]V\u00fdbu\u0161n\u00e9 T\u011b\u017een\u00ed! @@ -179,7 +174,7 @@ Repair.Skills.StackedItems=[[DARK_RED]]Nem\u016f\u017ee\u0161 opravovat nestacko Repair.Skills.Super.Chance=[[RED]]\u0160ance na superopravov\u00e1n\u00ed: [[YELLOW]]{0} Repair.Skillup=[[YELLOW]]Dovednost v opravovani byla navysena o {0}. Celkem ({1}) Repair.Arcane.Chance.Downgrade=[[GRAY]]Sance na degradovani magicke sily predmetu: [[YELLOW]]{0}% -Repair.Arcane.Chance.Success=[[GRAY]]Mira uspesnosti AF: [[YELLOW]]{0}% +Repair.Arcane.Chance.Success=[[GRAY]]Pravd\u011bpodobnost \u00fasp\u011bchu AF: [[YELLOW]]{0}% Repair.Arcane.Downgrade=[[RED]]Magick\u00e1 s\u00edla tohoto p\u0159edm\u011btu zesl\u00e1bla. Repair.Arcane.Fail=[[RED]]Predmet ztratil navzdy svou magickou silu. Repair.Arcane.Lost=[[RED]]Nemel jsi dostatocnou dovednost pro zachovani ocarovani predmetu. @@ -217,6 +212,7 @@ Taming.Ability.Bonus.2=Husta srst Taming.Ability.Bonus.4=Otresuvzdorny Taming.Ability.Bonus.6=Nabrousene drapy Taming.Ability.Bonus.8=Rychl\u00e9 Ob\u010derstven\u00ed +Taming.Ability.Bonus.9={0} \u0161ance na vyl\u00e9\u010den\u00ed p\u0159i \u00fatoku Taming.Combat.Chance.Gore=[[RED]]\u0160ance na nabodnut\u00ed: [[YELLOW]]{0} Taming.Effect.0=Tradice \u0161elem Taming.Effect.1=Na\u0159\u00edznut\u00ed kost\u00ed kontroluje vlky & oceloty @@ -293,9 +289,7 @@ Combat.ArrowDeflect=[[WHITE]]**SIP VYCHYLEN** Combat.BeastLore=[[GREEN]]**TRADICE SELEM** Combat.BeastLoreHealth=[[DARK_AQUA]]Zivoty ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Vlastn\u00edk ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Byl jsi zasazen horicim sipem! Combat.Gore=[[GREEN]]**PRUNIK** -Combat.Ignition=[[RED]]**VZPLANUTI** Combat.StruckByGore=[[RED]]**BYL JSI PROBODNUT** Combat.TargetDazed=C\u00edl byl [[DARK_RED]]Omr\u00e1\u010den Combat.TouchedFuzzy=[[DARK_RED]]Nejasne dotcen. Mas zavrat. @@ -314,6 +308,9 @@ Commands.Invite.Accepted=[[GREEN]]Pozvanka prijata. Pridal jsi se k party {0} Commands.Invite.Success=[[GREEN]]Pozv\u00e1nka \u00faspesne odesl\u00e1na. Commands.Leaderboards= [[RED]]- Tabulka nejlep\u0161\u00edch Commands.mcgod=[[RED]]- Prepnout GodMod +Commands.mchud.Invalid=Nespr\u00e1vn\u00fd typ HUD. +Commands.mcrank.Heading=[[GOLD]]-=OSOBN\u00cd HODNOCEN\u00cd=- +Commands.mctop.Tip=[[GOLD]]Tip: Pro osobn\u00ed statistiky pou\u017eij [[RED]]/mcrank[[GOLD]]! Commands.mmoedit=[player] [[RED]] - Modify target Commands.ModDescription=[[RED]]- Precti si strucny popis pluginu Commands.NoConsole=Tento prikaz nepodporuje pouziti z konzole. @@ -321,8 +318,10 @@ Commands.Other=[[GREEN]]--OSTATNI PRIKAZY-- Commands.Party.Accept=[[RED]]- Potvrdit pozvanku do party Commands.Party.Chat.Off=Chat jenom pro partu [[RED]]Vypnuty Commands.Party.Chat.On=Party chat [[RED]]Off +Commands.Party.Chat.Prefix=[[GREEN]]([[WHITE]]{0}[[GREEN]]) Commands.Party.Commands=[[GREEN]]--P\u0158\u00cdKAZY PARTY-- Commands.Party.Invite.0=[[RED]]VAROVANI: [[GREEN]]Obdrzel jsi pozvanku do party {0} od {1} +Commands.Party.Rename=[[GRAY]]Jm\u00e9no party zm\u011bn\u011bno na: [[WHITE]]{0} Commands.Party.Kick=[[RED]]Byl jsi vyhozen z party {0}! Commands.Party.Leave=[[RED]]Opustil jsi party Commands.Party.None=[RED]]Nejsi v zadne party. @@ -332,12 +331,17 @@ Commands.Party.Toggle=[[RED]]- Zapnout party chat Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Rebricek [[YELLOW]]Celkovych levelu-- Commands.PowerLevel=[[DARK_RED]]CELKOVY LEVEL: [[GREEN]]{0} Commands.Reset.All=[[GREEN]] Vsechny vase dovednosti byli byli uspesne resetov\u00e1ny. +Commands.Reset.Single=[[GREEN]] Vsechny vase dovednosti byly uspesne resetov\u00e1ny. Commands.Skill.Invalid=[[RED]]Neplatny nazev dovednosti! Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Tabulka nejlepsich-- Commands.SkillInfo=/ [[RED]]- Zjist\u00ed\u0161 bliz\u0161\u00ed informace o skillu Commands.Stats.Self=Tvoje statistiky Commands.Stats=[[RED]]- Shl\u00e9dnout svoje mcMMO statistiky Commands.ToggleAbility=[[RED]]- Aktivace schopnosti prav\u00fdm tla\u010d\u00edtkem. +Commands.Usage.Message=zprava +Commands.Usage.Page=stranka +Commands.Usage.Password=heslo +Commands.Usage.Player=hrac mcMMO.NoInvites=[[RED]]Momentalne nemas zadne pozvanky mcMMO.NoPermission=[[DARK_RED]]Nedostatecna prava mcMMO.NoSkillNote=[[DARK_GRAY]]Pokud nemas pristup k schopnosti, nebude zobrazena. @@ -349,9 +353,12 @@ Party.Locked=[[RED]]Parta je zamnuta, pouze velitel party t\u011b m\u016f\u017ee Party.NotInYourParty=[[DARK_RED]]{0} nen\u00ed ve tv\u00e9 part\u011b. Party.Password.Set=[[GREEN]]Heslo do party nastaveno na {0} Party.Player.Invalid=[[RED]]Tohle neni platny hrac. +Party.NotOnline=[[DARK_RED]]{0} nen\u00ed online! +Party.Player.InSameParty=[[RED]]{0} u\u017e je na va\u0161\u00ed party! +Party.PlayerNotInParty=[[DARK_RED]]{0} nen\u00ed na party Party.Teleport.Dead=[[RED]]Nemuzes se teleportovat k mrtvemu hraci. -Party.Teleport.Hurt=[[RED]]Byl jsi zasa\u017een p\u0159ed {0} sekundami a nem\u016f\u017ee\u0161 se teleportovat. Party.Teleport.Player=[[GREEN]]Byl jsi teleportovan k {0}. +Party.Teleport.Self=[[RED]]Nem\u016f\u017ee\u0161 se teleportovat s\u00e1m na sebe! Party.Teleport.Target=[[GREEN]]{0} se k tobe teleportoval. Party.Unlocked=[[GRAY]]Party je odemknuta Commands.XPGain.Acrobatics=Padani @@ -380,8 +387,10 @@ Effects.Level=[[DARK_GRAY]]LVL: [[GREEN]]{0} [[DARK_AQUA]]XP[[YELLOW]]([[GOLD]]{ Effects.Template=[[DARK_AQUA]]{0}: [[GREEN]]{1} Guides.Acrobatics=[[DARK_AQUA]]O akrobacii:\n[[YELLOW]]Akrobacie je um \u00fa\u017easn\u00e9ho pohybu v mcMMO.\n[[YELLOW]]D\u00e1v\u00e1 ti bonusy v boji a bonusy po\u0161kozen\u00ed v prost\u0159ed\u00ed.\n[[DARK_AQUA]]Zisk XP:\n[[YELLOW]]K z\u00edsk\u00e1n\u00ed XP v t\u00e9to dovednosti mus\u00ed\u0161 uhybat\n[[YELLOW]]p\u0159ed ranami nep\u0159\u00edtele, nebo p\u0159e\u017e\u00edvat p\u00e1dy.\n[[DARK_AQUA]]Jak fungujou kotrmelce?\n[[YELLOW]]M\u00e1\u0161 \u0161anci kdy\u017e pad\u00e1\u0161 zmen\u0161it \u0161kody, kter\u00e9\n[[YELLOW]]by ti zp\u016fsobily p\u00e1dy. Dr\u017e kl\u00e1vesu na skr\u010den\u00ed\n[[YELLOW]]p\u0159i p\u00e1du k v\u00fd\u0161en\u00ed \u0161ance na kotrmelec.\n[[YELLOW]]T\u00edm vznik\u00e1 P\u016fvabn\u00fd kotrmelec m\u00edsto standartn\u00edho.\n[[YELLOW]]P\u016fvabn\u00e9 kotrmelce jsou jako norm\u00e1ln\u00ed, ale m\u00e1\u0161 2x v\u011bt\u0161\u00ed \u0161anci\n[[YELLOW]]p\u0159e\u017e\u00edt p\u00e1d a jsou bezpe\u010dn\u011bj\u0161\u00ed ne\u017e norm\u00e1ln\u00ed\n[[YELLOW]]\u0160ance na kotrmelec jsou ovlivn\u011bny tv\u00fdmi dovednostmi\n[[DARK_AQUA]]Jak funguje \u00faskok?\n[[YELLOW]]\u00daskok je \u0161ance na rozp\u016flen\u00ed \u0161kod\n[[YELLOW]]kter\u00e9 by jsi z\u00edskal v boji.\n[[YELLOW]]Je ovlivn\u011bn tv\u00fdmi dovednostmi Guides.Axes=Pruvodce jiz brzy... +Guides.Available=[[DARK_AQUA]]N\u00e1vod k {0} - napi\u0161te /{1} ? [page] Guides.Excavation=[[DARK_AQUA]]O kopani:\n[[YELLOW]]Kopani je cinnost vykonavana nicenim bloku hliny lopatou a nachazenim pokladu.\n[[YELLOW]]Nicenim bloku lopatou ziskavate sanci, ze naleznete poklady.\n[[YELLOW]]Cim dele tuhle cinnost provozujete, tim vic zvysujete svou sanci k naleznuti.\n[[DARK_AQUA]]Zisk dovednosti:\n[[YELLOW]]Pro zisk dovednosti v kopani musite nicit hlinene bloky lopatou.\n[[YELLOW]]Pro naleznuti pokladu muzou byt niceni jen nektere bloky.\n[[DARK_AQUA]]Seznam bloku se sanci pro nalezeni pokladu:\n[[YELLOW]]Trava, Hlina, Pisek, Jil, Sterk, Podhubi, Zvetrany pisek\n[[DARK_AQUA]]Jak pouzivat Giga Drill Breaker:\n[[YELLOW]]S lopatou v ruce a klikem pravym tlacidlem aktivujete svuj nastroj.\n[[YELLOW]]Once in this state you have about 4 seconds to make\n[[YELLOW]]contact with Excavation compatible materials this will\n[[YELLOW]]activate Giga Drill Breaker.\n[[DARK_AQUA]]What is Giga Drill Breaker?\n[[YELLOW]]Giga Drill Breaker is an ability with a cooldown\n[[YELLOW]]tied to Excavation skill. It triples your chance\n[[YELLOW]]of finding treasures and enables instant break\n[[YELLOW]]on Excavation materials.\n[[DARK_AQUA]]How does Treasure Hunter work?\n[[YELLOW]]Every possible treasure for Excavation has its own\n[[YELLOW]]skill level requirement for it to drop, as a result it\'s\n[[YELLOW]]difficult to say how much it is helping you.\n[[YELLOW]]Just keep in mind that the higher your Excavation skill\n[[YELLOW]]is, the more treasures that can be found.\n[[YELLOW]]And also keep in mind that each type of Excavation\n[[YELLOW]]compatible material has its own unique list of treasures.\n[[YELLOW]]In other words you will find different treasures in Dirt\n[[YELLOW]]than you would in Gravel.\n[[DARK_AQUA]]Notes about Excavation:\n[[YELLOW]]Excavation drops are completely customizeable\n[[YELLOW]]So results vary server to server. Guides.Mining=[[DARK_AQUA]]O Miningu:\n[[YELLOW]]Mining spo\u010d\u00edv\u00e1 v t\u011b\u017een\u00ed kamenu a rud. Poskytuje bonusy\n[[YELLOW]]v po\u010dtu materi\u00e1lu, kter\u00fd vyt\u011b\u017e\u00edte.\n\n[[DARK_AQUA]]Z\u00edskan\u00ed XP:\n[[YELLOW]]Aby jste dostali XP, mus\u00edte m\u00edt v ruce krump\u00e1\u010d.\n[[YELLOW]]XP v\u00e1m d\u00e1vaj\u00ed jenom jist\u00e9 bloky.\n\n[[DARK_AQUA]]Kompatibiln\u00ed materi\u00e1ly:\n[[YELLOW]]Stone, Coal Ore, Iron Ore, Gold Ore, Diamond Ore, Redstone Ore,\n[[YELLOW]]Lapis Ore, Obsidian, Mossy Cobblestone, Ender Stone,\n[[YELLOW]]Glowstone, a Netherrack.\n\n\n[[DARK_AQUA]]Jak pou\u017e\u00edt Super Breaker:\n[[YELLOW]]Dr\u017ete v ruce krump\u00e1\u010d a stisknete prav\u00e9 tla\u010ditko na my\u0161i.\n[[YELLOW]]Vr\u00e1mci \u010dty\u0159 sekund m\u00fa\u017eete buchnout do bloku, kter\u00fd je naps\u00e1n\n[[YELLOW]]v kompatibiln\u00edch materi\u00e1lech, kter\u00e9 aktivujou\n[[YELLOW]]Super Breaker.\n\n[[DARK_AQUA]]Co je to Super Breaker?\n[[YELLOW]]Super Breaker je schopnost, kter\u00e1 trv\u00e1 podle toho,\n[[YELLOW]]jak\u00fd m\u00e1te skill. Ztrojn\u00e1sobuje va\u0161i \u0161anci na z\u00edskan\u00ed extra v\u011bc\u00ed\n[[YELLOW]]a t\u011b\u017e\u00edte bloky na jednu r\u00e1nu.\n\n[[DARK_AQUA]]Jak pou\u017e\u00edt Blast Mining:\n[[YELLOW]]Kdy\u017e m\u00e1te v ruce odpalova\u010d, kter\u00fdm je flint and steel ve vychoz\u00edm nastaven\u00ed,\n[[YELLOW]]klikn\u011bte prav\u00fdm tla\u010ditkem na my\u0161i na TNT, a to zp\u016fsob\u00ed,\n[[YELLOW]]\u017ee hned bouchne.\n\n[[DARK_AQUA]]Jak funguje Blast Mining?\n[[YELLOW]]Blast Mining je schopnost, kter\u00e1 trv\u00e1 podle toho, jak\u00fd m\u00e1te\n[[YELLOW]]skill. D\u00e1va bonusy kdy\u017e t\u011b\u017e\u00edte pou\u017eit\u00edm TNT a umo\u017e\u0148uje v\u00e1m\n[[YELLOW]]d\u00e1lkov\u011b odp\u00e1lit TNT. Blast mining m\u00e1 3 \u010d\u00e1sti.\n[[YELLOW]]Prvn\u00ed \u010d\u00e1st je Bigger Bombs, kter\u00e1 zv\u011bt\u0161uje oblast v\u00fdbuchu.\n[[YELLOW]]Druh\u00e1 \u010d\u00e1st je Demolitions Expert, kter\u00e1 zvy\u0161uje po\u0161kozen\u00ed\n[[YELLOW]]v\u00fdbuchem TNT. T\u0159et\u00ed \u010d\u00e1st prost\u011b zvy\u0161uje mno\u017estvi rud, kter\u00e9\n[[YELLOW]]z\u00edsk\u00e1te z TNT a zni\u017euje su\u0165,\n[[YELLOW]]kter\u00e1 padne. +Guides.Page.Invalid=Nespr\u00e1vn\u00e9 \u010d\u00edslo str\u00e1nky! Inspect.Offline=[[RED]]Nem\u00e1\u0161 pr\u00e1va kontrolovat hr\u00e1\u010de co nejsou online! Inspect.OfflineStats=mcMMO Statistiky pro offline hrace [[YELLOW]]{0} Inspect.Stats=[[GREEN]]mcMMO Statistiky pro [[YELLOW]]{0} @@ -401,3 +410,13 @@ Stats.Own.Stats=[[GREEN]][mcMMO] Statistiky Perks.xp.name=Zku\u0161enost Perks.xp.desc=Obdrzene {0}x Zkusenosti Perks.lucky.name=\u0160test\u00ed +Perks.cooldowns.name=Rychle zotaveni +Perks.activationtime.name=Vytrvalost +Perks.activationtime.desc=Prodlu\u017euje pou\u017eit\u00ed schopnosti na {0} sekund. +Vampirism.Killer.Success=[[GOLD]][mcMMO] [[DARK_AQUA]]Z\u00edskal jsi [[BLUE]]{0}[[DARK_AQUA]] level\u016f od [[YELLOW]]{1}. +Spout.Donate=[[YELLOW]][mcMMO] P\u0159isp\u011bjte! +Spout.Menu.HudButton.1=Typ HUD: {0} +Spout.Menu.HudButton.2=Zm\u011b\u0148te si styl HUD! +MOTD.Version=[[GOLD]][mcMMO] - verze [[DARK_AQUA]]{0} +MOTD.Website=[[GOLD]][mcMMO] [[GREEN]]{0}[[YELLOW]] - Web mcMMO +Commands.Description.mcremove=Odstranit u\u017eivatele z datab\u00e1ze mcMMO diff --git a/src/main/resources/locale/locale_cy.properties b/src/main/resources/locale/locale_cy.properties index 14179b01e..79900a6ef 100644 --- a/src/main/resources/locale/locale_cy.properties +++ b/src/main/resources/locale/locale_cy.properties @@ -32,7 +32,6 @@ Axes.Ability.Bonus.4=Greater Impact Axes.Ability.Bonus.5=Deal {0} Bonus DMG to unarmored foes Axes.Ability.Lower=[[GRAY]]**YOU LOWER YOUR AXE** Axes.Ability.Ready=[[GREEN]]**YOU READY YOUR AXE** -Axes.Combat.Cleave.Proc=[[DARK_RED]]Struck by CLEAVE! Axes.Combat.CritStruck=[[DARK_RED]]You were CRITICALLY hit! Axes.Combat.CritChance=[[RED]]Chance to critically strike: [[YELLOW]]{0} Axes.Combat.CriticalHit=[[RED]]CRITICAL HIT! @@ -146,14 +145,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] has used [[RED]]S Mining.Skills.SuperBreaker.Refresh=[[GREEN]] Eich [[YELLOW]] Super Torri\'r [[GREEN]] gallu ei hadnewyddu! Mining.Skillup=[[YELLOW]] sgiliau Mwyngloddio cynyddu {0}. Cyfanswm ({1}) Mining.Blast.Boom=[[GRAY]]**BOOM** -Mining.Blast.Effect.0=+35% ore yield -Mining.Blast.Effect.1=+40% ore yield -Mining.Blast.Effect.2=+45% ore yield, no debris -Mining.Blast.Effect.3=+50% ore yield, no debris -Mining.Blast.Effect.4=+55% ore yield, no debris, double drops -Mining.Blast.Effect.5=+60% ore yield, no debris, double drops -Mining.Blast.Effect.6=+65% ore yield, no debris, triple drops -Mining.Blast.Effect.7=+70% ore yield, no debris, triple drops Mining.Blast.Radius.Increase=[[RED]] Chwyth Cynnydd Radiws [[YELLOW]] {0} Mining.Blast.Rank=[[RED]]Blast Mining: [[YELLOW]] Rank {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] has used [[RED]]Blast Mining! @@ -321,9 +312,7 @@ Combat.ArrowDeflect=[[WHITE]]**ARROW DEFLECT** Combat.BeastLore=[[GREEN]] ** bwystfil ll\u00ean ** Combat.BeastLoreHealth=[[DARK_AQUA]] Iechyd ([[GREEN]] {0} [[DARK_AQUA]] / {1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Owner ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]You were struck by a burning arrow! Combat.Gore=[[GREEN]]**GORED** -Combat.Ignition=[[RED]]**IGNITION** Combat.StruckByGore=[[RED]]**YOU HAVE BEEN GORED** Combat.TargetDazed=Target was [[DARK_RED]]Dazed Combat.TouchedFuzzy=[[DARK_RED]] cyffwrdd Fuzzy. Teimlo benysgafn. @@ -416,7 +405,6 @@ Party.Password.Incorrect=[[RED]]Party password is incorrect. Party.Password.Set=[[GREEN]] Blaid cyfrinair wedi ei osod i {0} Party.Player.Invalid=[[RED]] Nid yw hynny\'n chwaraewr ddilys. Party.Teleport.Dead=[[RED]] Ni allwch teleport y chwaraewr yn farw. -Party.Teleport.Hurt=[[RED]]You\'ve been hurt in the last {0} seconds and cannnot teleport. Party.Teleport.Player=[[GREEN]]You have teleported to {0}. Party.Teleport.Self=[[RED]]You can\'t teleport to yourself! Party.Teleport.Target=[[GREEN]] {0} wedi teleported i chi. diff --git a/src/main/resources/locale/locale_da.properties b/src/main/resources/locale/locale_da.properties index 01134479c..30bff0300 100644 --- a/src/main/resources/locale/locale_da.properties +++ b/src/main/resources/locale/locale_da.properties @@ -32,7 +32,6 @@ Axes.Ability.Bonus.4=St\u00f8rre Slag Axes.Ability.Bonus.5=P\u00e5f\u00f8r {0} Bonus Skade til ubev\u00e6bnede fjender Axes.Ability.Lower=[[GRAY]]**DU S\u00c6NKER DIN \u00d8KSE** Axes.Ability.Ready=[[GREEN]]**DU G\u00d8R DIN \u00d8KSE KLAR** -Axes.Combat.Cleave.Proc=[[DARK_RED]]Du bliver hugget midt over! Axes.Combat.CritStruck=[[DARK_RED]]Du er blevet KRITISK ramt! Axes.Combat.CritChance=[[RED]]Chance for at ramme kritisk: [[YELLOW]]{0} Axes.Combat.CriticalHit=[[RED]]KRITISK SLAG! @@ -146,14 +145,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] har brugt [[RED]] Mining.Skills.SuperBreaker.Refresh=[[GREEN]]Din [[YELLOW]]Super Smadrer [[GREEN]]evne er genindl\u00e6st! Mining.Skillup=[[YELLOW]]Minedriftsevne for\u00f8get med {0}. Total ({1}) Mining.Blast.Boom=[[GRAY]]**BOOM** -Mining.Blast.Effect.0=35% malm udbytte -Mining.Blast.Effect.1=40% malm udbytte -Mining.Blast.Effect.2=45% malm udbytte, ingen byggeaffald -Mining.Blast.Effect.3=50% malm udbytte, ingen byggeaffald -Mining.Blast.Effect.4=+55% malm udbytte, ingen byggeaffald, 2x udbytte -Mining.Blast.Effect.5=+60% malm udbytte, ingen byggeaffald, 2x udbytte -Mining.Blast.Effect.6=+65% malm udbytte, ingen byggeaffald, 3x udbytte -Mining.Blast.Effect.7=+70% malm udbytte, ingen byggeaffald, 3x udbytte Mining.Blast.Radius.Increase=[[RED]]Eksplosions Radius For\u00f8gelse: [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]Blast Mining: [[YELLOW]] Rank {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] her brugt [[RED]]Blast Mining! @@ -320,9 +311,7 @@ Combat.ArrowDeflect=[[WHITE]]**UNDVIGER PIL** Combat.BeastLore=[[GREEN]]**TIGGENDE MONSTER** Combat.BeastLoreHealth=[[DARK_AQUA]]Liv ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Ejer ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Du er blevet ramt af en brandene pil! Combat.Gore=[[GREEN]]**SPIDDET** -Combat.Ignition=[[RED]]**ANT\u00c6NDING** Combat.StruckByGore=[[RED]]**DU ER BLEVET SPIDDET** Combat.TargetDazed=M\u00e5let er nu [[DARK_RED]]Bed\u00f8vet Combat.TouchedFuzzy=[[DARK_RED]]R\u00f8rte Plysse. F\u00f8lte mig svimmel. @@ -417,7 +406,6 @@ Party.Password.Incorrect=[[RED]]Gruppe kodeord er forkert. Party.Password.Set=[[GREEN]]Gruppe adgangskode sat til {0} Party.Player.Invalid=[[RED]]Dette er ikke en rigtig spiller. Party.Teleport.Dead=[[RED]]Du kan ikke teleportere til en d\u00f8d spiller. -Party.Teleport.Hurt=[[RED]]Du er blevet skadet infenfor de sidste {0} sekunder og kan ikke teleportere. Party.Teleport.Player=[[GREEN]]Du har teleporteret til {0}. Party.Teleport.Self=[[RED]]Du kan ikke teleportere dig selv! Party.Teleport.Target=[[GREEN]]{0} har teleporteret til dig. diff --git a/src/main/resources/locale/locale_de.properties b/src/main/resources/locale/locale_de.properties index 329e7401f..626084897 100644 --- a/src/main/resources/locale/locale_de.properties +++ b/src/main/resources/locale/locale_de.properties @@ -32,7 +32,6 @@ Axes.Ability.Bonus.4=Wucht-Schlag Axes.Ability.Bonus.5=Veraursacht {0} Zusatz-Schaden gegen ungepanzerte Feinde Axes.Ability.Lower=[[GRAY]]**Du senkst deine Axt** Axes.Ability.Ready=[[GREEN]]**Deine Axt ist bereit** -Axes.Combat.Cleave.Proc=[[DARK_RED]]AUSGESCHALTET durch SCHLITZER! Axes.Combat.CritStruck=[[DARK_RED]]Du wurdest KRITISCH getroffen! Axes.Combat.CritChance=[[RED]]Chance auf kritischen Treffer: [[YELLOW]]{0} Axes.Combat.CriticalHit=[[RED]]KRITISCHER TREFFER! @@ -151,14 +150,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] benutzte [[RED]]S Mining.Skills.SuperBreaker.Refresh=[[GREEN]]Dein [[YELLOW]]Super-Brecher [[GREEN]]ist wieder bereit! Mining.Skillup=[[YELLOW]]Bergbau Fertigkeit ist um {0} gestiegen. Gesamt ({1}) Mining.Blast.Boom=[[GRAY]]**BOOM** -Mining.Blast.Effect.0=+35% Erz-Ausbeute -Mining.Blast.Effect.1=+40% Erz-Ausbeute -Mining.Blast.Effect.2=+45% Erz-Ausbeute, kein Schutt -Mining.Blast.Effect.3=+50% Erz-Ausbeute, kein Schutt -Mining.Blast.Effect.4=+55% Erz-Ausbeute, kein Schutt, Doppel-Drops -Mining.Blast.Effect.5=+60% Erz-Ausbeute, kein Schutt, Doppel-Drops -Mining.Blast.Effect.6=+65% Erz-Ausbeute, kein Schutt, Dreifach-Drops -Mining.Blast.Effect.7=+70% Erz-Ausbeute, kein Schutt, Dreifach-Drops Mining.Blast.Radius.Increase=[[RED]]Z\u00fcndstoff Radius Erh\u00f6hung: [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]Z\u00fcndstoff Rang:[[YELLOW]] {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] benutzte [[RED]]Z\u00fcndstoff! @@ -329,9 +320,7 @@ Combat.ArrowDeflect=[[WHITE]]**Pfeil ABGELENKT** Combat.BeastLore=[[GREEN]]**BESTIENKUNDE** Combat.BeastLoreHealth=[[DARK_AQUA]]Gesundheit ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Besitzer ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Du wurdest von einem BRENNENDEM PFEIL getroffen! Combat.Gore=[[GREEN]]**AUFGESCHLITZT** -Combat.Ignition=[[RED]]**ENTZ\u00dcNDUNG** Combat.StruckByGore=[[RED]]**du wurdest AUFGESCHLITZT** Combat.TargetDazed=Ziel wurde [[DARK_RED]]BET\u00c4UBT Combat.TouchedFuzzy=[[DARK_RED]]Ungl\u00fccklich ber\u00fchrt. Schwindelgef\u00fchl. @@ -426,7 +415,6 @@ Party.Password.Incorrect=[[RED]]Party password is incorrect. Party.Password.Set=[[GREEN]]Gruppen-Password ge\u00e4ndert zu: {0} Party.Player.Invalid=[[RED]]Dies ist kein g\u00fcltiger Spieler. Party.Teleport.Dead=[[RED]]Du kannst dich nicht zu toten Spielern teleportieren -Party.Teleport.Hurt=[[RED]]Du wurdest in den letzten {0} Sekunden verletzt und kannst dich nicht teleportieren. Party.Teleport.Player=[[GREEN]]Du wurdest zu {0} teleportiert. Party.Teleport.Self=[[RED]]You can\'t teleport to yourself! Party.Teleport.Target=[[GREEN]]{0} hat sich zu dir teleportiert. diff --git a/src/main/resources/locale/locale_es.properties b/src/main/resources/locale/locale_es.properties index 80a5e1242..bfc79e582 100644 --- a/src/main/resources/locale/locale_es.properties +++ b/src/main/resources/locale/locale_es.properties @@ -32,7 +32,6 @@ Axes.Ability.Bonus.4=Gran Impacto Axes.Ability.Bonus.5=Hacer {0} de da\u00f1o bonus a los enemigos sin armadura Axes.Ability.Lower=[[GRAY]]**BAJAS TU HACHA** Axes.Ability.Ready=[[GREEN]]**PREPARAS TU HACHA** -Axes.Combat.Cleave.Proc=[[DARK_RED]]\u00a1Golpeado por PARTIR! Axes.Combat.CritStruck=[[DARK_RED]]\u00a1Fuiste golpeado CR\u00cdTICAMENTE! Axes.Combat.CritChance=[[RED]]Probabilidad de golpe cr\u00edtico: [[YELLOW]]{0}% Axes.Combat.CriticalHit=[[RED]]\u00a1GOLPE CR\u00cdTICO! @@ -134,14 +133,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]\u00a1{0}[[DARK_GREEN]] us\u00f3 [[ Mining.Skills.SuperBreaker.Refresh=[[GREEN]]\u00a1Tu habilidad de [[YELLOW]]S\u00faper Destructor [[GREEN]]est\u00e1 refrescada! Mining.Skillup=[[YELLOW]]Habilidad de Miner\u00eda incrementada en {0}. Total ({1}) Mining.Blast.Boom=[[GRAY]]**BOOM** -Mining.Blast.Effect.0=+35% de producci\u00f3n minera -Mining.Blast.Effect.1=+40% de producci\u00f3n minera -Mining.Blast.Effect.2=+45% de producci\u00f3n minera, sin residuos -Mining.Blast.Effect.3=+50% de producci\u00f3n minera, sin residuos -Mining.Blast.Effect.4=+55% de producci\u00f3n minera, sin residuos, doble drops -Mining.Blast.Effect.5=+60% de producci\u00f3n minera, sin residuos, doble drops -Mining.Blast.Effect.6=+65% de producci\u00f3n minera, sin residuos y triple drops -Mining.Blast.Effect.7=+70% de producci\u00f3n minera, sin residuos, triple drops Mining.Blast.Radius.Increase=[[RED]]Incrementado Radio de Explosi\u00f3n: [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]Miner\u00eda Explosiva: [[YELLOW]] Rango {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]\u00a1{0}[[DARK_GREEN]] us\u00f3 [[RED]]Miner\u00eda Explosiva! @@ -290,9 +281,7 @@ Combat.ArrowDeflect=[[WHITE]]**FLECHA DESVIADA** Combat.BeastLore=[[GREEN]]**CONOCIMIENTO DE LA BESTIA** Combat.BeastLoreHealth=[[DARK_AQUA]]Salud ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Due\u00f1o ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Has sido golpeado por una flecha ardiendo\\! Combat.Gore=[[GREEN]]**MORDISCO** -Combat.Ignition=[[RED]]**IGNICION** Combat.StruckByGore=[[RED]]**FUISTE MORDISQUEADO** Combat.TargetDazed=El objetivo fue [[DARK_RED]]aturdido Combat.TouchedFuzzy=[[DARK_RED]]Est\u00e1s confuso. Te sientes mareado. @@ -346,7 +335,6 @@ Party.NotInYourParty=[[DARK_RED]]{0} no esta en tu fiesta Party.Password.Set=[[GREEN]]Contrase\u00f1a del grupo establecida: [[RED]]{0} Party.Player.Invalid=[[RED]]Ese no es un jugador v\u00e1lido. Party.Teleport.Dead=[[RED]]No te puedes teletransportar a un jugador muerto. -Party.Teleport.Hurt=[[RED]]Fuiste herido en los \u00faltimos {0} segundos y no te puedes teletransportar. Party.Teleport.Player=[[GREEN]]Te teletransportaste a {0}. Party.Teleport.Target=[[GREEN]]{0} se teletransport\u00f3 a ti. Party.Unlocked=[[GRAY]]El grupo est\u00e1 desbloqueado diff --git a/src/main/resources/locale/locale_fi.properties b/src/main/resources/locale/locale_fi.properties index bf98a0753..283fecbfe 100644 --- a/src/main/resources/locale/locale_fi.properties +++ b/src/main/resources/locale/locale_fi.properties @@ -13,9 +13,7 @@ Combat.ArrowDeflect=[[WHITE]]**NUOLI TORJUTTU** Combat.BeastLore=[[GREEN]]**BEAST LORE** Combat.BeastLoreHealth=[[DARK_AQUA]]Health ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Owner ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Palava nuoli osui sinuun\\! Combat.Gore=[[GREEN]]**PISTO** -Combat.Ignition=[[RED]]**SYTYTYS** Combat.StruckByGore=[[RED]]**SINUA ON PISTETTY** Combat.TargetDazed=Kohde [[DARK_RED]]tyrm\u00e4tty Combat.TouchedFuzzy=[[DARK_RED]]T\u00f6kk\u00e4sit P\u00f6rr\u00f6\u00e4. Tunsit huimauksen. diff --git a/src/main/resources/locale/locale_fr.properties b/src/main/resources/locale/locale_fr.properties index 43a06123c..548c21b38 100644 --- a/src/main/resources/locale/locale_fr.properties +++ b/src/main/resources/locale/locale_fr.properties @@ -32,7 +32,6 @@ Axes.Ability.Bonus.4=Impact puissant Axes.Ability.Bonus.5=Inflige {0} de d\u00e9g\u00e2ts en plus aux ennemis sans armure Axes.Ability.Lower=[[GRAY]]**VOUS ABAISSEZ VOTRE HACHE** Axes.Ability.Ready=[[GREEN]]**VOUS LEVEZ VOTRE HACHE** -Axes.Combat.Cleave.Proc=[[DARK_RED]]Frapp\u00e9 par Tranche-cr\u00e2ne ! Axes.Combat.CritStruck=[[DARK_RED]]Vous avez re\u00e7u un coup critique ! Axes.Combat.CritChance=[[RED]]Chance d\'infliger un coup critique : [[YELLOW]]{0}% Axes.Combat.CriticalHit=[[RED]]COUP CRITIQUE ! @@ -133,14 +132,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] a utilis\u00e9 [[ Mining.Skills.SuperBreaker.Refresh=[[GREEN]]Votre comp\u00e9tence [[YELLOW]]Broyeur [[GREEN]]est pr\u00eate ! Mining.Skillup=[[YELLOW]]Le talent Minage augmente de {0}. Total ({1}) Mining.Blast.Boom=[[GRAY]]**BOUM** -Mining.Blast.Effect.0=+35% de rendement -Mining.Blast.Effect.1=+40% de rendement -Mining.Blast.Effect.2=+45% de rendement, pas de d\u00e9bris -Mining.Blast.Effect.3=+50% de rendement, pas de d\u00e9bris -Mining.Blast.Effect.4=+55% de rendement, pas de d\u00e9bris, double drops -Mining.Blast.Effect.5=+60% de rendement, pas de d\u00e9bris, double drops -Mining.Blast.Effect.6=+65% de rendement, pas de d\u00e9bris, triple drops -Mining.Blast.Effect.7=+70% de rendement, pas de d\u00e9bris, triple drops Mining.Blast.Radius.Increase=[[RED]]Rayon d\'explosion : [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]Minage explosif : [[YELLOW]]Rang {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] a utilis\u00e9 [[RED]]Minage explosif ! @@ -282,9 +273,7 @@ Combat.ArrowDeflect=[[WHITE]]**FL\u00c8CHE DEVI\u00c9E** Combat.BeastLore=[[GREEN]]**CONNAISSANCE DES B\u00caTES** Combat.BeastLoreHealth=[[DARK_AQUA]]Vie ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Propri\u00e9taire ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Vous avez \u00e9t\u00e9 frapp\u00e9 par une fl\u00e8che br\u00fblante\\! Combat.Gore=[[GREEN]]**SANG** -Combat.Ignition=[[RED]]**ALLUMAGE** Combat.StruckByGore=[[RED]]**FRAPP\u00c9 JUSQU\'AU SANG** Combat.TargetDazed=La cible a \u00e9t\u00e9 [[DARK_RED]]\u00c9tourdi Combat.TouchedFuzzy=[[DARK_RED]]Vous \u00eates \u00e9tourdi. @@ -338,7 +327,6 @@ Party.NotInYourParty=[[DARK_RED]]{0} is not in your party Party.Password.Set=[[GREEN]]Mot de passe d\u00e9fini : {0} Party.Player.Invalid=[[RED]]Ce joueur n\'existe pas. Party.Teleport.Dead=[[RED]]Vous ne pouvez pas vous t\u00e9l\u00e9porter sur un joueur mort. -Party.Teleport.Hurt=[[RED]]Vous avez \u00e9t\u00e9 bless\u00e9 durant les {0} derni\u00e8res secondes et ne pouvez pas vous t\u00e9l\u00e9porter. Party.Teleport.Player=[[GREEN]]Vous vous \u00eates t\u00e9l\u00e9port\u00e9 sur {0}. Party.Teleport.Target=[[GREEN]]{0} s\'est t\u00e9l\u00e9port\u00e9 sur vous. Party.Unlocked=[[GRAY]]Le groupe est d\u00e9verrouill\u00e9. diff --git a/src/main/resources/locale/locale_hu_HU.properties b/src/main/resources/locale/locale_hu_HU.properties index 819f25ff3..ae274d48e 100644 --- a/src/main/resources/locale/locale_hu_HU.properties +++ b/src/main/resources/locale/locale_hu_HU.properties @@ -1,19 +1,39 @@ Acrobatics.Combat.Proc=[[GREEN]]**Elker\u00fclve** Acrobatics.SkillName=AKROBATIKA Acrobatics.Skillup=[[YELLOW]]Akrobatika fejl\u0151d\u00f6tt {0} szinttel. \u00d6sszesen: ({1}) +Archery.Skillup=[[YELLOW]]\u00cdj\u00e1szat fejl\u0151d\u00f6tt {0} szinttel. \u00d6sszesen: ({1}) +Axes.Combat.GI.Struck=[[RED]]**HATALMAS EREJ\u0170 \u00dcT\u00c9S** +Axes.Skills.SS.Other.On=[[GREEN]]{0}[[DARK_GREEN]] haszn\u00e1lta a [[RED]]Koponya T\u00f6r\u0151t! Excavation.SkillName=\u00c1S\u00c1S Herbalism.Listener=Gy\u00f3gyn\u00f6v\u00e9nytan: Mining.Ability.Ready=[[GREEN]]**CS\u00c1K\u00c1NYOD K\u00c9SZEN \u00c1LL** +Mining.Skills.SuperBreaker.Refresh=[[GREEN]]A [[YELLOW]] Szuper Z\u00faz\u00f3 [[GREEN]]k\u00e9pess\u00e9ged \u00fajra haszn\u00e1lhat\u00f3! Mining.Skillup=[[YELLOW]]B\u00e1ny\u00e1szat fejl\u0151d\u00f6tt {0} szinttel. \u00d6sszesen: ({1}) +Mining.Blast.Refresh=[[GREEN]]A [[YELLOW]]Robban\u00f3 B\u00e1ny\u00e1szat [[GREEN]]k\u00e9pess\u00e9ged \u00fajra el\u00e9rhet\u0151! +Repair.Skills.AdeptGold=[[DARK_RED]]Nem vagy el\u00e9g k\u00e9pzett ahhoz, hogy arany t\u00e1rgyakat jav\u00edts. Repair.Arcane.Fail=[[RED]]A t\u00e1rgyon l\u00e9v\u0151 var\u00e1zslat szertefoszlott. Swords.Combat.Bleeding.Stopped=[[GRAY]]A v\u00e9rz\u00e9s [[GREEN]]elm\u00falt[[GRAY]]! +Swords.Combat.Bleeding=[[GREEN]]**ELLENS\u00c9G V\u00c9RZIK** Swords.Skills.SS.On=[[GREEN]]**F\u0170R\u00c9SZES CSAP\u00c1S AKTIV\u00c1LVA** +Unarmed.Skills.Berserk.Off=[[RED]]**Tombol\u00e1sod befejez\u0151d\u00f6tt** +Unarmed.Skills.Berserk.Other.On=[[GREEN]]{0}[[DARK_GREEN]] haszn\u00e1lta a [[RED]]Tombol\u00e1st! +Woodcutting.Ability.0=Lev\u00e9l F\u00faj\u00f3 +Woodcutting.Ability.1=Elf\u00fajja a leveleket. +Woodcutting.SkillName=FAV\u00c1G\u00c1S Ability.Generic.Template=[[RED]]{0}: [[YELLOW]]{1} +Combat.TouchedFuzzy=[[DARK_RED]]Bolyhosat \u00e9rintettem. Elsz\u00e9d\u00fcltem. +Commands.AdminChat.Off=Admin Chat [[RED]]kikapcsolva +Commands.mmoedit=[player] [[RED]] - M\u00f3dos\u00edtva Commands.Party.Kick=[[RED]]Kidobtak a csoportb\u00f3l {0}! +Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0} Party.Unlocked=[[GRAY]]Csoport nyitva +Commands.XPGain.Excavation=\u00c1sni \u00e9s kincset tal\u00e1lni. Commands.XPGain.Herbalism=N\u00f6v\u00e9nyek betakar\u00edt\u00e1sa Commands.XPGain.Mining=K\u0151 \u00e9s \u00e9rcek kib\u00e1ny\u00e1sz\u00e1sa Commands.XPGain.Taming=\u00c1llatok idom\u00edt\u00e1sa vagy harc a farkasoddal Commands.XPGain=[[DARK_GRAY]]KAPOTT TP: [[WHITE]]{0} -Guides.Excavation=[[DARK_AQUA]]\u00c1s\u00e1sr\u00f3l:\n[[YELLOW]]\u00c1s\u00e1s a kincskeres\u00e9s egyik fajt\u00e1ja..\n[[YELLOW]]\u00c1s\u00e1s sor\u00e1n ez\u00e9rt kincseket kaphatsz.\n[[YELLOW]]Min\u00e9l t\u00f6bbet \u00e1sol, ann\u00e1l t\u00f6bb kincset tal\u00e1lhatsz.\n\n[[DARK_AQUA]]Tapasztalat Pont (TP) szerz\u00e9s:\n[[YELLOW]]Ahhoz, hogy TP-t szerezhess, \u00e1s\u00f3val a kezedben kell \u00e1snod.\n[[YELLOW]]Csak meghat\u00e1rozott t\u00edpus\u00fa blokkokban tal\u00e1lhatsz kincseket.\n[[DARK_AQUA]]Meghat\u00e1rozott blokkok:\n[[YELLOW]]F\u0171, f\u00f6ld, homok, agyag, s\u00f3der, gomb\u00e1s f\u00f6ld, l\u00e9lekhomok\n\n[[DARK_AQUA]]Hogyan haszn\u00e1ld a Hatalmas F\u00far\u00f3t:\n[[YELLOW]]Kezedben az \u00e1s\u00f3val kattonts a jobb eg\u00e9r gombbak.\n[[YELLOW]]Ezut\u00e1n 4 m\u00e1sodperced van, hogy\n[[YELLOW]]elkezdj \u00e1sni egy megfelel\u0151 anyagon. Ez \n[[YELLOW]]aktiv\u00e1lni fogja a Hatalmas F\u00far\u00f3t.\n[[DARK_AQUA]]Mi az a Hatalmas F\u00far\u00f3?\n[[YELLOW]]Hatalmas f\u00far\u00f3 egy k\u00e9pess\u00e9g, amely az \u00c1s\u00e1s\n[[YELLOW]]j\u00e1rtass\u00e1godhoz k\u00f6t\u0151dik. Megh\u00e1romszorozza\n[[YELLOW]]a kincs es\u00e9s\u00e9nek es\u00e9ly\u00e9t \u00e9s azonnal sz\u00e9tt\u00f6ri\n[[YELLOW]]az \u00e1s\u00e1shoz kapcsol\u00f3d\u00f3 blokkokat.\n\n[[DARK_AQUA]]HHogyan m\u0171k\u00f6dik a kincskeres\u00e9s?\n[[YELLOW]]Every possible treasure for Excavation has its own\n[[YELLOW]]skill level requirement for it to drop, as a result it\'s\n[[YELLOW]]difficult to say how much it is helping you.\n[[YELLOW]]Just keep in mind that the higher your Excavation skill\n[[YELLOW]]is, the more treasures that can be found.\n[[YELLOW]]And also keep in mind that each type of Excavation\n[[YELLOW]]compatible material has its own unique list of treasures.\n[[YELLOW]]In other words you will find different treasures in Dirt\n[[YELLOW]]than you would in Gravel.\n[[DARK_AQUA]]Notes about Excavation:\n[[YELLOW]]Excavation drops are completely customizeable\n[[YELLOW]]So results vary server to server. +XPRate.Event=[[GOLD]]mcMMO-ban most TP r\u00e1ta n\u00f6vel\u0151 esem\u00e9ny van! TP r\u00e1ta {0}x! +Guides.Excavation=[[DARK_AQUA]]\u00c1s\u00e1sr\u00f3l:\n\n[[YELLOW]]\u00c1s\u00e1s a kincskeres\u00e9s egyik fajt\u00e1ja..\n\n[[YELLOW]]\u00c1s\u00e1s sor\u00e1n ez\u00e9rt kincseket kaphatsz.\n\n[[YELLOW]]Min\u00e9l t\u00f6bbet \u00e1sol, ann\u00e1l t\u00f6bb kincset tal\u00e1lhatsz.\n\n\n\n[[DARK_AQUA]]Tapasztalat Pont (TP) szerz\u00e9s:\n\n[[YELLOW]]Ahhoz, hogy TP-t szerezhess, \u00e1s\u00f3val a kezedben kell \u00e1snod.\n\n[[YELLOW]]Csak meghat\u00e1rozott t\u00edpus\u00fa blokkokban tal\u00e1lhatsz kincseket.\n\n[[DARK_AQUA]]Meghat\u00e1rozott blokkok:\n\n[[YELLOW]]F\u0171, f\u00f6ld, homok, agyag, s\u00f3der, gomb\u00e1s f\u00f6ld, l\u00e9lekhomok\n\n\n\n[[DARK_AQUA]]Hogyan haszn\u00e1ld a Hatalmas F\u00far\u00f3t:\n\n[[YELLOW]]Kezedben az \u00e1s\u00f3val kattints a jobb eg\u00e9r gombbak.\n\n[[YELLOW]]Ezut\u00e1n 4 m\u00e1sodperced van, hogy\n\n[[YELLOW]]elkezdj \u00e1sni egy megfelel\u0151 anyagon. Ez \n\n[[YELLOW]]aktiv\u00e1lni fogja a Hatalmas F\u00far\u00f3t.\n\n[[DARK_AQUA]]Mi az a Hatalmas F\u00far\u00f3?\n\n[[YELLOW]]Hatalmas f\u00far\u00f3 egy k\u00e9pess\u00e9g, amely az \u00c1s\u00e1s\n\n[[YELLOW]]j\u00e1rtass\u00e1godhoz k\u00f6t\u0151dik. Megh\u00e1romszorozza\n\n[[YELLOW]]a kincs es\u00e9s\u00e9nek es\u00e9ly\u00e9t \u00e9s azonnal sz\u00e9tt\u00f6ri\n\n[[YELLOW]]az \u00e1s\u00e1shoz kapcsol\u00f3d\u00f3 blokkokat.\n\n\n\n[[DARK_AQUA]]Hogyan m\u0171k\u00f6dik a kincskeres\u00e9s?\n\n[[YELLOW]]Minden kincsnek megvan a maga \n\n[[YELLOW]]szintbeli k\u00f6vetelm\u00e9nye, amely ut\u00e1n eshet, ennek k\u00f6vetkezt\u00e9ben \n\n[[YELLOW]]neh\u00e9z megmondani, hogy mennyire hasznos.\n\n[[YELLOW]]Csak tartsd \u00e9szben, hogy min\u00e9l nagyobb az \u00c1s\u00e1sbeli j\u00e1rtass\u00e1god,\n\n[[YELLOW]]ann\u00e1l t\u00f6bb kincset kaphatsz.\n\n[[YELLOW]]Ezen fel\u00fcl azt se felejtsd el, hogy minden \u00c1sat\u00e1shoz k\u00f6t\u0151d\u0151\n\n[[YELLOW]]anyagnak megvan a saj\u00e1t list\u00e1ja, arra, hogy milyen kincset tartalmazhat.\n\n[[YELLOW]]M\u00e1s szavakkal, m\u00e1s kincset tal\u00e1lhatsz egy f\u00f6ld blokkban\n\n[[YELLOW]]mint egy homok blokkban.\n\n[[DARK_AQUA]]Megjegyz\u00e9s az \u00c1s\u00e1shoz:\n\n[[YELLOW]]A kincsek teljesen szem\u00e9lyre szabhat\u00f3ak.\n\n[[YELLOW]]\u00cdgy szerverenk\u00e9nt elt\u00e9rhetnek egym\u00e1st\u00f3l. +Skills.Disarmed=[[DARK_RED]]Lefegyvereztek! Stats.Header.Combat=[[GOLD]]-=HARCI K\u00c9PZETTS\u00c9GEK=- +Stats.Header.Gathering=[[GOLD]]-= GY\u0170JT\u00d6GET\u0150 K\u00c9PESS\u00c9GEK=- diff --git a/src/main/resources/locale/locale_it.properties b/src/main/resources/locale/locale_it.properties index 8804221b7..e6e874947 100644 --- a/src/main/resources/locale/locale_it.properties +++ b/src/main/resources/locale/locale_it.properties @@ -33,7 +33,6 @@ Axes.Ability.Bonus.4=Impatto Maggiore Axes.Ability.Bonus.5=Infliggi {0} danni bonus ai nemici senza armatura Axes.Ability.Lower=[[GRAY]]**ABBASSI L\'ASCIA** Axes.Ability.Ready=[[GREEN]]**PREPARI L\'ASCIA** -Axes.Combat.Cleave.Proc=[[DARK_RED]]Colpito da SFONDAMENTO! Axes.Combat.CritStruck=[[DARK_RED]]Hai subito un colpo CRITICO! Axes.Combat.CritChance=[[RED]]Probabilit\u00e0 di un colpo critico: [[YELLOW]]{0}% Axes.Combat.CriticalHit=[[RED]]COLPO CRITICO! @@ -104,6 +103,8 @@ Herbalism.Ability.GTh=[[GREEN]]**POLLICE VERDE** Herbalism.Ability.HylianLuck=[[RED]]Probabilit\u00e0 di Fotruna Hylian: [[YELLOW]]{0} Herbalism.Ability.Lower=[[GRAY]]**ABBASSI LA ZAPPA** Herbalism.Ability.Ready=[[GREEN]]**PREPARI LA ZAPPA** +Herbalism.Ability.ShroomThumb.Chance=[[RED]]Possibilit\u00e0 di Pollice Fungo: [[YELLOW]]{0} +Herbalism.Ability.ShroomThumb.Fail=[[RED]]**POLLICE FUNGO FALLITO** Herbalism.Effect.0=TERRA VERDE (CAPACIT\u00c0) Herbalism.Effect.1=Diffonde il Verde, Drop x3 Herbalism.Effect.2=Pollice Verde (Grano) @@ -116,6 +117,8 @@ Herbalism.Effect.8=Doppi Drop (Ogni Pianta) Herbalism.Effect.9=Raddoppia il normale drop Herbalism.Effect.10=Fortuna Hylian Herbalism.Effect.11=D\u00e0 una modesta possibilit\u00e0 di trovare oggetti rari +Herbalism.Effect.12=Pollice Fungo +Herbalism.Effect.13=Diffonde il micelio su terra & erba Herbalism.HylianLuck=[[GREEN]]Oggi la fortuna di Hyrule \u00e8 con te! Herbalism.Listener=Erboristeria: Herbalism.SkillName=ERBORISTERIA @@ -152,14 +155,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] ha usato [[RED]]S Mining.Skills.SuperBreaker.Refresh=[[GREEN]]La tua capacit\u00e0 [[YELLOW]]Super Demolitore [[GREEN]]si \u00e8 rigenerata! Mining.Skillup=[[YELLOW]]L\'abilit\u00e0 Estrazione \u00e8 aumentata di {0}. Totale ({1}) Mining.Blast.Boom=[[GRAY]]**BOOM** -Mining.Blast.Effect.0=+35% minerali estratti -Mining.Blast.Effect.1=+40% minerali estratti -Mining.Blast.Effect.2=+45% minerali estratti, niente macerie -Mining.Blast.Effect.3=+50% minerali estratti, niente macerie -Mining.Blast.Effect.4=+55% minerali estratti, niente macerie, doppi drop. -Mining.Blast.Effect.5=+60% minerali estratti, niente macerie, doppi drop. -Mining.Blast.Effect.6=+65% minerali estratti, niente macerie, tripli drop. -Mining.Blast.Effect.7=+70% minerali estratti, niente macerie, tripli drop. Mining.Blast.Radius.Increase=[[RED]]Incremento del Raggio di Esplosione: [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]Estrazione Esplosiva: [[YELLOW]] Grado {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] ha usato [[RED]]Estrazione Esplosiva! @@ -249,6 +244,7 @@ Taming.Ability.Bonus.6=Artigli Affilati Taming.Ability.Bonus.7=+{0} al Danno Taming.Ability.Bonus.8=Servizio Fast Food Taming.Ability.Bonus.9={0}% Probabilit\u00e0 di guarire quando si attacca +Taming.Ability.Bonus.11=Recupera salute quando viene danneggiato da magia o veleno Taming.Ability.Locked.0=BLOCCATO FINO AD ABILIT\u00c0 {0}+ (SICUREZZA AMBIENTALE) Taming.Ability.Locked.1=BLOCCATO FINO AD ABILIT\u00c0 {0}+ (PELLICCIA FOLTA) Taming.Ability.Locked.2=BLOCCATO FINO AD ABILIT\u00c0 {0}+ (A PROVA D\'URTO) @@ -265,6 +261,7 @@ Taming.Effect.14=[[GRAY]]RDN (Ocelot): Chinati e clicca col sinistro con {0} Pes Taming.Effect.15=[[GRAY]]RDN (Lupo): Chinati e clicca col sinistro con {0} Ossi in mano Taming.Effect.16=Servizio Fast Food Taming.Effect.17=Probabilit\u00e0 che i lupi di guarire quando attaccano +Taming.Effect.19=Guarito da Magia & Veleno Taming.Effect.2=Sbranare Taming.Effect.3=Colpo Critico che applica Emorragia Taming.Effect.4=Artigli Affilati @@ -336,13 +333,11 @@ Combat.ArrowDeflect=[[WHITE]]**FRECCIA DEVIATA** Combat.BeastLore=[[GREEN]]**CONOSCENZA DELLE BESTIE** Combat.BeastLoreHealth=[[DARK_AQUA]]Salute ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Proprietario ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Sei stato colpito da una freccia infuocata! Combat.Gore=[[GREEN]]**SBRANATO** -Combat.Ignition=[[RED]]**ACCENSIONE** Combat.StruckByGore=[[RED]]**SEI STATO SBRANATO** Combat.TargetDazed=Il bersaglio \u00e8 rimasto [[DARK_RED]]Stordito Combat.TouchedFuzzy=[[DARK_RED]]Toccato sfocato. Feltro vertiginoso. -mcMMO.Description=[[DARK_AQUA]]Riguardo il progetto [[YELLOW]]mcMMO[[DARK_AQUA]]:,[[GOLD]]mcMMO \u00e8 una mod GdR [[RED]]open source[[GOLD]] creata nel Febbraio 2011,[[GOLD]]da [[BLUE]]nossr50[[GOLD]]. L\'obiettivo \u00e8 di fornire un\'esperienza GdR di qualit\u00e0.,[[DARK_AQUA]]Suggerimenti:,[[GOLD]] - [[GREEN]]Usa [[RED]]/mcmmo help[[GREEN]] per vedere i comandi,[[GOLD]] - [[GREEN]]Digita [[RED]]/NOMEABILIT\u00c0[[GREEN]] per vedere informazioni dettagliate sull\'abilit\u00e0,[[DARK_AQUA]]Sviluppatori:,[[GOLD]] - [[GREEN]]nossr50 [[BLUE]](Fondatore),[[GOLD]] - [[GREEN]]GJ [[BLUE]](Capo Progetto),[[GOLD]] - [[GREEN]]NuclearW [[BLUE]](Sviluppatore),[[GOLD]] - [[GREEN]]bm01 [[BLUE]](Sviluppatore),[[GOLD]] - [[GREEN]]TfT_02 [[BLUE]](Sviluppatore),[[GOLD]] - [[GREEN]]Glitchfinder [[BLUE]](Sviluppatore),[[GOLD]] - [[GREEN]]t00thpick1 [[BLUE]](Sviluppatore),[[DARK_AQUA]]Link Utili:,[[GOLD]] - [[GREEN]]https://github.com/mcMMO-Dev/mcMMO/issues[[GOLD]] Segnalazioni Bug,[[GOLD]] - [[GREEN]]#mcmmo @ irc.esper.net[[GOLD]] IRC Chat, +mcMMO.Description=[[DARK_AQUA]]Riguardo il [[DARK_AQUA]]Progetto [[YELLOW]]mcMMO:,[[GOLD]]mcMMO \u00e8 una mod GdR [[RED]]open source[[GOLD]] creata nel Febbraio 2011,[[GOLD]]da [[BLUE]]nossr50[[GOLD]]. L\'obiettivo \u00e8 quello di fornire un\'esperienza GdR di qualit\u00e0.,[[DARK_AQUA]]Suggerimenti:,[[GOLD]] - [[GREEN]]Usa [[RED]]/mcmmo help[[GREEN]] per vedere i comandi,[[GOLD]] - [[GREEN]]Digita [[RED]]/NOMEABILIT\u00c0[[GREEN]] per vedere informazioni dettagliate su un\'abilit\u00e0,[[DARK_AQUA]]Sviluppatori:,[[GOLD]] - [[GREEN]]nossr50 [[BLUE]](Fondatore),[[GOLD]] - [[GREEN]]GJ [[BLUE]](Capo Progetto),[[GOLD]] - [[GREEN]]NuclearW [[BLUE]](Sviluppatore),[[GOLD]] - [[GREEN]]bm01 [[BLUE]](Sviluppatore),[[GOLD]] - [[GREEN]]TfT_02 [[BLUE]](Sviluppatore),[[GOLD]] - [[GREEN]]Glitchfinder [[BLUE]](Sviluppatore),[[GOLD]] - [[GREEN]]t00thpick1 [[BLUE]](Sviluppatore),[[DARK_AQUA]]Link Utili:,[[GOLD]] - [[GREEN]]https://github.com/mcMMO-Dev/mcMMO/issues[[GOLD]] Segnalazione Bug,[[GOLD]] - [[GREEN]]#mcmmo @ irc.esper.net[[GOLD]] IRC Chat, Commands.addlevels.AwardAll.1=[[GREEN]]Ti sono stati aggiudicati {0} livelli in tutte le abilit\u00e0! Commands.addlevels.AwardAll.2=[[RED]]Tutte le abilit\u00e0 sono state modificate per {0}. Commands.addlevels.AwardSkill.1=[[GREEN]]Ti sono stati aggiudicati {0} livelli in {1}! @@ -385,6 +380,8 @@ Commands.mmoupdate.Start=[[GRAY]]Inizio conversione... Commands.mmoupdate.Finish=[[GREEN]]Conversione terminata! Commands.ModDescription=[[RED]]- Leggi una breve descrizione della mod Commands.NoConsole=Questo comando non supporta l\'uso da console. +Commands.Notifications.Off=Notifiche delle capacit\u00e0 [[RED]]disattivate +Commands.Notifications.On=Notifiche delle capacit\u00e0 [[GREEN]]attivate Commands.Offline=[[RED]]Questo comando non funziona per i giocatori offline. Commands.Other=[[GREEN]]--ALTRI COMANDI-- Commands.Party.Header=[[RED]]-----[][[GREEN]]COMPAGNIA[[RED]][]----- @@ -405,6 +402,7 @@ Commands.Party.Join=[[GRAY]]Ti sei unito alla compagnia: {0} Commands.Party.Create=[[GRAY]]Creata la Compagnia: {0} Commands.Party.Rename=[[GRAY]]Nome della compagnia cambiato in: [[WHITE]]{0} Commands.Party.SetSharing=[[GRAY]]Modalit\u00e0 spartizione della compagnia {0} impostata come: [[DARK_AQUA]]{1} +Commands.Party.ToggleShareCategory=[[GRAY]]La condivisione oggetti di compagnia di [[GOLD]]{0} [[GRAY]]\u00e8 stata [[DARK_AQUA]]{1} Commands.Party.AlreadyExists=[[DARK_RED]]La Compagnia {0} esiste gi\u00e0! Commands.Party.Kick=[[RED]]Sei stato sospeso dalla tua compagnia {0}! Commands.Party.Leave=[[RED]]Hai abbandonato quella compagnia @@ -419,6 +417,7 @@ Commands.Party2=[[RED]]- entra in una compagnia di giocatori Commands.ptp.Enabled=Teletrasporto di compagnia [[GREEN]]abilitato Commands.ptp.Disabled=Teletrasporto di compagnia [[GREEN]]disabilitato Commands.ptp.NoRequests=[[RED]]Non hai richieste di teletrasporto in questo momento +Commands.ptp.NoWorldPermissions=[[RED]][mcMMO] Non hai il permesso di teletrasportarti verso il mondo {0}. Commands.ptp.Request1=[[YELLOW]]{0} [[GREEN]]ha richiesto di teletrasportarsi da te. Commands.ptp.Request2=[[GREEN]]Per teletrasportarti, digita [[YELLOW]]/ptp accept. [[GREEN]]La richiesta scadr\u00e0 fra [[RED]]{0} [[GREEN]]secondi. Commands.ptp.AcceptAny.Enabled=Conferma delle richieste di teletrasporto di compagnia [[GREEN]]abilitata @@ -484,7 +483,6 @@ Party.Player.InSameParty=[[RED]]{0} \u00e8 gi\u00e0 nella tua compagnia! Party.PlayerNotInParty=[[DARK_RED]]{0} non \u00e8 in una compagnia Party.Specify=[[RED]]Devi specificare una compagnia. Party.Teleport.Dead=[[RED]]Non puoi teletrasportarti verso un giocatore morto. -Party.Teleport.Hurt=[[RED]]Sei stato ferito negli ultimi {0} secondi e non puoi teletrasportarti. Party.Teleport.Player=[[GREEN]]Ti sei teletrasportato da {0}. Party.Teleport.Self=[[RED]]Non puoi teletrasportarti verso te stesso! Party.Teleport.Target=[[GREEN]]{0} ti ha teletrasportato. @@ -608,6 +606,7 @@ Commands.Description.mcability=Attiva o disattiva il fatto che le capacit\u00e0 Commands.Description.mcgod=Attiva o Disattiva la modalit\u00e0 dio mcMMO Commands.Description.mchud=Cambia il tuo stile di HUD di mcMMO Commands.Description.mcmmo=Mostra una breve descrizione di mcMMO +Commands.Description.mcnotify=Attiva o disattiva le notifiche delle capacit\u00e0 di mcMMO nel display di chat Commands.Description.mcpurge=Elimina dal database mcMMO gli utenti senza livelli mcMMO e quelli che non si sono connessi negli ultimi {0} mesi. Commands.Description.mcrank=Mostra la graduatoria mcMMO di un giocatore Commands.Description.mcrefresh=Rigenera tutti i raffreddamenti di mcMMO @@ -624,3 +623,5 @@ Commands.Description.skillreset=Azzera i livelli mcMMO di un utente Commands.Description.vampirism=Modifica la percentuale di vampirismo mcMMO o attiva/disattiva la modalit\u00e0 vampirismo Commands.Description.xplock=Blocca la tua barra XP di mcMMO su una specifica abilit\u00e0 di mcMMO Commands.Description.xprate=Modifica il tasso XP di mcMMO o d\u00e0 inizio a un evento XP mcMMO. +UpdateChecker.outdated=Stai usando una versione sorpassata di mcMMO! +UpdateChecker.newavailable=\u00c8 disponibile una nuova versione su BukkitDev. diff --git a/src/main/resources/locale/locale_ko.properties b/src/main/resources/locale/locale_ko.properties index b70ba823c..81cd1e3b4 100644 --- a/src/main/resources/locale/locale_ko.properties +++ b/src/main/resources/locale/locale_ko.properties @@ -14,10 +14,12 @@ Axes.Skills.SS.Other.On=[[\ub179\uc0c9]] {0} [[\uc5b4\ub450\uc6b4 \ub179\uc0c9]] Axes.Skillup=[[YELLOW]]\ub3c4\ub07c \uae30\uc220\uc774 {0} \uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) Excavation.SkillName=\ubc1c\uad74 Fishing.ItemFound=[[GRAY]]\ubcf4\ubb3c\uc744 \ubc1c\uacac\ud588\uc2b5\ub2c8\ub2e4! +Herbalism.Ability.GTh=[[GREEN]]**\ucc98\uc138\uc220** Herbalism.Listener=\uc57d\ucd08\ud559 : Herbalism.Skills.GTe.Refresh=[[\ub179\uc0c9]] \ub2f9\uc2e0\uc758 [[\ub178\ub780\uc0c9]] \uadf8\ub9b0 \ud14c\ub77c [[\ub179\uc0c9]] \ub2a5\ub825\uc774 \uc0c8\ub85c \uace0\uccd0\uc9d1\ub2c8\ub2e4! Herbalism.Skills.GTe.Other.Off=[[\ub808\ub4dc]] \uadf8\ub9b0 \ud14c\ub77c [[\ub179\uc0c9]]\uc5d0 \ub300\ud55c \ud6a8\ub825\uc774 [[\ub178\ub780\uc0c9]] {0} Mining.Ability.Length=[[\ub808\ub4dc]] \uc288\ud37c \ucc28\ub2e8\uae30 \uae38\uc774 : [[\ub178\ub780\uc0c9]] {0} \ucd08 +Mining.Ability.Lower=[[GRAY]]**\ub2f9\uc2e0\uc758 \uace1\uad2d\uc774\uac00 \ub108\ubb34 \ubb34\uac81\uc2b5\ub2c8\ub2e4.** Mining.Ability.Ready=[[GREEN]]**\uace1\uad2d\uc774\ub97c \uc900\ube44\ud558\uc138\uc694.** Mining.Listener=\uad11\uc5c5: Mining.Skills.SuperBreaker.Refresh=[[GREEN]]\ub2f9\uc2e0\uc758 [[YELLOW]]\uc288\ud37c \ube0c\ub808\uc774\ucee4[[GREEN]] \ub2a5\ub825\uc774 \uc6d0\uc0c1\ubcf5\uadc0 \ub418\uc5c8\uc2b5\ub2c8\ub2e4! @@ -26,6 +28,8 @@ Mining.Blast.Radius.Increase=[[RED]]\ud3ed\ubc1c \ubc94\uc704 \uc99d\uac00\ub7c9 Mining.Blast.Refresh=[[GREEN]]\ub2f9\uc2e0\uc758 [[YELLOW]]\ubc1c\ud30c [[GREEN]]\ub2a5\ub825\uc774 \uc6d0\uc0c1\ubcf5\uadc0 \ub418\uc5c8\uc2b5\ub2c8\ub2e4! Repair.Effect.0=\uc218\ub9ac Repair.Effect.2=\uc218\ub9ac \ub9c8\uc2a4\ud130\ub9ac +Repair.Effect.5=\uc911\ubcf5 \ud6a8\uacfc +Repair.Effect.7=\ub2e4\uc774\uc544\ubaac\ub4dc \uc7a5\ube44 \uc218\ub9ac Repair.Effect.9=\ub9c8\ubc95 \ud56d\ubaa9\uc744 \ubcf5\uad6c Repair.Listener=\ubcf5\uad6c : Repair.SkillName=REPAIR @@ -45,6 +49,7 @@ Swords.Skills.SS.Other.Off=[[\ub808\ub4dc]] \ud1b1\ub2c8 \ubaa8\uc591\uc758 \uac Swords.Skills.SS.Other.On=[[\ub179\uc0c9]] {0} [[\uc5b4\ub450\uc6b4 \ub179\uc0c9]] \uc0ac\uc6a9\ud55c [[\ub808\ub4dc]] \ud1b1\ub2c8 \ubaa8\uc591\uc758 \uacbd\uace0! Taming.Ability.Bonus.2=\ub450\uaebc\uc6b4 \ubaa8\ud53c Taming.Listener.Wolf=[[\uc5b4\ub450\uc6b4 \ud68c\uc0c9]] \ub2e4\uc2dc\uc5d0 \ub300\ud55c \uadc0\ud558\uc758 \ub291\ub300 scurries ... +Taming.Skillup=[[YELLOW]]\uae38\ub4e4\uc774\uae30 \uae30\uc220 {0} \uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) Unarmed.Listener=\ubb34\uae30 : Unarmed.SkillName=\ube44\ubb34\uc7a5 Unarmed.Skills.Berserk.Off=[[RED]]**\ubc84\uc11c\ud06c \ud574\uc81c** @@ -68,6 +73,7 @@ Commands.DoesNotExist=[[RED]]\uc0ac\uc6a9\uc790\uac00 DB\uc5d0 \uc874\uc7ac\ud55 Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode \ube44\ud65c\uc131\ud654 Commands.Invite.Accepted=[[\ub179\uc0c9]] \uc811\uc218 \ucd08\ub300\ud569\ub2c8\ub2e4. \ub2f9\uc2e0\uc740 \ud30c\ud2f0\uc5d0 \uc744 (\ub97c) \uac00\uc785 {0} Commands.mmoedit=[\ud50c\ub808\uc774\uc5b4] [[RED]] - \ubaa9\ud45c\ub97c \uc218\uc815 +Commands.Party.Accept=[[RED]]- \ud30c\ud2f0 \ucd08\ub300 \uc218\ub77d Commands.Party.Invite.0=[[\uc801\uc0c9]] \uacbd\uace0 : [[\ub179\uc0c9]] \ub2f9\uc2e0\uc740 \ub098\uc5d0\uac8c \ud30c\ud2f0 \ucd08\ub300\ub97c\ubc1b\uc740 {0}\uc5d0\uc11c {1} Commands.Party.Kick=[[\ub808\ub4dc]] \ub2f9\uc2e0\uc740 \uc790 {0}\uc5d0\uc11c \ucad3\uaca8\ub418\uc5c8\uc2b5\ub2c8\ub2e4! Commands.Party.Leave=[[\ub808\ub4dc]] \ub2f9\uc2e0\uc774 \ub0a8\uaca8 \ub450\uc5c8\ub358 \uadf8 \ub2f9\uc0ac\uc790 diff --git a/src/main/resources/locale/locale_nl.properties b/src/main/resources/locale/locale_nl.properties index c8f477fcc..cdf129908 100644 --- a/src/main/resources/locale/locale_nl.properties +++ b/src/main/resources/locale/locale_nl.properties @@ -1,23 +1,56 @@ Acrobatics.Combat.Proc=[[GREEN]]**Ontweken** +Acrobatics.Effect.0=Rollen +Acrobatics.Effect.4=Ontwijken +Acrobatics.Listener=Acrobatiek Acrobatics.SkillName=ACROBATIEK Acrobatics.Skillup=[[YELLOW]]Acrobatiek toegenomen met {0}. Totaal ({1}) +Archery.Effect.0=Ervaringsschot +Archery.Effect.1=Neemt de schade van bogen toe +Archery.Effect.2=Verdoven (Spelers) +Archery.Effect.5=Kans om pijlen te krijgen van lijken +Archery.Listener=Boogschieten: +Archery.SkillName=BOOGSCHIETEN Archery.Skillup=[[YELLOW]] Boogschieten ervaring toegenomen met {0}. Totaal ({1}) +Axes.Ability.Bonus.0=Bijl Meesterschap +Axes.Combat.CritStruck=[[DARK_RED]]Je bent KRITISCH geraakt Axes.Combat.GI.Struck=[[RED]]**GETROFFEN MET MEER SCHADE** +Axes.Combat.SS.Length=[[RED]]Schedel Splijter Lengte: [[YELLOW]]{0}s +Axes.Effect.3=Verdubbelde Schade +Axes.Effect.5=Voegt DMG bonus toe +Axes.SkillName=BIJLEN Axes.Skills.SS.On=[[GREEN]]**SCHEDEL SPLIJTER GEACTIVEERD** Axes.Skills.SS.Refresh=[[GREEN]]Jou [[YELLOW]]Schedel Splijten [[GREEN]]kracht is hersteld! Axes.Skills.SS.Other.On=[[GREEN]]{0}[[DARK_GREEN]] heeft [[RED]]Schedel Splijter[[DARK_GREEN]]gebruikt! +Axes.Skillup=[[YELLOW]]Bijl ervaring toegenomen met {0}. Totaal ({1}) +Excavation.Effect.2=Schatten Jager +Excavation.Listener=Uitgraving: Excavation.SkillName=Uitgraving +Excavation.Skills.GigaDrillBreaker.On=[[GREEN]]**GIGA DRILL BREKER GEACTIVEERD** +Excavation.Skillup=[[YELLOW]]Uitgravings ervaring toegenomen met {0}. Totaal ({1}) +Fishing.Chance.Raining=[[BLUE]] Regen Bonus Fishing.ItemFound=[[GRAY]]Schat gevonden! Fishing.Listener=Vissen: Fishing.MagicFound=[[GRAY]]Jij voelt een vleugje magie met deze vangst... +Herbalism.Ability.GTh=[[GREEN]]**GROEN DUIMPJE** Herbalism.Listener=Kruidenkunde: Herbalism.Skills.GTe.Refresh=[[GREEN]]Jou [[YELLOW]]groene Vingers [[GREEN]]kracht is hersteld! Herbalism.Skills.GTe.Other.Off=[[RED]]Groene vingers[[GREEN]] is uitgewerkt voor [[YELLOW]]{0} +Herbalism.Skills.GTe.Other.On=[[GREEN]]{0}[[DARK_GREEN]]heeft[[RED]]Groene Aarde[[DARK_GREEN]]gebruikt! Mining.Ability.Length=[[RED]]Super BrekerLengte: [[YELLOW]]{0}s Mining.Ability.Ready=[[GREEN]]**JE HOUDT JE PIKHOUWEEL GEREED** +Mining.Listener=Mijnbouw: +Mining.Skills.SuperBreaker.Other.Off=[[RED]] Super Breker[[GREEN]] is uitgewerkt voor [[YELLOW]]{0} Mining.Skills.SuperBreaker.Refresh=[[GREEN]]Jou[[YELLOW]]Super Breek[[GREEN]]kracht is hersteld! Mining.Skillup=[[YELLOW]]Mijn ervaring toegenomen met {0}. Totaal: ({1}) Mining.Blast.Refresh=[[GREEN]]Jou[[YELLOW]]explosie mijn [[GREEN]]kracht is hersteld! +Repair.Effect.0=Repareren +Repair.Effect.2=Reparatie Meesterschap +Repair.Effect.3=Toegenomen reparatie aantal +Repair.Effect.4=Super Reparatie +Repair.Effect.5=Verdubbelde effectiefheid +Repair.Effect.6=Diamanten Reparatie ({0}+ SKILL) +Repair.Effect.7=Repareer Diamanten Gereedschap & Wapenuitrusting +Repair.Effect.8=Arcane Smeden Repair.Effect.9=Magische voorwerpen repareren Repair.Listener.Anvil=[[DARK.RED]]Je hebt een aambeeld geplaatst, met een aambeeld kun je je gereedschappen en pantser mee repareren Repair.Listener=Repareer: @@ -27,12 +60,19 @@ Repair.Skills.AdeptGold=[[DARK_RED]]Je bent niet goed genoeg om goud te reparere Repair.Skills.AdeptStone=[[DARK_RED]]Je bent nog niet sterk genoeg om steen te repareren. Repair.Skills.FeltEasy=[[GRAY]]Dat voelde makkelijk. Repair.Skillup=[[YELLOW]]Repareer ervaring toegenomen met {0}. Totaal: ({1}) +Repair.Arcane.Chance.Downgrade=[[GRAY]]AF Downgrade Kans: [[YELLOW]]{0}% Repair.Arcane.Chance.Success=[[GRAY]] Mystiek Smeden Succes Percentage: [[YELLOW]]{0}% Repair.Arcane.Fail=[[RED]]Mysterieuze kracht heeft het voorwerp voorgoed verlaten. +Repair.Arcane.Lost=[[RED]]Je hebt niet genoeg ervaring om de betoveringen te behouden Swords.Ability.Ready=[[GREEN]]**JIJ HOUD JOU WAPEN GEREED** Swords.Combat.Bleeding.Stopped=[[GRAY]]Het bloeden is [[GREEN]]Gestopt[[GRAY]]! Swords.Combat.Bleeding=[[GREEN]]**VIJAND BLOED** +Swords.Combat.Counter.Hit=[[DARK_RED]]Geraakt door een tegenaanval Swords.Combat.Countered=[[GREEN]]**TEGEN-AANVAL** +Swords.Combat.SS.Struck=[[DARK_RED]]Geraakt door GEKARTELDE SLAG! +Swords.Effect.2=Gekartelde Slag (Vermogen) +Swords.Effect.4=Gekartelde Slag Bloed+ +Swords.Effect.6=Bloeden Swords.Listener=Zwaarden: Swords.SkillName=ZWAARDEN Swords.Skills.SS.On=[[GREEN]]**GEKARTELDE SLAG GEACTIVEERD** @@ -40,6 +80,19 @@ Swords.Skills.SS.Other.Off=[[RED]]Gekartelde Slag[[GREEN]] is uitgewerkt voor [[ Swords.Skills.SS.Other.On=[[GREEN]]{0}[[DARK_GREEN]] heeft [[RED]]Gekartelde Slag[[DARK_GREEN]]gebruikt! Swords.Skillup=[[YELLOW]]Zwaarden ervaring toegenomen met {0}. Totaal: ({1}) Taming.Ability.Bonus.2=Dikke Vacht +Taming.Ability.Bonus.7=+{0} Schade +Taming.Effect.10=Schokbestendig +Taming.Effect.11=Explosieve Schade Verkleining +Taming.Effect.12=Roep van het WIld +Taming.Effect.13=Roep een dier aan je zijde op +Taming.Effect.14=[[GRAY]]COTW (Ocelot): Buk en linkermuisknop met {0} Vis in je hand +Taming.Effect.15=[[GRAY]]COTW (Wolf): Buk en linkermuisknop met {0} Botten in je hand +Taming.Effect.16=Fast Food Service +Taming.Effect.17=Kans voor wolven na een aanval te regeneren +Taming.Listener.Wolf=[[DARK_GRAY]]Jouw wolf dribbelt terug naar je... +Taming.Listener=Temming: +Taming.Skillup=[[YELLOW]]Temmings ervaring toegenomen met {0}. Totaal ({1}) +Taming.Summon.Complete=[[GREEN]]Oproepen voltooid Unarmed.Ability.Berserk.Length=[[RED]]Razernij Lengte: [[YELLOW]]{0}s Unarmed.Effect.0=Razernij (KRACHT) Unarmed.Listener=Ongewapend: @@ -51,9 +104,10 @@ Unarmed.Skills.Berserk.Refresh=[[GREEN]]Jou[[YELLOW]]Razernij [[GREEN]]kracht is Woodcutting.Ability.0=Bladblazer Woodcutting.Ability.1=Bladeren wegblazen Woodcutting.Effect.2=Bladblazer -Woodcutting.Listener=Houthakken +Woodcutting.Listener=Houthakken: Woodcutting.SkillName=Houthakken Woodcutting.Skills.TreeFeller.Other.Off=[[RED]]Boom Veller[[GREEN]] is uitgewerkt voor [[YELLOW]]{0} +Woodcutting.Skills.TreeFeller.Other.On=[[GREEN]]{0}[[DARK)GREEN]]heeft[[RED]]Tree Feller[[DARK_GREEN]]gebruikt! Woodcutting.Skills.TreeFeller.Splinter=[[RED]]JOU BIJL SPLINTERT IN DUIZENDEN STUKJES! Woodcutting.Skillup=[[YELLOW]]Houthakken toegenomen met {0}. Totaal ({1}) Ability.Generic.Template.Lock=[[GRAY]]{0} @@ -62,18 +116,21 @@ Combat.ArrowDeflect=[[WHITE]]**PIJL AFWIJKING** Combat.BeastLore=[[GREEN]]**WOLFINSPECTIE** Combat.BeastLoreHealth=[[DARK_AQUA]]Levens ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Eigenaar ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Je bent geraakt door een brandende pijl\\! Combat.Gore=[[GREEN]]**GESTOLD BLOED** -Combat.Ignition=[[RED]]**ONTSTEKING** Combat.StruckByGore=[[RED]]**VAST DOOR GESTOLD BLOED** Combat.TargetDazed=Doelwit was [[DARK_RED]]versuft Combat.TouchedFuzzy=[[DARK_RED]]Je raakte Fuzzy aan. Je voelt je duizelig. Commands.AdminChat.Off=Alleen Admin gesprek[[RED]]Uit +Commands.AdminToggle=[[RED]]- Zet Admin Chat aan/uit Commands.Disabled=[[RED]]Deze opdracht is gedeactiveerd. Commands.DoesNotExist=[[RED]]Speler bestaat niet in de database! +Commands.GodMode.Disabled=[[YELLOW]]mcMMO GodModus Uitgeschakeld Commands.Invite.Accepted=[[GREEN]]Uitnodiging geacepteerd. Jij hebt de groep {0} betreden +Commands.mcgod=[[RED]]- GodModus Schakelen Commands.mcrank.Player=[[RED]]DOELWIT: [[WHITE]]{0} Commands.mmoedit=[player] [[RED]] - Pas doel aan +Commands.mmoupdate.Start=[[GRAY]]Beginnen met converteren... +Commands.ModDescription=[[RED]]- Lees instructie mod beschrijving Commands.NoConsole=Deze commando wordt niet ondersteund vanuit de console. Commands.Party.ShareMode=[[DARK_GRAY]]DEEL MODUS: Commands.Party.Accept=[[RED]]- Accepteer groep uitnodiging @@ -81,22 +138,30 @@ Commands.Party.Chat.Off=Groep\'s Chat [[RED]]Uit Commands.Party.Chat.On=Groep\'s Chat [[GREEN]]Aan Commands.Party.Commands=[[GREEN]]--GROEP COMMANDOS-- Commands.Party.Invite.0=[[RED]]ALERT: [[GREEN]]Jij hebt een groep uitnodiging ontvangen voor {0} van {1} +Commands.Party.Invite=[[RED]]- Verstuur groepsuitnodiging Commands.Party.Create=[[GRAY]]Groep aangemaakt: {0} Commands.Party.Rename=[[GRAY]]Groep\'s naan veranderd naar: [[WHITE]]{0} Commands.Party.AlreadyExists=[[DARK_RED]]Groep {0} bestaat al! Commands.Party.Kick=[[RED]]Je bent verwijderd uit de groep {0}! Commands.Party.Leave=[[RED]]Je hebt de groep verlaten +Commands.Party.Members.Header=[[RED]]-----[][[GREEN]]LEDEN[[RED]][]----- +Commands.Party.Members={0} Commands.Party.None=[[RED]]Je bent niet in een groep. Commands.Party.Quit=[[RED]]- Verlaat je huidige groep Commands.Party.Teleport= [[RED]]- Teleport naar een groepslid Commands.Party.Toggle=[[RED]]- Zet Party Chat aan/uit +Commands.Party1=[[RED]]- Maak een nieuwe groep Commands.ptp.RequestExpired=[[RED]]Groep\'s teleport verzoek is verlopen! Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Kracht Level [[YELLOW]]Leiderbord-- Commands.PowerLevel=[[DARK_RED]]KRACHT LEVEL: [[GREEN]]{0} Commands.Usage.Level=niveau Commands.Usage.Message=bericht +Commands.Usage.PartyName=naam Commands.Usage.Password=wachtwoord +Commands.Usage.XP=xp +mcMMO.NoSkillNote=[[DARK_GRAY]]als je geen toegang hebt tot een vermogen, wordt die hier niet getoont Party.Forbidden=[mcMMO] Groepen niet toegestaan op deze wereld (zie Machtigingen) +Party.InformedOnQuit={0} [[GREEN]]heeft de groep verlaten Party.InvalidName=[[DARK_RED]]Dat is geen geldige groep\'s naam. Party.IsLocked=[[RED]]Deze groep is al gesloten! Party.IsntLocked=[[RED]]Deze groep is niet gesloten! @@ -109,24 +174,37 @@ Party.Owner.Player=[[GREEN]]Jij bent nu de groep eigenaar. Party.Password.None=[[RED]]Deze groep is vergrendeld met een wachtwoord. Voer het wachtwoord in om in deze groep te komen. Party.Password.Incorrect=[[RED]]Groeps- wachtwoord is incorrect. Party.Password.Set=[[GREEN]]Groep wachtwoord veranderd in {0} +Party.Password.Removed=[[GREEN]]Groepswachtwoord is verwijderd. +Party.Player.Invalid=[[RED]]Dat is geen geldige speler. +Party.NotOnline=[[DARK_RED]]{0} is niet online! Party.Player.InSameParty=[[RED]]{0} zit al in uw groep! Party.PlayerNotInParty=[[DARK_RED]]{0} zit niet in een groep Party.Specify=[[RED]]Je moet een groep invullen. +Party.Teleport.Dead=[RED]Je kan niet naar een dode speler teleporteren. Party.Teleport.Target=[[GREEN]]{0} is naar jou toe gedeporteerd. +Party.Teleport.Disabled=[[RED]]{0} staat groeps-teleportaties niet toe. +Party.Join.Self=[[RED]]Je kan niet meedoen met jezelf! Party.Unlocked=[[GRAY]]Groep is ontgrendeld +Party.Status.Unlocked=[[DARK_GREEN]](OPEN) +Party.ShareMode.None=NIKS Party.ShareMode.Equal=GELIJK Party.ShareMode.Random=WILLEKEURIG +Party.ExpShare.Disabled=[[RED]]Groep experience delen in uitgeschakeld. +Party.ItemShare.Disabled=[[RED]]Groeps item delen is uitgezet. +Commands.XPGain.Acrobatics=Vallen Commands.XPGain.Axes=Monsters aanvallen Commands.XPGain.Excavation=Graven en schatten vinden Commands.XPGain.Fishing=Vissen (Wat denk je zelf?) Commands.XPGain.Herbalism=Kruiden Verzamelen Commands.XPGain.Mining=Het Mijnen van Steen & Erts +Commands.XPGain.Repair=Repareren Commands.XPGain.Swords=Monsters aanvallen Commands.XPGain.Taming=Dieren Temmen, of vechten met je wolven Commands.XPGain=[[DARK_GRAY]]XP GEWONNEN: [[WHITE]]{0} Commands.xplock.locked=[[GOLD]]Jou XP BALK is nu bevroren op {0}! Commands.xplock.unlocked=[[GOLD]]Jou XP BALK is nu[[GREEN]]ONTGRENDELD[[GOLD]]! Commands.xprate.over=[[RED]]mcMMO XP Verdubbeling Evenement is VOORBIJ!! +Commands.xprate.proper.0=[[RED]]Juiste gebruiking om de XP snelheid te veranderen is /xprate XPRate.Event=[[GOLD]]mcMMO is momenteel in een XP verdubbeling evenement! XP verdubbeling is {0}x! Effects.Effects=EFFECTEN Guides.Axes=Guide coming soon... @@ -135,8 +213,12 @@ Guides.Mining=[[DARK_AQUA]]About Mining:\n[[YELLOW]]Mining consists of mining st Inspect.OfflineStats=mcMMO statistieken voor offline-speler [[YELLOW]]{0} Inspect.Stats=[[GREEN]]mcMMO Statistieken voor [[YELLOW]]{0} Inspect.TooFar=[[RED]]Jij bent te ver weg om deze speler te inspecteren! +Item.ChimaeraWing.Pass=**CHIMAERA VLEUGEL** +Item.Injured.Wait=Je bent recent gewond geraakt en je moet wachter om dit te gebruiken. [[YELLOW]]({0}s) Skills.Disarmed=[[DARK_RED]]Je bent ontwapend! Skills.NeedMore=[[DARK_RED]]Jij hebt te weinig [[GRAY]]{0} Skills.TooTired=[[RED]]Jij bent te moe om die kracht opnieuw te gebruiken. [[YELLOW]]({0}s) Stats.Header.Combat=[[GOLD]]-=Strijd Ervaring=- Stats.Header.Gathering=[[GOLD]]-=VERZAMELAAR VAARDIGHEDEN=- +Stats.Header.Misc=[[GOLD]]-=MISC ERVARING=- +Stats.Own.Stats=[[GREEN]][mcMMO] Stats diff --git a/src/main/resources/locale/locale_pl.properties b/src/main/resources/locale/locale_pl.properties index 091b71c43..97d4ce482 100644 --- a/src/main/resources/locale/locale_pl.properties +++ b/src/main/resources/locale/locale_pl.properties @@ -79,9 +79,7 @@ Combat.ArrowDeflect=[[WHITE]]**ODBICIE STRZALY** Combat.BeastLore=[[GREEN]]**WIEDZA O ZWIERZETACH** Combat.BeastLoreHealth=[[DARK_AQUA]]Zycie ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Wlasciciel ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Zostales trafiony plonaca strzala\\! Combat.Gore=[[GREEN]]**KRWOTOK** -Combat.Ignition=[[RED]]**PODPALENIE** Combat.StruckByGore=[[RED]]**WYKRWAWIENIE** Combat.TargetDazed=Cel zostal [[DARK_RED]]oszolomiony. Combat.TouchedFuzzy=[[DARK_RED]]Zostales oszolomiony. @@ -134,7 +132,6 @@ Guides.Smelting=Wkrotce... Inspect.OfflineStats=mcMMO Stats for Offline Player [[YELLOW]]{0} Inspect.Stats=[[GREEN]]mcMMO Stats for [[YELLOW]]{0} Inspect.TooFar=[[RED]]You are too far away to inspect that player! -Item.ChimaeraWing.Fail=**CHIMAERA WING FAILED!** Item.ChimaeraWing.Pass=**SKRZYD\u0141O CHIMERY** Skills.Disarmed=[[DARK_RED]]Zostales rozbrojony! Skills.NeedMore=[[DARK_RED]]Potrzebujesz wiecej diff --git a/src/main/resources/locale/locale_pt_BR.properties b/src/main/resources/locale/locale_pt_BR.properties index d7baa494e..7c95899de 100644 --- a/src/main/resources/locale/locale_pt_BR.properties +++ b/src/main/resources/locale/locale_pt_BR.properties @@ -10,9 +10,7 @@ Combat.ArrowDeflect=[[WHITE]]*DESVIOU A FLECHA* Combat.BeastLore=[[GREEN]]*CONHECIMENTO DE FERAS* Combat.BeastLoreHealth=[[DARK_AQUA]]Health ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]Dono ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]Voc\u00ea foi atingido por uma flecha flamejante\\! Combat.Gore=[[GREEN]]*MORDIDA* -Combat.Ignition=[[RED]]*IGNI\u00c7AO* Combat.StruckByGore=[[RED]]*ATINGIDO POR MORDIDA* Combat.TargetDazed=Alvo foi [[DARK_RED]]Atordoado Combat.TouchedFuzzy=[[DARK_RED]]Visao turva. Sente Tonturas. diff --git a/src/main/resources/locale/locale_ru.properties b/src/main/resources/locale/locale_ru.properties index e60515ad3..c5442e453 100644 --- a/src/main/resources/locale/locale_ru.properties +++ b/src/main/resources/locale/locale_ru.properties @@ -33,7 +33,6 @@ Axes.Ability.Bonus.4=\u0412\u0435\u043b\u0438\u043a\u0438\u0439 \u0423\u0434\u04 Axes.Ability.Bonus.5=\u041d\u0430\u043d\u043e\u0441\u0438\u0442 {0} \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0423\u0440\u043e\u043d\u0430 \u0431\u0435\u0437\u043e\u0440\u0443\u0436\u043d\u044b\u043c \u0432\u0440\u0430\u0433\u0430\u043c Axes.Ability.Lower=[[GREEN]]**\u0422\u041e\u041f\u041e\u0420 \u0412 \u041e\u0411\u042b\u0427\u041d\u041e\u041c \u0421\u041e\u0421\u0422\u041e\u042f\u041d\u0418\u0418** Axes.Ability.Ready=[[GREEN]]**\u0422\u041e\u041f\u041e\u0420 \u0412 \u0421\u041e\u0421\u0422\u041e\u042f\u041d\u0418\u0418 \u0413\u041e\u0422\u041e\u0412\u041d\u041e\u0421\u0422\u0418** -Axes.Combat.Cleave.Proc=[[DARK_RED]]\u041f\u043e\u0440\u0430\u0436\u0435\u043d \u0421\u041f\u041b\u042d\u0428 \u0423\u0414\u0410\u0420\u041e\u041c! Axes.Combat.CritStruck=[[DARK_RED]]\u0412\u0430\u043c \u043d\u0430\u043d\u0435\u0441\u0435\u043d\u043e \u041a\u0420\u0418\u0422\u0418\u0427\u0415\u0421\u041a\u041e\u0415 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435! Axes.Combat.CritChance=[[RED]]\u0428\u0430\u043d\u0441 \u043d\u0430\u043d\u0435\u0441\u0442\u0438 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u0434\u0430\u0440: [[YELLOW]]{0}% Axes.Combat.CriticalHit=[[RED]]\u041a\u0420\u0418\u0422\u0418\u0427\u0415\u0421\u041a\u0418\u0419 \u0423\u0414\u0410\u0420! @@ -122,7 +121,7 @@ Herbalism.SkillName=\u0422\u0420\u0410\u0412\u041d\u0418\u0427\u0415\u0421\u0422 Herbalism.Skills.GTe.Off=[[RED]]**\u0423\u043c\u0435\u043d\u0438\u0435 \"\u041e\u0437\u0435\u043b\u0435\u043d\u0435\u043d\u0438\u0435\" \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435** Herbalism.Skills.GTe.On=[[GREEN]]**\u0423\u043c\u0435\u043d\u0438\u0435 \"\u041e\u0437\u0435\u043b\u0435\u043d\u0435\u043d\u0438\u0435\" \u0410\u041a\u0422\u0418\u0412\u0418\u0420\u041e\u0412\u0410\u041d\u041e** Herbalism.Skills.GTe.Refresh=[[GREEN]]\u0412\u0430\u0448\u0435 \u0443\u043c\u0435\u043d\u0438\u0435 [[YELLOW]]\"\u041e\u0437\u0435\u043b\u0435\u043d\u0435\u043d\u0438\u0435\" [[GREEN]]\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e! -Herbalism.Skills.GTe.Other.Off=[[RED]]\u0423\u043c\u0435\u043d\u0438\u0435 \"\u041e\u0437\u0435\u043b\u0435\u043d\u0435\u043d\u0438\u0435\"[[GREEN]] \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0443 [[YELLOW]]{0} +Herbalism.Skills.GTe.Other.Off=[[GREEN]] \u0423\u043c\u0435\u043d\u0438\u0435 \"[[RED]]\u041e\u0437\u0435\u043b\u0435\u043d\u0435\u043d\u0438\u0435[[GREEN]] \" \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0443 [[YELLOW]]{0} Herbalism.Skills.GTe.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0443\u043c\u0435\u043d\u0438\u0435 [[RED]] \"\u041e\u0437\u0435\u043b\u0435\u043d\u0435\u043d\u0438\u0435\"! Herbalism.Skillup=[[YELLOW]]\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0430\u0432\u044b\u043a\u0430 \"\u0422\u0440\u0430\u0432\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\" \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d \u043d\u0430 {0}. \u0412\u0441\u0435\u0433\u043e ({1}) Mining.Ability.Length=[[RED]]\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u043c\u0435\u043d\u0438\u044f \"\u0421\u0443\u043f\u0435\u0440 \u0414\u0440\u043e\u0431\u0438\u043b\u043a\u0430\": [[YELLOW]]{0}\u0441. @@ -152,14 +151,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u0438\u0441\u043 Mining.Skills.SuperBreaker.Refresh=[[GREEN]]\u0412\u0430\u0448\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c [[YELLOW]]\u041a\u043e\u043f\u0430\u0442\u0435\u043b\u044c [[GREEN]]\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430! Mining.Skillup=[[YELLOW]]\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0430\u0432\u044b\u043a\u0430 \"\u0428\u0430\u0445\u0442\u0451\u0440\u0441\u0442\u0432\u043e\" \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d \u043d\u0430 {0}. \u0412\u0441\u0435\u0433\u043e ({1}) Mining.Blast.Boom=[[GRAY]]**\u0411\u0423\u041c** -Mining.Blast.Effect.0=+35% \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u0440\u0443\u0434 -Mining.Blast.Effect.1=+40% \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u0440\u0443\u0434 -Mining.Blast.Effect.2=+45% \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u0440\u0443\u0434, \u0431\u0435\u0437 \u043c\u0443\u0441\u043e\u0440\u0430 -Mining.Blast.Effect.3=+50% \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u0440\u0443\u0434, \u0431\u0435\u0437 \u043c\u0443\u0441\u043e\u0440\u0430 -Mining.Blast.Effect.4=+55% \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u0440\u0443\u0434, \u0431\u0435\u0437 \u043c\u0443\u0441\u043e\u0440\u0430, \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0434\u0440\u043e\u043f -Mining.Blast.Effect.5=+60% \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u0440\u0443\u0434, \u0431\u0435\u0437 \u043c\u0443\u0441\u043e\u0440\u0430, \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0434\u0440\u043e\u043f -Mining.Blast.Effect.6=+65% \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u0440\u0443\u0434, \u0431\u0435\u0437 \u043c\u0443\u0441\u043e\u0440\u0430, \u0442\u0440\u043e\u0439\u043d\u043e\u0439 \u0434\u0440\u043e\u043f -Mining.Blast.Effect.7=+70% \u0434\u043e\u0445\u043e\u0434 \u043e\u0442 \u0440\u0443\u0434, \u0431\u0435\u0437 \u043c\u0443\u0441\u043e\u0440\u0430, \u0442\u0440\u043e\u0439\u043d\u043e\u0439 \u0434\u0440\u043e\u043f Mining.Blast.Radius.Increase=[[RED]]\u0420\u0430\u0434\u0438\u0443\u0441 \u0412\u0437\u0440\u044b\u0432\u0430 \u0423\u0432\u0435\u043b\u0438\u0447\u0435\u043d: [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]\u041f\u043e\u0434\u0440\u044b\u0432\u043d\u0430\u044f \u0414\u043e\u0431\u044b\u0447\u0430: [[YELLOW]] \u0420\u0430\u043d\u0433 {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0443\u043c\u0435\u043d\u0438\u0435 [[RED]]\"\u041f\u043e\u0434\u0440\u044b\u0432\u043d\u0430\u044f \u0414\u043e\u0431\u044b\u0447\u0430\"! @@ -235,7 +226,7 @@ Swords.SkillName=\u0412\u043b\u0430\u0434\u0435\u043d\u0438\u0435 \u041c\u0435\u Swords.Skills.SS.Off=[[RED]]**\u0423\u043c\u0435\u043d\u0438\u0435 \"\u0420\u0435\u0436\u0443\u0449\u0438\u0439 \u0443\u0434\u0430\u0440\" \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435** Swords.Skills.SS.On=[[GREEN]]**\u0423\u043c\u0435\u043d\u0438\u0435 \"\u0420\u0435\u0436\u0443\u0449\u0438\u0439 \u0443\u0434\u0430\u0440\" \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u043e** Swords.Skills.SS.Refresh=[[GREEN]]\u0412\u0430\u0448\u0435 \u0443\u043c\u0435\u043d\u0438\u0435 [[YELLOW]]\"\u0420\u0435\u0436\u0443\u0449\u0438\u0439 \u0423\u0434\u0430\u0440\" [[GREEN]]\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e! -Swords.Skills.SS.Other.Off=[[RED]]\u0423\u043c\u0435\u043d\u0438\u0435 \"\u0420\u0435\u0436\u0443\u0449\u0438\u0439 \u0443\u0434\u0430\u0440\"[[GREEN]] \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0443 [[YELLOW]]{0} +Swords.Skills.SS.Other.Off=[[GREEN]]\u0423\u043c\u0435\u043d\u0438\u0435 \"[[RED]]\u0420\u0435\u0436\u0443\u0449\u0438\u0439 \u0443\u0434\u0430\u0440[[GREEN]]\" \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0443 [[YELLOW]]{0} Swords.Skills.SS.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0443\u043c\u0435\u043d\u0438\u0435 [[RED]]\"\u0420\u0435\u0436\u0443\u0449\u0438\u0439 \u0423\u0434\u0430\u0440\"! Swords.Skillup=[[YELLOW]]\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0430\u0432\u044b\u043a\u0430 \"\u0412\u043b\u0430\u0434\u0435\u043d\u0438\u0435 \u041c\u0435\u0447\u0435\u043c\" \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d \u043d\u0430 {0}. \u0412\u0441\u0435\u0433\u043e ({1}) Swords.SS.Length=[[RED]]\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u043c\u0435\u043d\u0438\u044f \"\u0420\u0435\u0436\u0443\u0449\u0438\u0439 \u0423\u0434\u0430\u0440\": [[YELLOW]]{0}\u0441. @@ -249,6 +240,7 @@ Taming.Ability.Bonus.6=\u041e\u0441\u0442\u0440\u044b\u0435 \u041a\u043e\u0433\u Taming.Ability.Bonus.7=+{0} \u0423\u0440\u043e\u043d\u0430 Taming.Ability.Bonus.8=\u0411\u044b\u0441\u0442\u0440\u043e\u0435 \u041f\u0438\u0442\u0430\u043d\u0438\u0435 Taming.Ability.Bonus.9={0}% \u0428\u0430\u043d\u0441 \u0432\u044b\u043b\u0435\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0430\u0442\u0430\u043a\u0435 +Taming.Ability.Bonus.10=\u0421\u0432\u044f\u0442\u043e\u0439 \u041f\u0435\u0441 Taming.Ability.Locked.0=\u0417\u0410\u0411\u041b\u041e\u041a\u0418\u0420\u041e\u0412\u0410\u041d\u041e \u0414\u041e \u0414\u041e\u0421\u0422\u0418\u0416\u0415\u041d\u0418\u042f {0}+ \u0423\u0420\u041e\u0412\u041d\u042f \u041d\u0410\u0412\u042b\u041a\u0410 (\u042d\u041a\u041e\u041b\u041e\u0413\u0418\u0427\u0415\u0421\u041a\u041e\u0415 \u0421\u041e\u0417\u041d\u0410\u041d\u0418\u0415) Taming.Ability.Locked.1=\u0417\u0410\u0411\u041b\u041e\u041a\u0418\u0420\u041e\u0412\u0410\u041d\u041e \u0414\u041e \u0414\u041e\u0421\u0422\u0418\u0416\u0415\u041d\u0418\u042f {0}+ \u0423\u0420\u041e\u0412\u041d\u042f \u041d\u0410\u0412\u042b\u041a\u0410 (\u0413\u0423\u0421\u0422\u041e\u0419 \u041c\u0415\u0425) Taming.Ability.Locked.2=\u0417\u0410\u0411\u041b\u041e\u041a\u0418\u0420\u041e\u0412\u0410\u041d\u041e \u0414\u041e \u0414\u041e\u0421\u0422\u0418\u0416\u0415\u041d\u0418\u042f {0}+ \u0423\u0420\u041e\u0412\u041d\u042f \u041d\u0410\u0412\u042b\u041a\u0410 (\u0417\u0410\u0429\u0418\u0422\u0410 \u041e\u0422 \u0428\u041e\u041a\u0410) @@ -265,6 +257,8 @@ Taming.Effect.14=[[GRAY]]COTW (\u041e\u0446\u0435\u043b\u043e\u0442): \u041f\u04 Taming.Effect.15=[[GRAY]]COTW (\u0412\u043e\u043b\u043a): \u041f\u0440\u0438\u0441\u044f\u0434\u044c\u0442\u0435 \u0438 \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043b\u0435\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u0441 {0} \u041a\u043e\u0441\u0442\u044c\u044e \u0432 \u0440\u0443\u043a\u0435 Taming.Effect.16=\u0411\u044b\u0441\u0442\u0440\u043e\u0435 \u041f\u0438\u0442\u0430\u043d\u0438\u0435 Taming.Effect.17=\u0423 \u0432\u043e\u043b\u043a\u043e\u0432 \u0435\u0441\u0442\u044c \u0448\u0430\u043d\u0441 \u0432\u044b\u043b\u0435\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0430\u0442\u0430\u043a\u0435 +Taming.Effect.18=\u0421\u0432\u044f\u0442\u043e\u0439 \u041f\u0435\u0441 +Taming.Effect.19=\u0418\u0437\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u0439 \u0432\u043e\u043b\u0448\u0435\u0431\u0441\u0442\u0432\u043e\u043c & \u044f\u0434\u043e\u043c Taming.Effect.2=\u041f\u0440\u043e\u043d\u0437\u0430\u043d\u0438\u0435 \u041a\u043b\u044b\u043a\u0430\u043c\u0438 Taming.Effect.3=\u041a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0423\u0434\u0430\u0440, \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u041a\u0440\u043e\u0432\u043e\u0442\u0435\u0447\u0435\u043d\u0438\u0435 Taming.Effect.4=\u041e\u0441\u0442\u0440\u044b\u0435 \u041a\u043e\u0433\u0442\u0438 @@ -278,7 +272,7 @@ Taming.Listener=\u0423\u043a\u0440\u043e\u0449\u0435\u043d\u0438\u0435: Taming.SkillName=\u0423\u041a\u0420\u041e\u0429\u0415\u041d\u0418\u0415 Taming.Skillup=[[YELLOW]]\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0430\u0432\u044b\u043a\u0430 \"\u0423\u043a\u0440\u043e\u0449\u0435\u043d\u0438\u0435\" \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d \u043d\u0430 {0}. \u0412\u0441\u0435\u0433\u043e ({1}) Taming.Summon.Complete=[[GREEN]]\u0412\u044b\u0437\u043e\u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d -Taming.Summon.Fail.Ocelot=[[RED]]\u0412\u043e\u043a\u0440\u0443\u0433 \u0412\u0430\u0441 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043e\u0446\u0435\u043b\u043e\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0437\u0432\u0430\u0442\u044c \u0435\u0449\u0435. +Taming.Summon.Fail.Ocelot=[[RED]]\u0412\u043e\u043a\u0440\u0443\u0433 \u0412\u0430\u0441 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043e\u0446\u0435\u043b\u043e\u0442\u043e\u0432. Taming.Summon.Fail.Wolf=[[RED]]\u0412\u043e\u043a\u0440\u0443\u0433 \u0412\u0430\u0441 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u043b\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0437\u0432\u0430\u0442\u044c \u0435\u0449\u0435. Unarmed.Ability.Berserk.Length=[[RED]]\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u043c\u0435\u043d\u0438\u044f \"\u0411\u0435\u0440\u0441\u0435\u0440\u043a\": [[YELLOW]]{0}\u0441. Unarmed.Ability.Bonus.0=\u0421\u0442\u0438\u043b\u044c \"\u0416\u0435\u043b\u0435\u0437\u043d\u044b\u0439 \u041a\u0443\u043b\u0430\u043a\" @@ -304,7 +298,7 @@ Unarmed.Listener=\u0411\u0435\u0437\u043e\u0440\u0443\u0436\u043d\u044b\u0439: Unarmed.SkillName=\u0411\u0415\u0417\u041e\u0420\u0423\u0416\u041d\u042b\u0419 Unarmed.Skills.Berserk.Off=[[RED]]**\u0423\u043c\u0435\u043d\u0438\u0435 \"\u0411\u0435\u0440\u0441\u0435\u0440\u043a\" \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435** Unarmed.Skills.Berserk.On=[[GREEN]]**\u0423\u043c\u0435\u043d\u0438\u0435 \"\u0411\u0435\u0440\u0441\u0435\u0440\u043a\" \u0410\u041a\u0422\u0418\u0412\u0418\u0420\u041e\u0412\u0410\u041d\u041e** -Unarmed.Skills.Berserk.Other.Off=[[RED]]\u0423\u043c\u0435\u043d\u0438\u0435 \"\u0411\u0435\u0440\u0441\u0435\u0440\u043a\"[[GREEN]] \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0443 [[YELLOW]]{0} +Unarmed.Skills.Berserk.Other.Off=[[GREEN]]\u0423\u043c\u0435\u043d\u0438\u0435 \"[[RED]]\u0411\u0435\u0440\u0441\u0435\u0440\u043a[[GREEN]]\" \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0443 [[YELLOW]]{0} Unarmed.Skills.Berserk.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u0432\u043a\u043b\u044e\u0447\u0438\u043b [[RED]]\u0443\u043c\u0435\u043d\u0438\u0435 \"\u0411\u0435\u0440\u0441\u0435\u0440\u043a\"! Unarmed.Skills.Berserk.Refresh=[[GREEN]]\u0412\u0430\u0448\u0435 \u0443\u043c\u0435\u043d\u0438\u0435 [[YELLOW]]\"\u0411\u0435\u0440\u0441\u0435\u0440\u043a\" [[GREEN]]\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e! Unarmed.Skillup=[[YELLOW]]\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0430\u0432\u044b\u043a\u0430 \"\u0411\u0435\u0437\u043e\u0440\u0443\u0436\u043d\u044b\u0439\" \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d \u043d\u0430 {0}. \u0412\u0441\u0435\u0433\u043e ({1}) @@ -324,7 +318,7 @@ Woodcutting.SkillName=\u041b\u0415\u0421\u041e\u0420\u0423\u0411\u0421\u0422\u04 Woodcutting.Skills.TreeFeller.Off=[RED]]**\u0423\u043c\u0435\u043d\u0438\u0435 \"\u041b\u0435\u0441\u043e\u0440\u0443\u0431\" \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435** Woodcutting.Skills.TreeFeller.On=[[GREEN]]**\u0423\u043c\u0435\u043d\u0438\u0435 \"\u041b\u0435\u0441\u043e\u0440\u0443\u0431\" \u0410\u041a\u0422\u0418\u0412\u0418\u0420\u041e\u0412\u0410\u041d\u041e** Woodcutting.Skills.TreeFeller.Refresh=[[GREEN]]\u0412\u0430\u0448\u0435 \u0443\u043c\u0435\u043d\u0438\u0435 [[YELLOW]]\"\u041b\u0435\u0441\u043e\u0440\u0443\u0431\" [[GREEN]]\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e! -Woodcutting.Skills.TreeFeller.Other.Off=[[RED]]\u0423\u043c\u0435\u043d\u0438\u0435 \"\u041b\u0435\u0441\u043e\u0440\u0443\u0431\"[[GREEN]] \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0443 [[YELLOW]]{0} +Woodcutting.Skills.TreeFeller.Other.Off=[[GREEN]]\u0423\u043c\u0435\u043d\u0438\u0435 \"[[RED]]\u041b\u0435\u0441\u043e\u0440\u0443\u0431[[GREEN]]\" \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0443 [[YELLOW]]{0} Woodcutting.Skills.TreeFeller.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0443\u043c\u0435\u043d\u0438\u0435 [[RED]]\"\u041b\u0435\u0441\u043e\u0440\u0443\u0431\"! Woodcutting.Skills.TreeFeller.Splinter=[[RED]]\u0412\u0410\u0428 \u0422\u041e\u041f\u041e\u0420 \u0420\u0410\u0421\u041a\u041e\u041b\u041e\u041b\u0421\u042f \u041d\u0410 \u0414\u0415\u0421\u042f\u0422\u041a\u0418 \u041a\u0423\u0421\u041a\u041e\u0412! Woodcutting.Skills.TreeFellerThreshold=[[RED]]\u042d\u0442\u043e \u0434\u0435\u0440\u0435\u0432\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u043e\u0435! @@ -336,9 +330,7 @@ Combat.ArrowDeflect=[[WHITE]]**\u0421\u0422\u0420\u0415\u041b\u0410 \u041e\u0422 Combat.BeastLore=[[GREEN]]**\u0423\u043c\u0435\u043d\u0438\u0435 \"\u0423\u0434\u0430\u0440 \u0432\u043e\u043b\u043a\u0430\" \u0410\u041a\u0422\u0418\u0412\u0418\u0420\u041e\u0412\u0410\u041d\u041e** Combat.BeastLoreHealth=[[DARK_AQUA]]\u0417\u0434\u043e\u0440\u043e\u0432\u044c\u0435 ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]\u0412\u043b\u0430\u0434\u0435\u043b\u0435\u0446 ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]\u0412\u044b \u0431\u044b\u043b\u0438 \u043f\u043e\u0440\u0430\u0436\u0435\u043d\u044b \u0433\u043e\u0440\u044f\u0449\u0435\u0439 \u0441\u0442\u0440\u0435\u043b\u043e\u0439! Combat.Gore=[[GREEN]]**\u041f\u0420\u041e\u041d\u0417\u0410\u041d\u0418\u0415 \u041a\u041b\u042b\u041a\u0410\u041c\u0418** -Combat.Ignition=[[RED]]**\u0412\u041e\u0421\u041f\u041b\u0410\u041c\u0415\u041d\u0415\u041d\u0418\u0415** Combat.StruckByGore=[[RED]]**\u0412\u0410\u0421 \u041f\u0420\u041e\u041d\u0417\u0418\u041b\u0418 \u041a\u041b\u042b\u041a\u0410\u041c\u0418** Combat.TargetDazed=\u0412\u0430\u0448\u0430 \u0446\u0435\u043b\u044c [[DARK_RED]]\u0428\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0430 Combat.TouchedFuzzy=[[DARK_RED]]\u0412\u044b \u0438\u0441\u0442\u0435\u043a\u0430\u0435\u0442\u0435 \u043a\u0440\u043e\u0432\u044c\u044e. \u041a\u0440\u0443\u0436\u0438\u0442\u0441\u044f \u0433\u043e\u043b\u043e\u0432\u0430. @@ -357,15 +349,15 @@ Commands.AdminToggle=[[RED]]- \u0412\u043a\u043b./\u043e\u0442\u043a\u043b. \u04 Commands.Chat.Console=*\u041a\u043e\u043d\u0441\u043e\u043b\u044c* Commands.Disabled=[[RED]]\u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0430. Commands.DoesNotExist=[[RED]]\u0418\u0433\u0440\u043e\u043a\u0430 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445! -Commands.GodMode.Disabled=[[YELLOW]]\u0420\u0435\u0436\u0438\u043c \u0411\u043e\u0433\u0430 mcMMO \u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d -Commands.GodMode.Enabled=[[YELLOW]]\u0420\u0435\u0436\u0438\u043c \u0411\u043e\u0433\u0430 mcMMO \u0412\u043a\u043b\u044e\u0447\u0435\u043d +Commands.GodMode.Disabled=[[YELLOW]]\u0420\u0435\u0436\u0438\u043c-\u0431\u043e\u0433\u0430 mcMMO \u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d +Commands.GodMode.Enabled=[[YELLOW]]\u0420\u0435\u0436\u0438\u043c-\u0431\u043e\u0433\u0430 mcMMO \u0412\u043a\u043b\u044e\u0447\u0435\u043d Commands.GodMode.Forbidden=[mcMMO] \u0420\u0435\u0436\u0438\u043c \u0411\u043e\u0433\u0430 \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d \u0432 \u044d\u0442\u043e\u043c \u043c\u0438\u0440\u0435 (\u0421\u043c\u043e\u0442\u0440\u0438 Permissions) Commands.Inspect= [[RED]]- \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0438\u0433\u0440\u043e\u043a\u0435 Commands.Invite.Accepted=[[GREEN]]\u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u043e. \u0412\u044b \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0435\u043d\u0438\u043b\u0438\u0441\u044c \u043a \u0433\u0440\u0443\u043f\u0435 {0} Commands.Invite.Success=[[GREEN]]\u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e. Commands.Leaderboards= [[RED]]- \u0421\u043f\u0438\u0441\u043a\u0438 \u041b\u0438\u0434\u0435\u0440\u043e\u0432 Commands.mcc.Header=[[RED]]---[][[YELLOW]]\u041a\u043e\u043c\u0430\u043d\u0434\u044b mcMMO[[RED]][]--- -Commands.mcgod=[[RED]]- \u0412\u043a\u043b./\u043e\u0442\u043a\u043b. \u0420\u0435\u0436\u0438\u043c \u0411\u043e\u0433\u0430 +Commands.mcgod=[[RED]]- \u0412\u043a\u043b./\u043e\u0442\u043a\u043b. \u0440\u0435\u0436\u0438\u043c-\u0431\u043e\u0433\u0430 mcMMO Commands.mchud.Invalid=[[RED]]\u042d\u0442\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u041f\u0430\u043d\u0435\u043b\u0438 \u0412\u0430\u0436\u043d\u043e\u0439 \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. Commands.mcpurge.Success=[[GREEN]]\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u044b\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430! Commands.mcrank.Heading=[[GOLD]]-=\u041f\u0415\u0420\u0421\u041e\u041d\u0410\u041b\u042c\u041d\u042b\u0415 \u0420\u0410\u041d\u0413\u0418=- @@ -377,12 +369,15 @@ Commands.mcrefresh.Success=[[RED]]{0} \u043e\u0447\u043a\u043e\u0432 \u0443\u043 Commands.mcremove.Success=[[GREEN]]{0} \u0431\u044b\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0443\u0434\u0430\u043b\u0435\u043d \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445! Commands.mctop.Tip=[[GOLD]]\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430: \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 [[RED]]/mcrank[[GOLD]] \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0441\u0435 \u0432\u0430\u0448\u0438 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u043d\u0433\u0438! Commands.mmoedit=[player] [[RED]] - \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0446\u0435\u043b\u0438 +Commands.mmoedit.AllSkills.1=[[GREEN]]\u0412\u0430\u0448 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u043e \u0432\u0441\u0435\u0445 \u043d\u0430\u0432\u044b\u043a\u0430\u0445 \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 {0}! Commands.mmoedit.Modified.1=[[GREEN]]\u0412\u0430\u0448 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432 {0} \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 {1}! Commands.mmoedit.Modified.2=[[RED]]{0} \u0431\u044b\u043b\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0434\u043b\u044f {1}. Commands.mmoupdate.Start=[[GRAY]]\u041d\u0430\u0447\u0430\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f... Commands.mmoupdate.Finish=[[GREEN]]\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e! Commands.ModDescription=[[RED]]- \u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0430 Commands.NoConsole=\u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 +Commands.Notifications.On=\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u043e [[GREEN]] \u043d\u0430 +Commands.Offline=[RED]] \u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0438\u0433\u0440\u043e\u043a\u043e\u0432. Commands.Other=[[GREEN]]--\u0414\u0420\u0423\u0413\u0418\u0415 \u041a\u041e\u041c\u0410\u041d\u0414\u042b-- Commands.Party.Header=[[RED]]-----[][[GREEN]]\u0413\u0420\u0423\u041f\u041f\u0410[[RED]][]----- Commands.Party.Status=[[DARK_GRAY]]\u041d\u0410\u0417\u0412\u0410\u041d\u0418\u0415: [[WHITE]]{0} {1} @@ -433,24 +428,29 @@ Commands.SkillInfo=/ [[RED]]- \u041f\u043e\u0441\u043c\u043e\u0442\u0440\ Commands.Stats.Self=\u0412\u0410\u0428\u0410 \u0421\u0422\u0410\u0422\u0418\u0421\u0422\u0418\u041a\u0410 Commands.Stats=[[RED]]- \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0412\u0430\u0448\u0443 mcMMO \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 Commands.ToggleAbility=[[RED]]- \u0412\u043a\u043b./\u043e\u0442\u043a\u043b. \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u043c\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u043c\u044b\u0448\u0438 +Commands.Usage.0=[[RED]]\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 /{0} Commands.Usage.1=[[RED]]\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 /{0} {1} Commands.Usage.2=[[RED]]\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 /{0} {1} {2} Commands.Usage.3=[[RED]]\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 /{0} {1} {2} {3} Commands.Usage.Level=level Commands.Usage.Message=message Commands.Usage.Page=page +Commands.Usage.PartyName=\u0438\u043c\u044f Commands.Usage.Password=password Commands.Usage.Player=player +Commands.Usage.Rate=rate Commands.Usage.Skill=skill Commands.Usage.XP=xp mcMMO.NoInvites=[[RED]]\u0421\u0435\u0439\u0447\u0430\u0441 \u0443 \u0412\u0430\u0441 \u043d\u0435\u0442 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0439 mcMMO.NoPermission=[[DARK_RED]]\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0430\u0432. -mcMMO.NoSkillNote=[[DARK_GRAY]]\u0415\u0441\u043b\u0438 \u0443 \u0412\u0430\u0441 \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0430\u0432\u044b\u043a\u0443, \u0442\u043e \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u0441\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f. +mcMMO.NoSkillNote=[[DARK_GRAY]]\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0430\u0432\u044b\u043a\u0443, \u0442\u043e \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0434\u0435\u0441\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0451\u043d. Party.Forbidden=[mcMMO] \u0413\u0440\u0443\u043f\u043f\u044b \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u044b \u0432 \u044d\u0442\u043e\u043c \u043c\u0438\u0440\u0435 (\u0421\u043c\u043e\u0442\u0440\u0438 Permissions) +Party.Help.6=[[RED]] \u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0433\u043d\u0430\u0442\u044c \u0438\u0433\u0440\u043e\u043a\u0430 \u0438\u0437 \u0432\u0430\u0448\u0435\u0439 \u043f\u0430\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 [[DARK_AQUA]] {0} Party.InformedOnJoin={0} [[GREEN]]\u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0435\u043d\u0438\u043b\u0441\u044f \u043a \u0432\u0430\u0448\u0435\u0439 \u0433\u0440\u0443\u043f\u043f\u0435 Party.InformedOnQuit={0} [[GREEN]]\u043f\u043e\u043a\u0438\u043d\u0443\u043b \u0432\u0430\u0448\u0443 \u0433\u0440\u0443\u043f\u043f\u0443 Party.InformedOnNameChange=[[GOLD]]{0} [[GREEN]]\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u043d\u0430 [[WHITE]]{1} Party.InvalidName=[[DARK_RED]]\u041d\u0435\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b. +Party.Invite.Self=[[RED]]\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0438\u0433\u043b\u0430\u0441\u0438\u0442\u044c \u0441\u0435\u0431\u044f! Party.IsLocked=[[RED]]\u042d\u0442\u0430 \u0433\u0440\u0443\u043f\u043f\u0430 \u0443\u0436\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u0430! Party.IsntLocked=[[RED]]\u042d\u0442\u0430 \u0433\u0440\u0443\u043f\u043f\u0430 \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u0430! Party.Locked=[[RED]]\u0413\u0440\u0443\u043f\u043f\u0430 \u0437\u0430\u043f\u0430\u0440\u043e\u043b\u0435\u043d\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0434\u0435\u0440 \u0433\u0440\u0443\u043f\u043f\u044b \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0442\u044c. @@ -466,18 +466,20 @@ Party.Player.Invalid=[[RED]]\u042d\u0442\u043e \u043d\u0435\u0434\u0435\u0439\u0 Party.NotOnline=[[DARK_RED]]{0} \u043d\u0435 \u0432 \u043e\u043d\u043b\u0430\u0439\u043d\u0435! Party.Player.InSameParty=[[RED]]{0} \u0443\u0436\u0435 \u0432 \u0432\u0430\u0448\u0435\u0439 \u0433\u0440\u0443\u043f\u043f\u0435! Party.PlayerNotInParty=[[DARK_RED]]{0} \u043d\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0433\u0440\u0443\u043f\u043f\u0435 +Party.Specify=[[RED]]\u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0443. Party.Teleport.Dead=[[RED]]\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u0441\u044f \u043a \u043c\u0435\u0440\u0442\u0432\u043e\u043c\u0443 \u0438\u0433\u0440\u043e\u043a\u0443. -Party.Teleport.Hurt=[[RED]]\u0417\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 {0} \u0441\u0435\u043a\u0443\u043d\u0434 \u0412\u044b \u0431\u044b\u043b\u0438 \u0440\u0430\u043d\u0435\u043d\u044b \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. Party.Teleport.Player=[[GREEN]]\u0412\u044b \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043a {0}. Party.Teleport.Self=[[RED]]\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435! Party.Teleport.Target=[[GREEN]]{0} \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043a \u0412\u0430\u043c. Party.Teleport.Disabled=[[RED]]\u0422\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0430\u0446\u0438\u044f \u043a \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c \u0433\u0440\u0443\u043f\u043f\u044b {0} \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u0430 +Party.Join.Self=[[RED]]\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0435\u0431\u0435! Party.Unlocked=[[GRAY]]\u0413\u0440\u0443\u043f\u043f\u0430 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0430 Party.Disband=[[GRAY]\u0413\u0440\u0443\u043f\u043f\u0430 \u0431\u044b\u043b\u0430 \u0440\u0430\u0441\u043f\u0443\u0449\u0435\u043d\u0430 Party.Status.Locked=[[DARK_RED]](\u0422\u041e\u041b\u042c\u041a\u041e \u041f\u041e \u041f\u0420\u0418\u0413\u041b\u0410\u0428\u0415\u041d\u0418\u042e) Party.Status.Unlocked=[[DARK_GREEN]](\u041e\u0422\u041a\u0420\u042b\u0422\u041e) Party.ShareType.Exp=\u041e\u041f\u042b\u0422 Party.ShareType.Item=\u041f\u0420\u0415\u0414\u041c\u0415\u0422 +Party.ShareMode.None=\u041d\u0418\u0427\u0415\u0413\u041e Party.ShareMode.Equal=\u0420\u0410\u0412\u041d\u042b\u0419 Party.ShareMode.Random=\u0421\u041b\u0423\u0427\u0410\u0419\u041d\u041e Commands.XPGain.Acrobatics=\u041f\u0440\u044b\u0433\u0430\u0439\u0442\u0435 \u0441 \u0432\u044b\u0441\u043e\u0442\u044b @@ -554,6 +556,7 @@ Vampirism.Killer.Failure=[[GOLD]][mcMMO] [[YELLOW]]{0}[[GRAY]] \u0431\u044b\u043 Vampirism.Killer.Success=[[GOLD]][mcMMO] [[DARK_AQUA]]\u0412\u044b \u0443\u043a\u0440\u0430\u043b\u0438 [[BLUE]]{0}[[DARK_AQUA]] \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0443 [[YELLOW]]{1} Vampirism.Victim.Failure=[[GOLD]][mcMMO] [[YELLOW]]{0}[[GRAY]] \u0431\u044b\u043b \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0443\u043a\u0440\u0430\u0441\u0442\u044c \u0432\u0430\u0448\u0438 \u0437\u043d\u0430\u043d\u0438\u044f! Vampirism.Victim.Success=[[GOLD]][mcMMO] [[YELLOW]]{0}[[DARK_RED]] \u0443\u043a\u0440\u0430\u043b [[BLUE]]{1}[[DARK_RED]] \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0443 \u0432\u0430\u0441! +Hardcore.Enabled=[[GOLD]][mcMMO] \u0425\u0430\u0440\u0434\u043a\u043e\u0440 \u043c\u043e\u0434 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d. Spout.Donate=[[YELLOW]][mcMMO] \u041f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u043d\u043e! Spout.LevelUp.1=[[GREEN]\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u043e\u0432\u044b\u0448\u0435\u043d! Spout.LevelUp.2=[[YELLOW]]{0}[[DARK_AQUA]] ([[GREEN]]{1}[[DARK_AQUA]]) @@ -588,3 +591,23 @@ Smelting.Effect.7=\u0428\u0430\u043d\u0441 \u0447\u0442\u043e \u0440\u0443\u0434 Smelting.FluxMining.Success=[[GREEN]]\u042d\u0442\u0430 \u0440\u0443\u0434\u0430 \u043f\u0435\u0440\u0435\u043f\u043b\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0430\u043c\u0430 \u0441\u043e\u0431\u043e\u0439! Smelting.Listener=\u0412\u044b\u043f\u043b\u0430\u0432\u043a\u0430: Smelting.SkillName=\u0412\u042b\u041f\u041b\u0410\u0412\u041a\u0410 +Commands.Description.addlevels=\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c mcMMO \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 +Commands.Description.adminchat=\u0412\u043a\u043b./\u043e\u0442\u043a\u043b. \u0440\u0435\u0436\u0438\u043c \u0447\u0430\u0442\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0436\u0434\u0443 \u0430\u0434\u043c\u0438\u043d\u0430\u043c\u0438 \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u0441\u043a\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 +Commands.Description.addxp=\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u043f\u044b\u0442 mcMMO +Commands.Description.mcability=\u0412\u043a\u043b./\u043e\u0442\u043a\u043b. \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044e \u0443\u043c\u0435\u043d\u0438\u0439 mcMMO \u043a\u043b\u0438\u043a\u043e\u043c \u041f\u041a\u041c +Commands.Description.mcgod=\u0412\u043a\u043b./\u043e\u0442\u043a\u043b. \u0440\u0435\u0436\u0438\u043c-\u0431\u043e\u0433\u0430 mcMMO +Commands.Description.mcmmo=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 mcMMO +Commands.Description.mcpurge=\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0431\u0435\u0437 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 mcMMO \u0438 \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u043b\u0438\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0435 {0} \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 mcMMO. +Commands.Description.mcrank=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c mcMMO \u0440\u0435\u0439\u0442\u0438\u043d\u0433 \u0438\u0433\u0440\u043e\u043a\u0430 +Commands.Description.mcrefresh=\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u043a\u0443\u043b\u0434\u0430\u0443\u043d\u044b \u0434\u043b\u044f mcMMO +Commands.Description.mcremove=\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 mcMMO +Commands.Description.mcstats=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u0448\u0438 mcMMO \u0443\u0440\u043e\u0432\u043d\u0438 \u0438 \u043e\u043f\u044b\u0442 +Commands.Description.mctop=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043b\u0438\u0434\u0435\u0440\u043e\u0432 mcMMO +Commands.Description.mmoedit=\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c mcMMO \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 +Commands.Description.mmoupdate=\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 mcMMO \u0438\u0437 Flatfile \u0432 MySQL +Commands.Description.party=\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u043f\u0430\u0442\u0438 mcMMO +Commands.Description.Skill=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0430\u0432\u044b\u043a\u0430\u0445 mcMMO \u0434\u043b\u044f {0} +Commands.Description.skillreset=\u0421\u0431\u0440\u043e\u0441 mcMMO \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 +Commands.Description.vampirism=\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 mcMMO \u043a\u0440\u043e\u0432\u043e\u0436\u0430\u0434\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 \u043a\u0440\u043e\u0432\u043e\u0436\u0430\u0434\u043d\u043e\u0441\u0442\u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c/\u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c +UpdateChecker.outdated=\u0412\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e mcMMO! +UpdateChecker.newavailable=\u0415\u0441\u0442\u044c \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u043d\u0430 BukkitDev. diff --git a/src/main/resources/locale/locale_zh_CN.properties b/src/main/resources/locale/locale_zh_CN.properties index 823156da5..1f95b9898 100644 --- a/src/main/resources/locale/locale_zh_CN.properties +++ b/src/main/resources/locale/locale_zh_CN.properties @@ -32,7 +32,6 @@ Axes.Ability.Bonus.4=\u5f3a\u70c8\u51b2\u51fb Axes.Ability.Bonus.5=\u5bf9\u65e0\u62a4\u7532\u654c\u4eba\u9020\u6210 {0} \u70b9\u989d\u5916\u4f24\u5bb3 Axes.Ability.Lower=[[GRAY]]**\u4f60\u6536\u8d77\u4e86\u4f60\u7684\u65a7\u5934** Axes.Ability.Ready=[[GREEN]]**\u4f60\u63e1\u7d27\u4e86\u4f60\u7684\u65a7\u5934** -Axes.Combat.Cleave.Proc=[[DARK_RED]]\u53d7\u5230\u5288\u88c2\u6253\u51fb! Axes.Combat.CritStruck=[[DARK_RED]]\u4f60\u6253\u51fa\u4e86\u66b4\u51fb! Axes.Combat.CritChance=[[RED]]\u66b4\u51fb\u51e0\u7387: [[YELLOW]]{0}% Axes.Combat.CriticalHit=[[RED]]\u66b4\u51fb! @@ -142,14 +141,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u4f7f\u7528\u4e8 Mining.Skills.SuperBreaker.Refresh=[[GREEN]]\u4f60\u7684 [[YELLOW]]\u8d85\u7ea7\u77ff\u5de5 [[GREEN]]\u6280\u80fd\u5df2\u7ecf\u53ef\u4ee5\u518d\u6b21\u4f7f\u7528\u4e86\uff01 Mining.Skillup=[[YELLOW]]\u6316\u77ff\u6280\u80fd\u4e0a\u5347\u4e86 {0}. \u603b\u7b49\u7ea7 ({1}) Mining.Blast.Boom=[[GRAY]]**\u5623** -Mining.Blast.Effect.0=+35% \u77ff\u77f3\u4ea7\u91cf -Mining.Blast.Effect.1=+40% \u77ff\u77f3\u4ea7\u91cf -Mining.Blast.Effect.2=+45% \u77ff\u77f3\u4ea7\u91cf, \u65e0\u788e\u7247 -Mining.Blast.Effect.3= +50% \u77ff\u7269\u4ea7\u7387, \u65e0\u788e\u7247 -Mining.Blast.Effect.4=+55% \u77ff\u7269\u4ea7\u7387, \u65e0\u788e\u7247, \u4e09\u500d\u6389\u843d -Mining.Blast.Effect.5=+60% \u77ff\u7269\u4ea7\u7387, \u65e0\u788e\u7247, \u4e09\u500d\u6389\u843d -Mining.Blast.Effect.6=+65% \u77ff\u7269\u4ea7\u7387, \u65e0\u788e\u7247, \u4e09\u500d\u6389\u843d -Mining.Blast.Effect.7=+70% \u77ff\u77f3\u4ea7\u91cf,\u65e0\u788e\u7247,3\u500d\u6389\u843d Mining.Blast.Radius.Increase=[[RED]]\u7206\u70b8\u534a\u5f84\u63d0\u5347: [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]\u7206\u7834\u5f00\u91c7: [[YELLOW]] \u6392\u540d {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u4f7f\u7528\u4e86 [[RED]]\u7206\u7834\u5f00\u91c7! @@ -310,9 +301,7 @@ Combat.ArrowDeflect=[[WHITE]]**\u7bad\u77e2\u504f\u5411** Combat.BeastLore=[[GREEN]]**\u9a6f\u517d\u77e5\u8bc6** Combat.BeastLoreHealth=[[DARK_AQUA]]\u751f\u547d\u503c ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]\u62e5\u6709\u8005 ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]\u4f60\u88ab\u4e00\u652f\u706b\u7bad\u51fb\u4e2d\u4e86! Combat.Gore=[[GREEN]]**\u6d41\u8840** -Combat.Ignition=[[RED]]**\u70b9\u71c3** Combat.StruckByGore=[[RED]]**\u4f60\u5f00\u59cb\u6d41\u8840\u4e86** Combat.TargetDazed=\u76ee\u6807\u88ab [[DARK_RED]]\u88ab\u51fb\u6655 Combat.TouchedFuzzy=[[DARK_RED]]\u5934\u6655\u76ee\u7729 @@ -388,7 +377,6 @@ Party.Owner.NotLeader=[[DARK_RED]]\u4f60\u5df2\u7ecf\u4e0d\u518d\u662f\u6d3e\u7c Party.Password.Set=[[GREEN]]\u961f\u4f0d\u5bc6\u7801\u8bbe\u7f6e\u4e3a {0} Party.Player.Invalid=[[RED]]\u8fd9\u4e0d\u662f\u4e00\u540d\u6709\u6548\u7684\u73a9\u5bb6 Party.Teleport.Dead=[[RED]]\u4f60\u4e0d\u80fd\u4f20\u9001\u5230\u6b7b\u4ea1\u7684\u73a9\u5bb6\u8eab\u8fb9 -Party.Teleport.Hurt=[[RED]]\u4f60\u5df2\u7ecf\u5728 {0} \u79d2\u524d\u53d7\u4f24\u5e76\u4e14\u65e0\u6cd5\u4f20\u9001. Party.Teleport.Player=[[GREEN]]\u4f60\u5df2\u7ecf\u4f20\u9001\u5230 {0}. Party.Teleport.Self=[[RED]]\u4f60\u4e0d\u80fd\u4f20\u9001\u5230\u4f60\u81ea\u5df1\u90a3\u91cc! Party.Teleport.Target=[[GREEN]]{0} \u5df2\u7ecf\u4f20\u9001\u5230\u4f60\u8eab\u8fb9. @@ -449,3 +437,6 @@ Perks.cooldowns.name=\u5feb\u901f\u6062\u590d Perks.cooldowns.desc=\u51cf\u5c11\u51b7\u5374\u65f6\u95f4 {0}. Perks.activationtime.name=\u8010\u529b Perks.activationtime.desc=\u63d0\u9ad8\u80fd\u529b\uff0c\u6fc0\u6d3b\u65f6\u95f4 {0} \u79d2. +Hardcore.Enabled=[[GOLD]][mcMMO] \u542f\u7528\u786c\u6838\u6a21\u5f0f +UpdateChecker.outdated=\u4f60\u6b63\u4f7f\u7528\u7740\u4e00\u4e2a\u8fc7\u65f6\u7248\u672c\u7684mcMMO! +UpdateChecker.newavailable=\u53d1\u73b0BukkitDev\u4e0a\u6709\u53ef\u7528\u65b0\u7248\u672c. diff --git a/src/main/resources/locale/locale_zh_TW.properties b/src/main/resources/locale/locale_zh_TW.properties index a437a7fe8..36b0f1c4a 100644 --- a/src/main/resources/locale/locale_zh_TW.properties +++ b/src/main/resources/locale/locale_zh_TW.properties @@ -32,7 +32,6 @@ Axes.Ability.Bonus.4=\u5f37\u529b\u5c04\u64ca Axes.Ability.Bonus.5=\u5c0d\u7121\u88dd\u7532\u6575\u4eba\u984d\u5916\u9020\u6210 {0} \u50b7\u5bb3 Axes.Ability.Lower=[[GRAY]]**\u4f60\u653e\u4e0b\u4e86\u4f60\u7684\u65a7\u982d** Axes.Ability.Ready=[[GREEN]]**\u4f60\u63e1\u7dca\u4e86\u4f60\u7684\u65a7\u982d** -Axes.Combat.Cleave.Proc=[[DARK_RED]]\u53d7\u5230\u5f37\u70c8\u6253\u64ca! Axes.Combat.CritStruck=[[DARK_RED]]\u4f60\u6253\u51fa\u4e86\u6703\u5fc3\u4e00\u64ca! Axes.Combat.CritChance=[[RED]]\u66b4\u64ca\u6a5f\u7387: [[YELLOW]]{0}% Axes.Combat.CriticalHit=[[RED]]\u6703\u5fc3\u4e00\u64ca! @@ -125,7 +124,7 @@ Mining.Ability.Locked.0=\u9396\u5b9a \u76f4\u5230 {0}+ \u6280\u80fd (\u6316\u792 Mining.Ability.Locked.1=\u9396\u5b9a \u76f4\u5230 {0}+ \u6280\u80fd (\u66f4\u5927\u7684\u70b8\u5f48) Mining.Ability.Locked.2=\u9396\u5b9a \u76f4\u5230 {0}+ \u6280\u80fd (\u7206\u7834\u5c08\u5bb6) Mining.Ability.Lower=[[GRAY]]**\u4f60\u653e\u4e0b\u4e86\u4f60\u7684\u7a3f\u5b50** -Mining.Ability.Ready=[GREEN]**\u4f60\u63e1\u7dca\u4e86\u4f60\u7684\u7a3f\u5b50**\n\n +Mining.Ability.Ready=[GREEN]**\u4f60\u63e1\u7dca\u4e86\u4f60\u7684\u93ac\u5b50**\\\n\\\n Mining.Effect.0=\u8d85\u7d1a\u5de5\u4eba (\u4e3b\u52d5\u6280\u80fd) Mining.Effect.1=\u901f\u5ea6+, 3\u500d\u6389\u843d\u7387 Mining.Effect.2=\u96d9\u500d\u6389\u843d @@ -147,14 +146,6 @@ Mining.Skills.SuperBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u4f7f\u7528\u4e8 Mining.Skills.SuperBreaker.Refresh=[[GREEN]]\u4f60\u7684 [[YELLOW]]\u8d85\u7d1a\u5de5\u4eba [[GREEN]]\u6280\u80fd\u5df2\u7d93\u53ef\u4ee5\u518d\u6b21\u4f7f\u7528\u4e86\uff01 Mining.Skillup=[[YELLOW]]\u6316\u7926\u6280\u80fd\u4e0a\u5347\u4e86 {0}! \u7e3d\u7b49\u7d1a ({1})! Mining.Blast.Boom=[[GRAY]]**BOOM!** -Mining.Blast.Effect.0=+35% \u7926\u7269\u7522\u91cf -Mining.Blast.Effect.1=+40% \u7926\u7269\u7522\u91cf -Mining.Blast.Effect.2=+45% \u7926\u7269\u7522\u91cf, \u7121\u788e\u7247 -Mining.Blast.Effect.3=+50% \u7926\u7269\u7522\u91cf, \u7121\u788e\u7247 -Mining.Blast.Effect.4=+55% \u7926\u7269\u7522\u91cf, \u7121\u788e\u7247,2\u500d\u6389\u843d -Mining.Blast.Effect.5=+60% \u7926\u7269\u7522\u91cf, \u7121\u788e\u7247,2\u500d\u6389\u843d -Mining.Blast.Effect.6=+65% \u7926\u7269\u7522\u91cf, \u7121\u788e\u7247,3\u500d\u6389\u843d -Mining.Blast.Effect.7=+70% \u7926\u7269\u7522\u91cf, \u7121\u788e\u7247,3\u500d\u6389\u843d Mining.Blast.Radius.Increase=[[RED]]\u7206\u70b8\u534a\u5f91\u63d0\u5347: [[YELLOW]]+{0} Mining.Blast.Rank=[[RED]]\u6316\u7926\u7206\u767c: [[YELLOW]] \u6392\u540d {0}/8 [[GRAY]]({1}) Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u4f7f\u7528\u4e86 [[RED]]\u6316\u7926\u7206\u767c! @@ -238,6 +229,7 @@ Taming.Ability.Bonus.6=\u5229\u722a Taming.Ability.Bonus.7=+{0} \u50b7\u5bb3 Taming.Ability.Bonus.8=\u5feb\u9910\u670d\u52d9 Taming.Ability.Bonus.9={0} \u4e00\u5b9a\u6a5f\u7387\u5728\u653b\u64ca\u6642\u6062\u5fa9\u8840\u91cf +Taming.Ability.Bonus.11=\u88ab\u6709\u5bb3\u7684\u9b54\u6cd5\u50b7\u5bb3\u6216\u4e2d\u6bd2\u6642\uff0c\u6062\u5fa9\u5065\u5eb7 Taming.Ability.Locked.0=\u9396\u5b9a \u76f4\u5230 {0}+ \u6280\u80fd (\u8fc5\u9748\u654f\u6377) Taming.Ability.Locked.1=\u9396\u5b9a \u76f4\u5230 {0}+ \u6280\u80fd (\u539a\u5be6\u7684\u76ae\u6bdb) Taming.Ability.Locked.2=\u9396\u5b9a \u76f4\u5230 {0}+ \u6280\u80fd (\u885d\u64ca\u683c\u64cb) @@ -284,6 +276,7 @@ Unarmed.Effect.4=\u9435\u8155\u5927\u5e2b Unarmed.Effect.5=\u4f7f\u4f60\u7684\u88dd\u7532\u96a8\u6642\u9593\u589e\u52a0\u800c\u589e\u5f37 Unarmed.Effect.6=\u5f13\u7bad\u504f\u5411 Unarmed.Effect.7=\u8b93\u5f13\u7bad\u504f\u5411 +Unarmed.Effect.9=\u9632\u6b62\u4f60\u88ab\u596a\u53d6\u6b66\u5668 Unarmed.Listener=\u5c1a\u672a\u88dd\u5099: Unarmed.SkillName=\u5c1a\u672a\u88dd\u5099 Unarmed.Skills.Berserk.Off=[[RED]]**\u72c2\u66b4\u6280\u80fd\u5df2\u7ed3\u675f** @@ -320,9 +313,7 @@ Combat.ArrowDeflect=[[WHITE]]**\u5f13\u7bad\u504f\u5411** Combat.BeastLore=[[GREEN]]**\u8a13\u7378\u4e4b\u80fd** Combat.BeastLoreHealth=[[DARK_AQUA]]\u751f\u547d\u503c ([[GREEN]]{0}[[DARK_AQUA]]/{1}) Combat.BeastLoreOwner=[[DARK_AQUA]]\u64c1\u6709\u8005 ([[RED]]{0}[[DARK_AQUA]]) -Combat.BurningArrowHit=[[DARK_RED]]\u4f60\u88ab\u4e00\u652f\u706b\u7bad\u64ca\u4e2d\u4e86! Combat.Gore=[[GREEN]]**\u6d41\u8840** -Combat.Ignition=[[RED]]**\u9ede\u71c3** Combat.StruckByGore=[[RED]]**\u4f60\u958b\u59cb\u6d41\u8840\u4e86** Combat.TargetDazed=\u76ee\u6a19\u5df2\u88ab [[DARK_RED]] \u64ca\u6688 Combat.TouchedFuzzy=[[DARK_RED]]\u982d\u6688\u76ee\u7729... @@ -360,18 +351,23 @@ Commands.mcrank.Unranked=[[WHITE]]\u6392\u884c\u699c\u5916 Commands.mcrefresh.Success=[[RED]]{0} \u79d2\u5f8c\u51b7\u537b\u6642\u9593\u5b8c\u7562. Commands.mcremove.Success=[[GREEN]]{0} \u5df2\u6210\u529f\u5f9e\u6578\u64da\u88e1\u79fb\u9664! Commands.mmoedit=[player] [[RED]] - \u7de8\u8f2f\u76ee\u6a19 +Commands.mmoedit.AllSkills.1=[\u7da0\u8272]\u60a8\u6240\u6709\u7684\u6280\u80fd\u7b49\u7d1a\u88ab\u8a2d\u5b9a\u70ba{0}\uff01 Commands.mmoedit.Modified.1=[[GREEN]]\u4f60\u7684 {0} \u7b49\u7d1a\u88ab\u8a2d\u5b9a\u70ba {1}! Commands.mmoedit.Modified.2=[[RED]]{0} \u56e0\u70ba {1} \u800c\u4fee\u6539. Commands.mmoupdate.Start=[[GRAY]]\u78ba\u8a8d\u7248\u672c\u4e2d... Commands.mmoupdate.Finish=[[GREEN]]\u8b80\u53d6\u7248\u672c\u5b8c\u7562! Commands.ModDescription=[[RED]]- \u8acb\u95b1\u8b80\u63d2\u4ef6\u63cf\u8ff0 Commands.NoConsole=\u9019\u500b\u6307\u4ee4\u4e0d\u53ef\u4f7f\u7528 +Commands.Notifications.Off= [\u7da0\u8272]\u5207\u63db\u80fd\u529b\u7684\u901a\u77e5 +Commands.Notifications.On= [\u7da0\u8272]\u5207\u63db\u80fd\u529b\u7684\u901a\u77e5 +Commands.Offline=[RED]]\u6b64\u547d\u4ee4\u4e26\u4e0d\u9069\u7528\u65bc\u96e2\u7dda\u73a9\u5bb6\u3002 Commands.Other=[[GREEN]]--\u5176\u4ed6\u6307\u4ee4-- Commands.Party.Header=[[RED]]-----[][[GREEN]]\u968a\u4f0d[[RED]][]----- Commands.Party.Status=[[DARK_GRAY]]\u540d\u5b57: [[WHITE]]{0} {1} Commands.Party.ShareMode=[[DARK_GRAY]]\u5206\u4eab\u6a21\u5f0f: Commands.Party.ItemShare=[[GRAY]]\u7269\u54c1 [[DARK_AQUA]]({0}) Commands.Party.ExpShare=[[GRAY]]\u7d93\u9a57\u503c [[DARK_AQUA]]({0}) +Commands.Party.ItemShareCategories=[[DARK_GRAY]]\u5171\u4eab\u9805\u76ee: [[GRAY]][[ITALIC]]{0} Commands.Party.MembersNear=[[DARK_GRAY]]\u63a5\u8fd1\u4f60 [[DARK_AQUA]]{0}[[DARK_GRAY]]/[[DARK_AQUA]]{1} Commands.Party.Accept=[[RED]]- \u63a5\u53d7\u968a\u4f0d\u9080\u8acb Commands.Party.Chat.Off=\u968a\u4f0d\u804a\u5929\u6a21\u5f0f[[RED]]\u53d6\u6d88 @@ -387,6 +383,7 @@ Commands.Party.Rename=[[GRAY]]\u968a\u4f0d\u540d\u7a31\u5df2\u66f4\u6539\u70ba: Commands.Party.SetSharing=[[GRAY]]\u968a\u4f0d {0} \u5206\u4eab\u8a2d\u5b9a\u70ba: [[DARK_AQUA]]{1} Commands.Party.Kick=[[RED]]\u4f60\u5df2\u88ab {0} \u8e22\u51fa! Commands.Party.Leave=[[RED]]\u4f60\u96e2\u958b\u4e86\u9019\u652f\u968a\u4f0d +Commands.Party.Members.Header=[RED]] ----- [] [GREEN]\u6703\u54e1[RED] [] ----- Commands.Party.Members={0} Commands.Party.None=[[RED]]\u4f60\u4e0d\u5728\u968a\u4f0d\u4e2d. Commands.Party.Quit=[[RED]]- \u96e2\u958b\u4f60\u73fe\u5728\u7684\u968a\u4f0d @@ -397,6 +394,7 @@ Commands.Party2=[[RED]]- \u52a0\u5165\u73a9\u5bb6\u7684\u968a\u4f0d\u88e1 Commands.ptp.Enabled=\u968a\u4f0d\u50b3\u9001 [[GREEN]]\u5141\u8a31 Commands.ptp.Disabled=\u968a\u4f0d\u50b3\u9001 [[RED]]\u4e0d\u5141\u8a31 Commands.ptp.NoRequests=[[RED]]\u4f60\u73fe\u5728\u4e0d\u53ef\u4ee5\u50b3\u9001 +Commands.ptp.NoWorldPermissions=[[RED]] [mcMMO]\u60a8\u6c92\u6709\u6b0a\u9650\u50b3\u9001\u5230\u6b64\u4e16\u754c{0}\u3002 Commands.ptp.Request1=[[YELLOW]]{0} [[GREEN]]\u5df2\u50b3\u9001\u81f3\u4f60\u65c1\u908a. Commands.ptp.RequestExpired=[[RED]]\u968a\u4f0d\u50b3\u9001\u5df2\u6210\u529f! Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] \u80fd\u529b\u7b49\u7d1a [[YELLOW]]\u6392\u884c\u699c-- @@ -411,12 +409,14 @@ Commands.SkillInfo=/ [[RED]]- \u67e5\u770b\u6280\u80fd\u7684\u8a73\u7ec6\ Commands.Stats.Self=\u4f60\u7684\u8a0a\u606f Commands.Stats=[[RED]]- \u67e5\u770b\u4f60\u7684mcMMO\u7d71\u8a08\u8a0a\u606f Commands.ToggleAbility=[[RED]]- \u7528\u6ed1\u9f20\u53f3\u9375\u5207\u63db\u6280\u80fd\u4f7f\u7528\u6a21\u5f0f +Commands.Usage.0=[RED]]\u6b63\u78ba\u4f7f\u7528/ {0} Commands.Usage.1=[[RED]]\u8acb\u8f38\u5165 /{0} {1} Commands.Usage.2=[[RED]]\u8acb\u8f38\u5165 /{0} {1} {2} Commands.Usage.3=[[RED]]\u8acb\u8f38\u5165 /{0} {1} {2} {3} Commands.Usage.Level=\u7b49\u7d1a Commands.Usage.Message=\u8a0a\u606f Commands.Usage.Page=\u9801\u6578 +Commands.Usage.PartyName= \u540d\u7a31 Commands.Usage.Password=\u5bc6\u78bc Commands.Usage.Player=\u73a9\u5bb6 Commands.Usage.Skill=\u6280\u80fd @@ -425,10 +425,18 @@ mcMMO.NoInvites=[[RED]]\u4f60\u6c92\u6709\u6536\u5230\u4efb\u4f55\u968a\u4f0d\u9 mcMMO.NoPermission=[[DARK_RED]]\u6b0a\u9650\u4e0d\u8db3 mcMMO.NoSkillNote=[[DARK_GRAY]]\u5982\u679c\u4f60\u7121\u6cd5\u4f7f\u7528\u90a3\u4e9b\u6280\u80fd\u5c31\u4e0d\u6703\u51fa\u73fe\u5728\u9019\u88e1 Party.Forbidden=[mcMMO] \u968a\u4f0d\u529f\u80fd\u4e0d\u5141\u8a31\u5728\u9019\u4e16\u754c\u958b\u555f (\u8acb\u89c0\u770b\u6b0a\u9650\u8a2d\u5b9a) +Party.Help.0=[RED]]\u6b63\u78ba\u4f7f\u7528[DARK_AQUA] {0} [\u5bc6\u78bc]\u3002 +Party.Help.1=[RED]]\u8981\u5275\u5efa\u4e00\u500b\u968a\u4f0d\uff0c\u8acb\u4f7f\u7528[DARK_AQUA] {0} <\u540d\u7a31> [\u5bc6\u78bc]\u3002 +Party.Help.4=[RED]]\u8981\u9396\u5b9a\u6216\u89e3\u9396\u4f60\u7684\u968a\u4f0d\uff0c\u4f7f\u7528[DARK_AQUA]] {0} +Party.Help.5=[[RED]]\u4f7f\u7528\u5bc6\u78bc\u4fdd\u8b77\u4f60\u7684\u968a\u4f0d\uff0c\u8acb\u4f7f\u7528[DARK_AQUA] {0}<\u5bc6\u78bc> +Party.Help.6=[[RED]]\u8981\u8e22\u7684\u7403\u54e1\u5f9e\u968a\u4f0d\u4e2d\uff0c\u4f7f\u7528[DARK_AQUA] {0} +Party.Help.7=[RED]]\u8981\u8cb4\u968a\u4f0d\u7684\u6240\u6709\u6b0a\u8f49\u79fb\uff0c\u4f7f\u7528[DARK_AQUA] {0} +Party.Help.8=[RED]\u8981\u89e3\u6563\u968a\u4f0d\uff0c\u4f7f\u7528[DARK_AQUA] {0} Party.InformedOnJoin={0} [[GREEN]]\u52a0\u5165\u4e86\u4f60\u7684\u968a\u4f0d Party.InformedOnQuit={0} [[GREEN]]\u96e2\u958b\u4e86\u4f60\u7684\u968a\u4f0d Party.InformedOnNameChange=[[GOLD]]{0} [[GREEN]]\u5c07\u968a\u4f0d\u540d\u7a31\u8a2d\u5b9a\u70ba [[WHITE]]{1} Party.InvalidName=[[DARK_RED]]\u90a3\u4e0d\u662f\u4e00\u500b\u6709\u6548\u7684\u968a\u4f0d\u540d\u7a31. +Party.Invite.Self=[RED]\u4f60\u80fd\u4e0d\u80fd\u9080\u8acb\u81ea\u5df1\uff01 Party.IsLocked=[[RED]]\u9019\u500b\u968a\u4f0d\u5df2\u7d93\u9396\u5b9a\u4e86! Party.IsntLocked=[[RED]]\u9019\u500b\u968a\u4f0d\u4e26\u6c92\u6709\u9396\u5b9a! Party.Locked=[[RED]]\u9019\u500b\u968a\u4f0d\u5df2\u9396\u5b9a!\u53ea\u6709\u968a\u9577\u53ef\u4ee5\u9080\u8acb! @@ -437,6 +445,7 @@ Party.NotOwner=[[DARK_RED]]\u4f60\u4e26\u975e\u968a\u9577. Party.Owner.New=[[GREEN]]{0} \u6210\u70ba\u65b0\u968a\u9577. Party.Owner.NotLeader=[[DARK_RED]]\u56e0\u9592\u7f6e\u904e\u4e45,\u968a\u9577\u81ea\u52d5\u8f49\u8b93. Party.Owner.Player=[[GREEN]]\u4f60\u6210\u70ba\u4e86\u968a\u9577. +Party.Password.None=[RED]\u9019\u500b\u968a\u4f0d\u662f\u6709\u5bc6\u78bc\u4fdd\u8b77\u7684\u3002\u8acb\u63d0\u4f9b\u5bc6\u78bc\u624d\u80fd\u52a0\u5165\u3002 Party.Password.Incorrect=[[RED]]\u968a\u4f0d\u5bc6\u78bc\u932f\u8aa4. Party.Password.Set=[[GREEN]]\u968a\u4f0d\u5bc6\u78bc\u8a2d\u5b9a\u70ba {0} Party.Password.Removed=[[GREEN]]\u968a\u4f0d\u5bc6\u78bc\u5df2\u522a\u9664. @@ -444,18 +453,23 @@ Party.Player.Invalid=[[RED]]\u6b64\u73a9\u5bb6\u4e0d\u5b58\u5728 Party.NotOnline=[[DARK_RED]]{0} \u4e26\u4e0d\u5728\u7dda\u4e0a! Party.Player.InSameParty=[[RED]]{0} \u5df2\u7d93\u5728\u4f60\u968a\u4f0d\u88e1\u4e86! Party.PlayerNotInParty=[[DARK_RED]]{0} \u5df2\u4e0d\u5728\u4f60\u7684\u5718\u968a +Party.Specify=[RED]\u60a8\u5fc5\u9808\u6307\u5b9a\u4e00\u500b\u968a\u4f0d\u3002 Party.Teleport.Dead=[[RED]]\u4f60\u4e0d\u80fd\u50b3\u9001\u81f3\u6b7b\u4ea1\u7684\u73a9\u5bb6\u65c1 -Party.Teleport.Hurt=[[RED]]\u4f60\u5df2\u7d93\u5728 {0} \u79d2\u524d\u53d7\u50b7\u4e26\u4e14\u7121\u6cd5\u50b3\u9001. Party.Teleport.Player=[[GREEN]]\u4f60\u5df2\u7d93\u50b3\u9001\u5230 {0}. Party.Teleport.Self=[[RED]]\u4f60\u7121\u6cd5\u50b3\u9001\u5230\u4f60\u81ea\u5df1\u8eab\u65c1! Party.Teleport.Target=[[GREEN]]{0} \u5df2\u7d93\u50b3\u9001\u5230\u4f60\u8eab\u908a Party.Teleport.Disabled=[[RED]]{0} \u4e0d\u5141\u8a31\u968a\u4f0d\u50b3\u9001. +Party.Rename.Same=[RED]] {0}\u4f60\u5df2\u7d93\u5728\u968a\u4f0d\u88e1\u4e86\uff01 +Party.Join.Self=[RED]\u4e0d\u80fd\u52a0\u5165\u4f60\u81ea\u5df1\uff01 Party.Unlocked=[[GRAY]]\u968a\u4f0d\u4ee5\u89e3\u9396! +Party.Disband=[[GRAY]]\u968a\u4f0d\u5df2\u89e3\u6563 Party.Status.Locked=[[DARK_RED]](\u53ea\u53ef\u9080\u8acb) Party.Status.Unlocked=[[DARK_GREEN]](\u958b\u555f) Party.ShareType.Exp=\u7d93\u9a57\u503c Party.ShareType.Item=\u7269\u54c1 +Party.ShareMode.None=\u7121 Party.ShareMode.Random=\u96a8\u6a5f +Party.ExpShare.Disabled= [RED]\u968a\u4f0d\u7684\u7d93\u9a57\u5171\u4eab\u88ab\u7981\u7528\u3002 Commands.XPGain.Acrobatics=\u6389\u843d Commands.XPGain.Archery=\u653b\u64ca\u602a\u7269 Commands.XPGain.Axes=\u653b\u64ca\u602a\u7269 @@ -467,6 +481,7 @@ Commands.XPGain.Repair=\u4fee\u7406 Commands.XPGain.Swords=\u653b\u64ca\u602a\u7269 Commands.XPGain.Taming=\u99b4\u7378,\u548c\u4f60\u7684\u72fc\u4e00\u8d77\u6230\u9b25 Commands.XPGain.Unarmed=\u653b\u64ca\u602a\u7269 +Commands.XPGain.Woodcutting=\u780d\u6a39 Commands.XPGain=[[DARK_GRAY]]\u7372\u5f97\u7d93\u9a57\u503c:[[WHITE]]{0} Commands.xplock.locked=[[GOLD]]\u4f60\u7684\u7d93\u9a57\u503c\u9396\u5b9a\u5728 {0}! Commands.xplock.unlocked=[[GOLD]]\u4f60\u7684\u7d93\u9a57\u503c\u73fe\u5728 [[GREEN]]\u89e3\u9664\u9396\u5b9a\u4e86[[GOLD]]! @@ -489,6 +504,8 @@ Inspect.Offline=[[RED]]\u4f60\u6c92\u6709\u67e5\u8a62\u96e2\u7dda\u73a9\u5bb6\u8 Inspect.OfflineStats=\u96e2\u7dda\u73a9\u5bb6\u7684 [mcMMO] \u7d71\u8a08\u8a0a\u606f [[YELLOW]]{0} Inspect.Stats=[[GREEN]][mcMMO] \u7684\u7d71\u8a08\u8a0a\u606f [[YELLOW]]{0} Inspect.TooFar=[[RED]]\u56e0\u8ddd\u96e2\u592a\u9060\u7121\u6cd5\u67e5\u770b\u90a3\u4f4d\u73a9\u5bb6! +Item.ChimaeraWing.Fail=**\u5947\u7f8e\u62c9\u4e4b\u7ffc\u4f7f\u7528\u5931\u6557\u4e86!** +Item.ChimaeraWing.Pass=**\u5947\u7f8e\u62c9\u4e4b\u7ffc** Item.Injured.Wait=\u4f60\u904e\u5ea6\u75b2\u52de\u5fc5\u9808\u7b49\u5f85\u4e00\u6bb5\u6642\u9593\u5f8c\u624d\u53ef\u4f7f\u7528. [[YELLOW]]({0}s) Skills.Disarmed=[[DARK_RED]]\u4f60\u7684\u6b66\u5668\u88ab\u63a0\u596a\u4e86! Skills.Header=[[RED]]-----[][[GREEN]]{0}[[RED]][]----- @@ -512,6 +529,7 @@ Hardcore.Player.Loss=[[GOLD]][mcMMO] [[DARK_RED]]\u4f60\u5728\u6b7b\u4ea1\u4e2d\ Vampirism.Killer.Success=[[GOLD]][mcMMO] [[DARK_AQUA]]\u4f60\u5077\u4e86 [[BLUE]]{0}[[DARK_AQUA]] \u7b49\u4f86\u81ea\u65bc[[YELLOW]]{1}. Vampirism.Victim.Failure=[[GOLD]][mcMMO] [[YELLOW]]{0}[[GRAY]] \u4e0d\u5141\u8a31\u5f9e\u4f60\u90a3\u596a\u53d6\u7d93\u9a57\u503c! Vampirism.Victim.Success=[[GOLD]][mcMMO] [[YELLOW]]{0}[[DARK_RED]] \u596a\u8d70\u4e86\u4f60 [[BLUE]]{1}[[DARK_RED]] \u7b49! +Spout.Donate=[[YELLOW]] [mcMMO\u6350\u52a9\uff01 Spout.LevelUp.1=[[GREEN]]\u5347\u7d1a! Spout.LevelUp.2=[[YELLOW]]{0}[[DARK_AQUA]] ([[GREEN]]{1}[[DARK_AQUA]]) Spout.Menu.Exit=[[GRAY]]\u8f38\u5165 ESCAPE \u4f86\u96e2\u958b @@ -523,3 +541,17 @@ Spout.Title={0}\n[[YELLOW]]P[[GOLD]]\u7b49\u7d1a[[WHITE]].[[GREEN]]{1} MOTD.Hardcore.VampireOn=[[GOLD]][mcMMO] [[DARK_RED]]\u6b63\u7248\u6a21\u5f0f\u958b\u555f. MOTD.Version=[[GOLD]][mcMMO] \u6b63\u904b\u4f5c\u7684\u7248\u672c [[DARK_AQUA]]{0} MOTD.Website=[[GOLD]][mcMMO] [[GREEN]]{0}[[YELLOW]] - mcMMO \u9996\u9801 +Smelting.Ability.Locked.0=\u9396\u5b9a\u72c0\u614b\uff0c\u76f4\u5230{0} +\u6280\u80fd\uff08VANILLA XP BOOST\uff09 +Smelting.Ability.Locked.1=\u9396\u5b9a\u72c0\u614b\uff0c\u76f4\u5230{0} +\u6280\u80fd\uff08FLUX\u7926\u696d\uff09 +Commands.Description.adminchat= \u5207\u63dbmcMMO\u7ba1\u7406\u804a\u5929\u958b/\u95dc\u6216\u767c\u9001\u7d66\u7ba1\u7406\u54e1\u7684\u804a\u5929\u6d88\u606f +Commands.Description.mcmmo=\u986f\u793a\u4e00\u500bmcMMO\u7684\u7c21\u55ae\u63cf\u8ff0 +Commands.Description.mcnotify=\u5207\u63dbmcMMO\u7684\u804a\u5929\u986f\u793a\u901a\u77e5 \u958b/\u95dc +Commands.Description.mcrank=\u986f\u793a\u6240\u6709mcMMO\u7684\u6392\u540d +Commands.Description.mcremove=\u5f9emcMMO\u6578\u64da\u5eab\u4e2d\u522a\u9664\u7528\u6236 +Commands.Description.mctop=\u986f\u793amcMMO\u6392\u884c\u699c +Commands.Description.party= \u63a7\u5236\u5404\u7a2emcMMO\u968a\u4f0d\u7684\u8a2d\u7f6e +Commands.Description.partychat=\u5207\u63dbmcMMO\u958b/\u95dc\u968a\u4f0d\u7684\u804a\u5929\u6216\u767c\u9001\u65b9\u7684\u804a\u5929\u4fe1\u606f +Commands.Description.ptp=\u50b3\u9001\u5230\u4e00\u500bmcMMO\u968a\u4f0d\u6210\u54e1\u65c1 +Commands.Description.Skill=\u986f\u793a\u7684\u8a73\u7d30mcMMO\u6280\u80fd\u4fe1\u606f{0} +UpdateChecker.outdated=\u60a8\u4f7f\u7528\u7684\u662f\u904e\u6642\u7684\u7248\u672cmcMMO\uff01 +UpdateChecker.newavailable=\u6709\u65b0\u7684\u7248\u672cBukkitDev\u3002 From 8b55744447d032637f28c1dfe9175982caf551fd Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 3 Mar 2013 23:24:47 -0500 Subject: [PATCH 126/137] 1.4.01 bugfix release --- Changelog.txt | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index a1ebcb941..1f80ef193 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,7 +7,7 @@ Key: ! Change - Removal -Version 1.4.01-dev +Version 1.4.01 = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs = Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile = Fixed bug where Smelting would throw consistent errors due to offline players diff --git a/pom.xml b/pom.xml index c804f4bf7..6cd70b0a4 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.4.01-dev1 + 1.4.01 mcMMO https://github.com/mcMMO-Dev/mcMMO From 2f83e559a451536e6f0c408e0bb060e22ac21d32 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 3 Mar 2013 23:25:46 -0500 Subject: [PATCH 127/137] Back to regularly scheduled development. --- Changelog.txt | 2 ++ pom.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 1f80ef193..1231e5e51 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,8 @@ Key: ! Change - Removal +Version 1.4.02-dev + Version 1.4.01 = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs = Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile diff --git a/pom.xml b/pom.xml index 6cd70b0a4..df2dc5224 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.4.01 + 1.4.02-dev1 mcMMO https://github.com/mcMMO-Dev/mcMMO From 27ed5f7c38efcedd68983a6fca73d9d99a6ea545 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Mon, 4 Mar 2013 15:16:33 +0100 Subject: [PATCH 128/137] Added API to get level caps Use getLevelCap(String skillType) to get a level cap of a specific skill. Use getPowerLevelCap() to get the power level cap. --- Changelog.txt | 1 + .../com/gmail/nossr50/api/ExperienceAPI.java | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index 1231e5e51..bb82070e0 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,7 @@ Key: - Removal Version 1.4.02-dev + + Added API to get the skill and power level caps. Version 1.4.01 = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index cb6283fa7..f535308f2 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -237,6 +237,29 @@ public final class ExperienceAPI { return UserManager.getPlayer(player).getPowerLevel(); } + /** + * Get the level cap of a specific skill. + *
+ * This function is designed for API usage. + * + * @param skillType The skill to get the level cap for + * @return the level cap of a given skill + */ + public static int getLevelCap(String skillType) { + return Config.getInstance().getLevelCap(SkillType.getSkill(skillType)); + } + + /** + * Get the power level cap. + *
+ * This function is designed for API usage. + * + * @return the power level cap of a given skill + */ + public static int getPowerLevelCap() { + return Config.getInstance().getPowerLevelCap(); + } + /** * Sets the level of a player in a specific skill type. *
From 0c027ca69775273cccc7ac800de246c6592cb1ef Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 4 Mar 2013 09:40:03 -0500 Subject: [PATCH 129/137] Straightening up our Managers more, also fixed a few bugs regarding unlock levels and Deflect not working properly. --- Changelog.txt | 2 + .../nossr50/datatypes/player/McMMOPlayer.java | 13 +- .../nossr50/listeners/BlockListener.java | 29 ++-- .../nossr50/listeners/EntityListener.java | 4 +- .../skills/acrobatics/AcrobaticsManager.java | 12 +- .../skills/archery/ArcheryManager.java | 14 +- .../nossr50/skills/axes/AxesManager.java | 15 +- .../skills/fishing/FishingManager.java | 6 +- .../skills/herbalism/HerbalismManager.java | 23 ++- .../nossr50/skills/mining/MiningManager.java | 15 +- .../skills/smelting/SmeltingManager.java | 17 +-- .../nossr50/skills/swords/SwordsManager.java | 12 +- .../nossr50/skills/taming/TamingManager.java | 32 +++-- .../skills/unarmed/UnarmedManager.java | 14 +- .../nossr50/util/skills/CombatUtils.java | 134 ++++++++---------- .../gmail/nossr50/util/skills/SkillUtils.java | 8 +- 16 files changed, 169 insertions(+), 181 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index bb82070e0..910a0441b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,8 @@ Key: Version 1.4.02-dev + Added API to get the skill and power level caps. + = Fixed bug where Deflect was calculated based on the attacker, not the defender + = Fixed bug where some skills weren't registering as unlocked until one level later Version 1.4.01 = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index f1d4d4c90..7e89c7d59 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -69,10 +69,11 @@ public class McMMOPlayer { private boolean placedSalvageAnvil; private boolean godMode; - private Map abilityMode = new HashMap(); + private Map abilityMode = new HashMap(); private Map abilityInformed = new HashMap(); - private Map toolPreparationMode = new HashMap(); - private Map toolATS = new HashMap(); + + private Map toolMode = new HashMap(); + private Map toolATS = new HashMap(); private int recentlyHurt; private int respawnATS; @@ -110,7 +111,7 @@ public class McMMOPlayer { } for (ToolType toolType : ToolType.values()) { - toolPreparationMode.put(toolType, false); + toolMode.put(toolType, false); toolATS.put(toolType, 0); } } @@ -219,7 +220,7 @@ public class McMMOPlayer { * @return true if the tool is prepped, false otherwise */ public boolean getToolPreparationMode(ToolType tool) { - return toolPreparationMode.get(tool); + return toolMode.get(tool); } public boolean getAbilityUse() { @@ -250,7 +251,7 @@ public class McMMOPlayer { * @param bool true if the tool should be prepped, false otherwise */ public void setToolPreparationMode(ToolType tool, boolean bool) { - toolPreparationMode.put(tool, bool); + toolMode.put(tool, bool); } /** diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 5274d8ca0..930a6dbc0 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -7,6 +7,7 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -234,20 +235,26 @@ public class BlockListener implements Listener { } BlockState blockState = event.getBlock().getState(); - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); - SmeltingManager smeltingManager = mcMMOPlayer.getSmeltingManager(); + ItemStack heldItem = player.getItemInHand(); - if (herbalismManager.canUseHylianLuck()) { - if (herbalismManager.processHylianLuck(blockState)) { - blockState.update(true); - event.setCancelled(true); + if (ItemUtils.isSword(heldItem)) { + HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager(); + + if (herbalismManager.canUseHylianLuck()) { + if (herbalismManager.processHylianLuck(blockState)) { + blockState.update(true); + event.setCancelled(true); + } } } - else if (smeltingManager.canUseFluxMining(blockState)) { - if (smeltingManager.processFluxMining(blockState)) { - blockState.update(true); - event.setCancelled(true); + else if (ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) { + SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager(); + + if (smeltingManager.canUseFluxMining(blockState)) { + if (smeltingManager.processFluxMining(blockState)) { + blockState.update(true); + event.setCancelled(true); + } } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 211348a32..352e72dc5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -115,8 +115,8 @@ public class EntityListener implements Listener { Player defendingPlayer = (Player) defender; Player attackingPlayer = (Player) attacker; - // TODO: Why? - if (defendingPlayer == attackingPlayer) { + // We want to make sure we're not gaining XP or applying abilities when we hit ourselves + if (defendingPlayer.equals(attackingPlayer)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index c9df41cd9..e2e42cf04 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -11,6 +11,7 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -27,12 +28,11 @@ public class AcrobaticsManager extends SkillManager { public boolean canDodge(Entity damager) { if (Permissions.dodge(getPlayer())) { - if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) { - return true; - } - else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) { - return true; + if (damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) { + return false; } + + return CombatUtils.shouldProcessSkill(damager, skill); } return false; @@ -48,7 +48,7 @@ public class AcrobaticsManager extends SkillManager { int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier); Player player = getPlayer(); - if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) { + if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) { ParticleEffectUtils.playDodgeEffect(player); if (mcMMOPlayer.useChatNotifications()) { diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 15d5053a6..ca7858ed9 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -26,9 +26,7 @@ public class ArcheryManager extends SkillManager { } public boolean canSkillShot() { - Player player = getPlayer(); - - return SkillUtils.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill); + return getSkillLevel() >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(getPlayer(), skill); } public boolean canTrackArrows() { @@ -64,7 +62,7 @@ public class ArcheryManager extends SkillManager { * @param target The {@link LivingEntity} damaged by the arrow */ public void trackArrows(LivingEntity target) { - if (SkillUtils.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) { Archery.incrementTrackerValue(target); } } @@ -72,14 +70,12 @@ public class ArcheryManager extends SkillManager { /** * Handle the effects of the Daze ability * - * @param defender The player being affected by the ability + * @param defender The {@link Player} being affected by the ability * @param damage The amount of damage initially dealt by the event * @return the modified event damage if the ability was successful, the original event damage otherwise */ public int dazeCheck(Player defender, int damage) { - Player attacker = getPlayer(); - - if (SkillUtils.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) { Location dazedLocation = defender.getLocation(); dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181)); @@ -91,7 +87,7 @@ public class ArcheryManager extends SkillManager { } if (mcMMOPlayer.useChatNotifications()) { - attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed")); + getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed")); } return damage + Archery.dazeModifier; diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index f579307a7..384c4b02c 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -68,10 +68,8 @@ public class AxesManager extends SkillManager { * @return the modified event damage if the ability was successful, the original event damage otherwise */ public int criticalHitCheck(LivingEntity target, int damage) { - Player player = getPlayer(); - - if (SkillUtils.activationSuccessful(player, skill, Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) { - player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit")); + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) { + getPlayer().sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit")); if (target instanceof Player) { ((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck")); @@ -94,10 +92,11 @@ public class AxesManager extends SkillManager { int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel); for (ItemStack armor : target.getEquipment().getArmorContents()) { - if (ItemUtils.isArmor(armor) && SkillUtils.activationSuccessful(getPlayer(), skill, Axes.impactChance)) { + if (ItemUtils.isArmor(armor) && Axes.impactChance > getActivationChance()) { double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior double modifiedDurabilityDamage = durabilityDamage * durabilityModifier; - double maxDurabilityDamage = (ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability()) * Axes.impactMaxDurabilityModifier; + short maxDurability = ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability(); + double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier; armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability())); } @@ -112,9 +111,9 @@ public class AxesManager extends SkillManager { * @return the modified event damage if the ability was successful, the original event damage otherwise */ public int greaterImpactCheck(LivingEntity target, int damage) { - Player player = getPlayer(); + if (Axes.greaterImpactChance > getActivationChance()) { + Player player = getPlayer(); - if (SkillUtils.activationSuccessful(player, skill, Axes.greaterImpactChance)) { ParticleEffectUtils.playGreaterImpactEffect(target); target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier)); diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 709534007..7d7714a34 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -38,9 +38,7 @@ public class FishingManager extends SkillManager { } public boolean canShake(Entity target) { - Player player = getPlayer(); - - return target instanceof LivingEntity && SkillUtils.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player); + return target instanceof LivingEntity && getSkillLevel() >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shake(getPlayer()); } /** @@ -136,7 +134,7 @@ public class FishingManager extends SkillManager { * @param mob The {@link LivingEntity} affected by the ability */ public void shakeCheck(LivingEntity target) { - if (SkillUtils.activationSuccessful(getPlayer(), skill, getShakeProbability())) { + if (getActivationChance() > getShakeProbability()) { Map possibleDrops = new HashMap(); Fishing.findPossibleDrops(target, possibleDrops); diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 4f6171589..f1546ab0b 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -24,7 +24,6 @@ import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask; import com.gmail.nossr50.runnables.skills.herbalism.GreenThumbTimerTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.BlockUtils; -import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ModUtils; import com.gmail.nossr50.util.Permissions; @@ -54,9 +53,7 @@ public class HerbalismManager extends SkillManager { } public boolean canUseHylianLuck() { - Player player = getPlayer(); - - return ItemUtils.isSword(player.getItemInHand()) && Permissions.hylianLuck(player); + return Permissions.hylianLuck(getPlayer()); } public boolean canGreenTerraBlock(BlockState blockState) { @@ -150,7 +147,7 @@ public class HerbalismManager extends SkillManager { xp = customBlock.getXpGain(); } - if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) { + if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) { Location location = blockState.getLocation(); if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) { @@ -178,10 +175,8 @@ public class HerbalismManager extends SkillManager { * @return true if the ability was successful, false otherwise */ public boolean processGreenThumbBlocks(BlockState blockState) { - Player player = getPlayer(); - - if (!SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { - player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail")); + if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { + getPlayer().sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail")); return false; } @@ -195,9 +190,7 @@ public class HerbalismManager extends SkillManager { * @return true if the ability was successful, false otherwise */ public boolean processHylianLuck(BlockState blockState) { - Player player = getPlayer(); - - if (!SkillUtils.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) { + if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) { return false; } @@ -236,7 +229,7 @@ public class HerbalismManager extends SkillManager { blockState.setType(Material.AIR); Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop()); - player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); + getPlayer().sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); return true; } @@ -264,7 +257,7 @@ public class HerbalismManager extends SkillManager { playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM)); player.updateInventory(); - if (!SkillUtils.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) { + if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) { player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail")); return false; } @@ -293,7 +286,7 @@ public class HerbalismManager extends SkillManager { mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimerTask(blockState), 0); return; } - else if (SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { + else if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { playerInventory.removeItem(seed); player.updateInventory(); // Needed until replacement available diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 80b51025f..c76b4a2d8 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -30,38 +30,33 @@ public class MiningManager extends SkillManager{ } public boolean canUseDemolitionsExpertise() { - Player player = getPlayer(); - - return SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.FOUR.getLevel()) && Permissions.demolitionsExpertise(player); + return getSkillLevel() >= BlastMining.Tier.FOUR.getLevel() && Permissions.demolitionsExpertise(getPlayer()); } public boolean canDetonate() { Player player = getPlayer(); - return player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player) && SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.ONE.getLevel()); + return canUseBlastMining() && player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player); } public boolean canUseBlastMining() { - return SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.ONE.getLevel()); + return getSkillLevel() >= BlastMining.Tier.ONE.getLevel(); } public boolean canUseBiggerBombs() { - Player player = getPlayer(); - - return Permissions.biggerBombs(player) && SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.TWO.getLevel()); + return getSkillLevel() >= BlastMining.Tier.TWO.getLevel() && Permissions.biggerBombs(getPlayer()); } /** * Process double drops & XP gain for Mining. * * @param blockState The {@link BlockState} to check ability activation for - * @param player The {@link Player} using this ability */ public void miningBlockCheck(BlockState blockState) { Player player = getPlayer(); int xp = Mining.getBlockXp(blockState); - if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { + if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { Mining.handleSilkTouchDrops(blockState); } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index 3c55f721c..bdd9be936 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.smelting; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.BlockState; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.inventory.ItemStack; @@ -16,7 +15,6 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.mining.Mining; import com.gmail.nossr50.skills.smelting.Smelting.Tier; import com.gmail.nossr50.util.BlockUtils; -import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.skills.SkillUtils; @@ -27,16 +25,11 @@ public class SmeltingManager extends SkillManager { } public boolean canUseFluxMining(BlockState blockState) { - Player player = getPlayer(); - ItemStack heldItem = player.getItemInHand(); - - return BlockUtils.affectedByFluxMining(blockState) && ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState); + return getSkillLevel() >= Smelting.fluxMiningUnlockLevel && BlockUtils.affectedByFluxMining(blockState) && Permissions.fluxMining(getPlayer()) && !mcMMO.placeStore.isTrue(blockState); } public boolean canUseVanillaXpBoost() { - Player player = getPlayer(); - - return SkillUtils.unlockLevelReached(player, skill, Smelting.Tier.ONE.getLevel()) && Permissions.vanillaXpBoost(player, skill); + return getSkillLevel() >= Smelting.Tier.ONE.getLevel() && Permissions.vanillaXpBoost(getPlayer(), skill); } /** @@ -48,7 +41,7 @@ public class SmeltingManager extends SkillManager { public boolean processFluxMining(BlockState blockState) { Player player = getPlayer(); - if (SkillUtils.unlockLevelReached(player, skill, Smelting.fluxMiningUnlockLevel) && SkillUtils.activationSuccessful(player, skill, Smelting.fluxMiningChance)) { + if (getActivationChance() > Smelting.fluxMiningChance) { ItemStack item = null; switch (blockState.getType()) { @@ -72,7 +65,7 @@ public class SmeltingManager extends SkillManager { Misc.dropItem(location, item); - if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { + if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { Misc.dropItem(location, item); } @@ -101,7 +94,7 @@ public class SmeltingManager extends SkillManager { applyXpGain(Smelting.getResourceXp(resourceType)); - if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) { + if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) { ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1); return newResult; } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index f60fb0c3b..0177f6fd2 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -28,6 +28,10 @@ public class SwordsManager extends SkillManager { return Permissions.bleed(getPlayer()); } + public boolean canUseCounterAttack() { + return Permissions.counterAttack(getPlayer()); + } + public boolean canUseSerratedStrike() { return mcMMOPlayer.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.serratedStrikes(getPlayer()); } @@ -38,9 +42,7 @@ public class SwordsManager extends SkillManager { * @param target The defending entity */ public void bleedCheck(LivingEntity target) { - Player player = getPlayer(); - - if (SkillUtils.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) { if (getSkillLevel() >= Swords.bleedMaxBonusLevel) { BleedTimerTask.add(target, Swords.bleedMaxTicks); @@ -50,7 +52,7 @@ public class SwordsManager extends SkillManager { } if (mcMMOPlayer.useChatNotifications()) { - player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); + getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); } if (target instanceof Player) { @@ -64,7 +66,7 @@ public class SwordsManager extends SkillManager { } public void counterAttackChecks(LivingEntity attacker, int damage) { - if (SkillUtils.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) { CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier); getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered")); 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 e45343127..d28bb582a 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -27,23 +27,35 @@ public class TamingManager extends SkillManager { } public boolean canUseThickFur() { - return getSkillLevel() > Taming.thickFurUnlockLevel && Permissions.thickFur(getPlayer()); + return getSkillLevel() >= Taming.thickFurUnlockLevel && Permissions.thickFur(getPlayer()); } public boolean canUseEnvironmentallyAware() { - return getSkillLevel() > Taming.environmentallyAwareUnlockLevel && Permissions.environmentallyAware(getPlayer()); + return getSkillLevel() >= Taming.environmentallyAwareUnlockLevel && Permissions.environmentallyAware(getPlayer()); } public boolean canUseShockProof() { - return getSkillLevel() > Taming.shockProofUnlockLevel && Permissions.shockProof(getPlayer()); + return getSkillLevel() >= Taming.shockProofUnlockLevel && Permissions.shockProof(getPlayer()); } public boolean canUseHolyHound() { - return getSkillLevel() > Taming.holyHoundUnlockLevel && Permissions.holyHound(getPlayer()); + return getSkillLevel() >= Taming.holyHoundUnlockLevel && Permissions.holyHound(getPlayer()); } - public boolean canUseBeastLore(LivingEntity target) { - return target instanceof Tameable && Permissions.beastLore(getPlayer()); + public boolean canUseFastFoodService() { + return getSkillLevel() >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(getPlayer()); + } + + public boolean canUseSharpenedClaws() { + return getSkillLevel() >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(getPlayer()); + } + + public boolean canUseGore() { + return Permissions.gore(getPlayer()); + } + + public boolean canUseBeastLore() { + return Permissions.beastLore(getPlayer()); } /** @@ -73,7 +85,7 @@ public class TamingManager extends SkillManager { * @param damage The damage being absorbed by the wolf */ public void fastFoodService(Wolf wolf, int damage) { - if (SkillUtils.activationSuccessful(getPlayer(), skill, Taming.fastFoodServiceActivationChance)) { + if (getActivationChance() > Taming.fastFoodServiceActivationChance) { int health = wolf.getHealth(); int maxHealth = wolf.getMaxHealth(); @@ -91,16 +103,14 @@ public class TamingManager extends SkillManager { * @param event The event to modify */ public int gore(LivingEntity target, int damage) { - Player owner = getPlayer(); - - if (SkillUtils.activationSuccessful(owner, skill, Taming.goreMaxChance, Taming.goreMaxBonusLevel)) { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Taming.goreMaxChance, Taming.goreMaxBonusLevel)) { BleedTimerTask.add(target, Taming.goreBleedTicks); if (target instanceof Player) { ((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore")); } - owner.sendMessage(LocaleLoader.getString("Combat.Gore")); + getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore")); return damage * Taming.goreModifier; } diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index f86fec269..101aa45de 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -38,13 +38,19 @@ public class UnarmedManager extends SkillManager { return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.disarm(getPlayer()); } + public boolean canDeflect() { + Player player = getPlayer(); + + return player.getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect(player); + } + /** * Check for disarm. * * @param defender The defending player */ public void disarmCheck(Player defender) { - if (SkillUtils.activationSuccessful(getPlayer(), skill, Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) { McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender); mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent); @@ -61,10 +67,8 @@ public class UnarmedManager extends SkillManager { * Check for arrow deflection. */ public boolean deflectCheck() { - Player player = getPlayer(); - - if (SkillUtils.activationSuccessful(player, skill, Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) { - player.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect")); + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) { + getPlayer().sendMessage(LocaleLoader.getString("Combat.ArrowDeflect")); return true; } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index f1cedbfaf..90ecd3892 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -55,22 +55,27 @@ public final class CombatUtils { if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) { Player player = (Player) attacker; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); if (Misc.isNPCEntity(player)) { return; } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); ItemStack heldItem = player.getItemInHand(); if (target instanceof Tameable) { - if (heldItem.getType() == Material.BONE && Permissions.beastLore(player)) { - mcMMOPlayer.getTamingManager().beastLore(target); - event.setCancelled(true); + if (isFriendlyPet(player, (Tameable) target)) { return; } - else if (isFriendlyPet(player, (Tameable) target)) { - return; + + if (heldItem.getType() == Material.BONE) { + TamingManager tamingManager = mcMMOPlayer.getTamingManager(); + + if (tamingManager.canUseBeastLore()) { + tamingManager.beastLore(target); + event.setCancelled(true); + return; + } } } @@ -94,7 +99,7 @@ public final class CombatUtils { swordsManager.serratedStrikes(target, event.getDamage()); } - startGainXp(swordsManager.getMcMMOPlayer(), target, SkillType.SWORDS); + startGainXp(mcMMOPlayer, target, SkillType.SWORDS); } } else if (ItemUtils.isAxe(heldItem)) { @@ -128,7 +133,7 @@ public final class CombatUtils { axesManager.skullSplitterCheck(target, event.getDamage()); } - startGainXp(axesManager.getMcMMOPlayer(), target, SkillType.AXES); + startGainXp(mcMMOPlayer, target, SkillType.AXES); } } else if (heldItem.getType() == Material.AIR) { @@ -155,14 +160,7 @@ public final class CombatUtils { unarmedManager.disarmCheck((Player) target); } - startGainXp(unarmedManager.getMcMMOPlayer(), target, SkillType.UNARMED); - } - } - else if (heldItem.getType() == Material.BONE) { - TamingManager tamingManager = mcMMOPlayer.getTamingManager(); - - if (tamingManager.canUseBeastLore(target)) { - tamingManager.beastLore(target); + startGainXp(mcMMOPlayer, target, SkillType.UNARMED); } } } @@ -185,17 +183,16 @@ public final class CombatUtils { if (Permissions.skillEnabled(master, SkillType.TAMING)) { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master); TamingManager tamingManager = mcMMOPlayer.getTamingManager(); - int skillLevel = tamingManager.getSkillLevel(); - if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) { + if (tamingManager.canUseFastFoodService()) { tamingManager.fastFoodService(wolf, event.getDamage()); } - if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) { + if (tamingManager.canUseSharpenedClaws()) { event.setDamage(Taming.sharpenedClaws(event.getDamage())); } - if (Permissions.gore(master)) { + if (tamingManager.canUseGore()) { event.setDamage(tamingManager.gore(target, event.getDamage())); } @@ -214,10 +211,47 @@ public final class CombatUtils { } if (!shouldProcessSkill(target, SkillType.ARCHERY)) { - return; + break; + } + + Player player = (Player) shooter; + + if (Misc.isNPCEntity(player)) { + break; + } + + if (Permissions.skillEnabled(player, SkillType.ARCHERY)) { + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager(); + + if (archeryManager.canSkillShot()) { + event.setDamage(archeryManager.skillShotCheck(event.getDamage())); + } + + if (target instanceof Player && SkillType.UNARMED.getPVPEnabled()) { + UnarmedManager unarmedManager = UserManager.getPlayer((Player) target).getUnarmedManager(); + + if (unarmedManager.canDeflect()) { + event.setCancelled(mcMMOPlayer.getUnarmedManager().deflectCheck()); + + if (event.isCancelled()) { + return; + } + } + } + + if (archeryManager.canDaze(target)) { + event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage())); + } + + if (archeryManager.canTrackArrows()) { + archeryManager.trackArrows(target); + } + + archeryManager.distanceXpBonus(target); + startGainXp(mcMMOPlayer, target, SkillType.ARCHERY); } - archeryCheck((Player) shooter, target, event); break; default: @@ -238,59 +272,17 @@ public final class CombatUtils { event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage())); } - ItemStack heldItem = player.getItemInHand(); - - if (damager instanceof Player) { - if (SkillType.SWORDS.getPVPEnabled() && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) { - mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage()); - } - } - else { - if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) { - mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage()); - } - } - } - } - - /** - * Process archery abilities. - * - * @param shooter The player shooting - * @param target The defending entity - * @param event The event to run the archery checks on. - */ - private static void archeryCheck(Player shooter, LivingEntity target, EntityDamageByEntityEvent event) { - if (Misc.isNPCEntity(shooter)) { - return; - } - - if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) { - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(shooter); - ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager(); - - if (archeryManager.canSkillShot()) { - event.setDamage(archeryManager.skillShotCheck(event.getDamage())); - } - - if (target instanceof Player && SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) { - event.setCancelled(mcMMOPlayer.getUnarmedManager().deflectCheck()); - - if (event.isCancelled()) { + if (ItemUtils.isSword(player.getItemInHand())) { + if (!shouldProcessSkill(target, SkillType.SWORDS)) { return; } - } - if (archeryManager.canDaze(target)) { - event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage())); - } + SwordsManager swordsManager = mcMMOPlayer.getSwordsManager(); - if (archeryManager.canTrackArrows()) { - archeryManager.trackArrows(target); + if (swordsManager.canUseCounterAttack()) { + swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage()); + } } - - archeryManager.distanceXpBonus(target); - startGainXp(UserManager.getPlayer(shooter), target, SkillType.ARCHERY); } } @@ -582,7 +574,7 @@ public final class CombatUtils { return false; } - private static boolean shouldProcessSkill(LivingEntity target, SkillType skill) { + public static boolean shouldProcessSkill(Entity target, SkillType skill) { boolean process; if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index 251b7574a..8f3cbf82d 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -612,12 +612,8 @@ public class SkillUtils { return chance > Misc.getRandom().nextInt(activationChance); } - public static boolean activationSuccessful(Player player, SkillType skill, double chance) { - return chance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, skill)); - } - - public static boolean unlockLevelReached(Player player, SkillType skill, int unlockLevel) { - return UserManager.getPlayer(player).getProfile().getSkillLevel(skill) > unlockLevel; + public static boolean activationSuccessful(int skillLevel, int activationChance, double maxChance, int maxLevel) { + return ((maxChance / maxLevel) * Math.min(skillLevel, maxLevel)) > Misc.getRandom().nextInt(activationChance); } public static boolean treasureDropSuccessful(double dropChance, int activationChance) { From 9cf322ca0b8e4f686d56dfd139439156b15d8c05 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Tue, 5 Mar 2013 00:30:07 +0100 Subject: [PATCH 130/137] Fixed NPE with /ptp --- .../java/com/gmail/nossr50/commands/party/PtpCommand.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java index 4d446d39f..c3ddb1c41 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java @@ -32,6 +32,9 @@ public class PtpCommand implements CommandExecutor { switch (args.length) { case 1: + player = (Player) sender; + mcMMOPlayer = UserManager.getPlayer(player); + if (args[0].equalsIgnoreCase("toggle")) { if (!Permissions.partyTeleportToggle(sender)) { sender.sendMessage(command.getPermissionMessage()); @@ -50,7 +53,6 @@ public class PtpCommand implements CommandExecutor { return acceptAnyTeleportRequest(); } - player = (Player) sender; int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR; From 1e738263bc6c69fa566044966642b2a93f1aa0b1 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Tue, 5 Mar 2013 00:30:48 +0100 Subject: [PATCH 131/137] Remove the ptp request after using /ptp accept --- src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java index c3ddb1c41..17ea23178 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java @@ -112,9 +112,9 @@ public class PtpCommand implements CommandExecutor { } target = mcMMOPlayer.getPtpRequest(); + mcMMOPlayer.removePtpRequest(); if (!canTeleport(target.getName())) { - mcMMOPlayer.removePtpRequest(); return true; } From 3440833af8bebbcd9e463dbb5174da41cd8d864f Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Tue, 5 Mar 2013 00:48:48 +0100 Subject: [PATCH 132/137] Fixed bug where the PTP cooldown was being read improperly --- Changelog.txt | 2 ++ .../java/com/gmail/nossr50/commands/party/PtpCommand.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 910a0441b..96a463937 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -11,6 +11,8 @@ Version 1.4.02-dev + Added API to get the skill and power level caps. = Fixed bug where Deflect was calculated based on the attacker, not the defender = Fixed bug where some skills weren't registering as unlocked until one level later + = Fixed bug where the PTP cooldown was being read improperly + = Fixed bug where /ptp where broken Version 1.4.01 = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs diff --git a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java index 17ea23178..3c75473f0 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java @@ -54,9 +54,9 @@ public class PtpCommand implements CommandExecutor { } int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); - long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR; + long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt(); - if (System.currentTimeMillis() - recentlyHurt >= (ptpCooldown * Misc.TIME_CONVERSION_FACTOR)) { + if ((recentlyHurt * Misc.TIME_CONVERSION_FACTOR + ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) { player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown)); return true; } From 4210920c5f30dec16b7b5e4e1ee2d07c2b352993 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 4 Mar 2013 21:59:16 -0500 Subject: [PATCH 133/137] Fixed ClassCastException relating to counter-attack with Swords. Fixes #784 --- Changelog.txt | 1 + .../java/com/gmail/nossr50/skills/swords/SwordsManager.java | 5 +++-- src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 96a463937..412598743 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -13,6 +13,7 @@ Version 1.4.02-dev = Fixed bug where some skills weren't registering as unlocked until one level later = Fixed bug where the PTP cooldown was being read improperly = Fixed bug where /ptp where broken + = Fixed ClassCastException relating to counter-attack with Swords Version 1.4.01 = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 0177f6fd2..962bf4970 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.skills.swords; +import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -28,8 +29,8 @@ public class SwordsManager extends SkillManager { return Permissions.bleed(getPlayer()); } - public boolean canUseCounterAttack() { - return Permissions.counterAttack(getPlayer()); + public boolean canUseCounterAttack(Entity target) { + return target instanceof LivingEntity && Permissions.counterAttack(getPlayer()); } public boolean canUseSerratedStrike() { diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 90ecd3892..3d3371420 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -279,7 +279,7 @@ public final class CombatUtils { SwordsManager swordsManager = mcMMOPlayer.getSwordsManager(); - if (swordsManager.canUseCounterAttack()) { + if (swordsManager.canUseCounterAttack(damager)) { swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage()); } } From df53e2fd4f5f92e3c8752f71a4a2eab16c28e2ff Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 4 Mar 2013 22:45:37 -0500 Subject: [PATCH 134/137] Fixed issue with some skill activations not activating enough or activating too much. Fixes #785 --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java | 5 +++-- .../com/gmail/nossr50/skills/fishing/FishingManager.java | 2 +- .../com/gmail/nossr50/skills/smelting/SmeltingManager.java | 2 +- .../java/com/gmail/nossr50/skills/taming/TamingManager.java | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 412598743..9d5576b43 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,6 +14,7 @@ Version 1.4.02-dev = Fixed bug where the PTP cooldown was being read improperly = Fixed bug where /ptp where broken = Fixed ClassCastException relating to counter-attack with Swords + = Fixed issue with some skill activations not activating enough or activating too much Version 1.4.01 = Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index 384c4b02c..3306e8752 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -12,6 +12,7 @@ import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ModUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; @@ -92,7 +93,7 @@ public class AxesManager extends SkillManager { int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel); for (ItemStack armor : target.getEquipment().getArmorContents()) { - if (ItemUtils.isArmor(armor) && Axes.impactChance > getActivationChance()) { + if (ItemUtils.isArmor(armor) && Axes.impactChance > Misc.getRandom().nextInt(getActivationChance())) { double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior double modifiedDurabilityDamage = durabilityDamage * durabilityModifier; short maxDurability = ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability(); @@ -111,7 +112,7 @@ public class AxesManager extends SkillManager { * @return the modified event damage if the ability was successful, the original event damage otherwise */ public int greaterImpactCheck(LivingEntity target, int damage) { - if (Axes.greaterImpactChance > getActivationChance()) { + if (Axes.greaterImpactChance > Misc.getRandom().nextInt(getActivationChance())) { Player player = getPlayer(); ParticleEffectUtils.playGreaterImpactEffect(target); diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 7d7714a34..a985c37d2 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -134,7 +134,7 @@ public class FishingManager extends SkillManager { * @param mob The {@link LivingEntity} affected by the ability */ public void shakeCheck(LivingEntity target) { - if (getActivationChance() > getShakeProbability()) { + if (getShakeProbability() > Misc.getRandom().nextInt(getActivationChance())) { Map possibleDrops = new HashMap(); Fishing.findPossibleDrops(target, possibleDrops); diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index bdd9be936..d24a1dc66 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -41,7 +41,7 @@ public class SmeltingManager extends SkillManager { public boolean processFluxMining(BlockState blockState) { Player player = getPlayer(); - if (getActivationChance() > Smelting.fluxMiningChance) { + if (Smelting.fluxMiningChance > Misc.getRandom().nextInt(getActivationChance())) { ItemStack item = null; switch (blockState.getType()) { 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 d28bb582a..c62d3e55b 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -85,7 +85,7 @@ public class TamingManager extends SkillManager { * @param damage The damage being absorbed by the wolf */ public void fastFoodService(Wolf wolf, int damage) { - if (getActivationChance() > Taming.fastFoodServiceActivationChance) { + if (Taming.fastFoodServiceActivationChance > Misc.getRandom().nextInt(getActivationChance())) { int health = wolf.getHealth(); int maxHealth = wolf.getMaxHealth(); From 1a66ff7659a8a1ab950cffbf6d2e2cb12719495d Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 4 Mar 2013 22:49:17 -0500 Subject: [PATCH 135/137] 1.4.02 bugfix release --- Changelog.txt | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 9d5576b43..6a695bd3f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,7 +7,7 @@ Key: ! Change - Removal -Version 1.4.02-dev +Version 1.4.02 + Added API to get the skill and power level caps. = Fixed bug where Deflect was calculated based on the attacker, not the defender = Fixed bug where some skills weren't registering as unlocked until one level later diff --git a/pom.xml b/pom.xml index df2dc5224..9b6689ad9 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.4.02-dev1 + 1.4.02 mcMMO https://github.com/mcMMO-Dev/mcMMO From 78a3ea47658e9ed74cf58deb6218361125e0c52c Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 4 Mar 2013 22:50:25 -0500 Subject: [PATCH 136/137] Back to active development --- Changelog.txt | 2 ++ pom.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 6a695bd3f..48cdd1627 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,8 @@ Key: ! Change - Removal +Version 1.4.03-dev + Version 1.4.02 + Added API to get the skill and power level caps. = Fixed bug where Deflect was calculated based on the attacker, not the defender diff --git a/pom.xml b/pom.xml index 9b6689ad9..9e7f242c9 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.4.02 + 1.4.03-dev1 mcMMO https://github.com/mcMMO-Dev/mcMMO From ae741a1b99d8e1e980e8d49aa7d74da90e90b8a4 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Tue, 5 Mar 2013 14:39:39 +0100 Subject: [PATCH 137/137] Fixed bug where players were unable to salvage leather armor. Closes #788 --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/util/ItemUtils.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 48cdd1627..69f728fa5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,7 @@ Key: - Removal Version 1.4.03-dev + = Fixed bug where players were unable to salvage leather armor Version 1.4.02 + Added API to get the skill and power level caps. diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index 94266a1fb..db6bd9311 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -264,7 +264,7 @@ public class ItemUtils { * @return true if the item is armor, false otherwise */ public static boolean isMinecraftArmor(ItemStack is) { - return isDiamondArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is); + return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is); } /**