From e5f6da01ec7a0f717e6de61de576ce560a3a05f2 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 09:37:09 -0500 Subject: [PATCH 01/94] Create a proper RepairManager to match the others, rename our old RepairManager to RepairableManager. --- .../commands/skills/RepairCommand.java | 15 +- .../nossr50/datatypes/player/McMMOPlayer.java | 5 + .../nossr50/listeners/BlockListener.java | 4 +- .../nossr50/listeners/PlayerListener.java | 4 +- src/main/java/com/gmail/nossr50/mcMMO.java | 10 +- .../gmail/nossr50/skills/repair/Repair.java | 302 ++++---------- .../nossr50/skills/repair/RepairManager.java | 373 +++++++++++++++--- .../skills/repair/RepairManagerFactory.java | 13 - .../skills/repair/RepairableManager.java | 45 +++ .../repair/RepairableManagerFactory.java | 13 + .../skills/repair/SimpleRepairManager.java | 214 ---------- .../repair/SimpleRepairableManager.java | 46 +++ 12 files changed, 511 insertions(+), 533 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/repair/RepairManagerFactory.java create mode 100644 src/main/java/com/gmail/nossr50/skills/repair/RepairableManager.java create mode 100644 src/main/java/com/gmail/nossr50/skills/repair/RepairableManagerFactory.java delete mode 100644 src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java create mode 100644 src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairableManager.java diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index a05c16527..e01fce126 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -9,6 +9,7 @@ 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; +import com.gmail.nossr50.util.player.UserManager; public class RepairCommand extends SkillCommand { private int arcaneForgingRank; @@ -41,10 +42,10 @@ public class RepairCommand extends SkillCommand { @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()); + Repairable diamondRepairable = mcMMO.repairableManager.getRepairable(Material.DIAMOND_PICKAXE.getId()); + Repairable goldRepairable = mcMMO.repairableManager.getRepairable(Material.GOLD_PICKAXE.getId()); + Repairable ironRepairable = mcMMO.repairableManager.getRepairable(Material.IRON_PICKAXE.getId()); + Repairable stoneRepairable = mcMMO.repairableManager.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(); @@ -66,7 +67,7 @@ public class RepairCommand extends SkillCommand { superRepairChanceLucky = superRepairStrings[1]; // ARCANE FORGING - arcaneForgingRank = Repair.getArcaneForgingRank(profile); + arcaneForgingRank = UserManager.getPlayer(player).getRepairManager().getArcaneForgingRank(); } @Override @@ -155,11 +156,11 @@ public class RepairCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank)); if (Repair.arcaneForgingEnchantLoss) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank)))); + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : UserManager.getPlayer(player).getRepairManager().getKeepEnchantChance()))); } if (Repair.arcaneForgingDowngrades) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank)))); + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : UserManager.getPlayer(player).getRepairManager().getDowngradeEnchantChance()))); } } } 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 7e89c7d59..55b367fc5 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -28,6 +28,7 @@ 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.repair.RepairManager; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.TamingManager; @@ -144,6 +145,10 @@ public class McMMOPlayer { return (MiningManager) skillManagers.get(SkillType.MINING); } + public RepairManager getRepairManager() { + return (RepairManager) skillManagers.get(SkillType.REPAIR); + } + public SmeltingManager getSmeltingManager() { return (SmeltingManager) skillManagers.get(SkillType.SMELTING); } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 930a6dbc0..4bd87939a 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -35,6 +35,7 @@ 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.RepairManager; import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.unarmed.Unarmed; @@ -116,10 +117,11 @@ public class BlockListener implements Listener { } if (Repair.anvilMessagesEnabled) { + RepairManager repairManager = UserManager.getPlayer(player).getRepairManager(); int blockID = blockState.getTypeId(); if (blockID == Repair.anvilID) { - Repair.placedAnvilCheck(player, blockID); + repairManager.placedAnvilCheck(blockID); } else if (blockID == Salvage.anvilID) { Salvage.placedAnvilCheck(player, blockID); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 76760c682..837794269 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -285,8 +285,8 @@ public class PlayerListener implements Listener { int blockID = block.getTypeId(); /* REPAIR CHECKS */ - if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairManager.isRepairable(heldItem)) { - mcMMO.repairManager.handleRepair(mcMMOPlayer, heldItem); + if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairableManager.isRepairable(heldItem)) { + UserManager.getPlayer(player).getRepairManager().handleRepair(heldItem); event.setCancelled(true); player.updateInventory(); } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 17b43990c..f4ec03e5c 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -45,8 +45,8 @@ 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.RepairableManager; +import com.gmail.nossr50.skills.repair.RepairableManagerFactory; import com.gmail.nossr50.skills.repair.Repairable; import com.gmail.nossr50.skills.repair.config.RepairConfigManager; import com.gmail.nossr50.util.LogFilter; @@ -71,7 +71,7 @@ public class mcMMO extends JavaPlugin { public static mcMMO p; public static ChunkManager placeStore; - public static RepairManager repairManager; + public static RepairableManager repairableManager; // Jar Stuff public static File mcmmo; @@ -377,8 +377,8 @@ public class mcMMO extends JavaPlugin { // 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); + repairableManager = RepairableManagerFactory.getRepairManager(repairables.size()); + repairableManager.registerRepairables(repairables); // Check if Repair Anvil and Salvage Anvil have different itemID's if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) { 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 b8e658c93..aa281c7a3 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -1,29 +1,46 @@ package com.gmail.nossr50.skills.repair; -import java.util.Map; -import java.util.Map.Entry; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.getspout.spoutapi.SpoutManager; -import org.getspout.spoutapi.player.SpoutPlayer; +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.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.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.player.UserManager; -import com.gmail.nossr50.util.skills.PerksUtils; public class Repair { + // The order of the values is extremely important, a few methods depend on it to work properly + protected enum Tier { + FOUR(4) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels4(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}, + THREE(3) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels3(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}, + TWO(2) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels2(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}, + ONE(1) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels1(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}; + + int numerical; + + private Tier(int numerical) { + this.numerical = numerical; + } + + public int toNumerical() { + return numerical; + } + + abstract protected int getLevel(); + abstract protected int getKeepEnchantChance(); + abstract protected int getDowngradeEnchantChance(); + } + public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel(); public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus(); @@ -37,244 +54,57 @@ public class Repair { public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled(); /** - * Get current Arcane Forging rank. + * Search the inventory for an item and return the index. * - * @param profile The PlayerProfile of the player to get the rank for - * @return The player's current Arcane Forging rank + * @param inventory PlayerInventory to scan + * @param itemId Item id to look for + * @return index location where the item was found, or -1 if not found */ - public static int getArcaneForgingRank(PlayerProfile profile) { - int skillLevel = profile.getSkillLevel(SkillType.REPAIR); + protected static int findInInventory(PlayerInventory inventory, int itemId) { + int location = inventory.first(itemId); - if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels4()) { - return 4; - } - else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels3()) { - return 3; - } - else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels2()) { - return 2; - } - else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels1()) { - return 1; - } - else { - return 0; + // VALIDATE + if (inventory.getItem(location).getTypeId() == itemId) { + return location; } + + return -1; } /** - * Handles removing & downgrading enchants. + * Search the inventory for an item and return the index. * - * @param player Player repairing the item - * @param is Item being repaired + * @param inventory PlayerInventory to scan + * @param itemId Item id to look for + * @param metadata Metadata to look for + * @return index location where the item was found, or -1 if not found */ - protected static void addEnchants(Player player, ItemStack is) { - if (Permissions.arcaneBypass(player)) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); - return; - } - Map enchants = is.getEnchantments(); + protected static int findInInventory(PlayerInventory inventory, int itemId, byte metadata) { + int location = -1; - if (enchants.size() == 0) { - return; - } - - int rank = getArcaneForgingRank(UserManager.getPlayer(player).getProfile()); - - if (rank == 0 || !Permissions.arcaneForging(player)) { - for (Enchantment x : enchants.keySet()) { - is.removeEnchantment(x); + for (ItemStack item : inventory.getContents()) { + if (item == null) { + continue; } - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost")); - return; - } - boolean downgraded = false; - - for (Entry enchant : enchants.entrySet()) { - Enchantment enchantment = enchant.getKey(); - - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.REPAIR); - - if (Misc.getRandom().nextInt(activationChance) <= getEnchantChance(rank)) { - int enchantLevel = enchant.getValue(); - - if (arcaneForgingDowngrades && enchantLevel > 1) { - if (Misc.getRandom().nextInt(activationChance) < getDowngradeChance(rank)) { - is.addEnchantment(enchantment, --enchantLevel); - downgraded = true; - } - } - } - else { - is.removeEnchantment(enchantment); + if (item.getTypeId() == itemId && item.getData().getData() == metadata) { + return location; } } - Map newEnchants = is.getEnchantments(); - - if (newEnchants.isEmpty()) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail")); - } - else if (downgraded || newEnchants.size() < enchants.size()) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade")); - } - else { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); - } + return location; } /** - * Gets chance of keeping enchantment during repair. + * Decrease the amount of items in this slot by one * - * @param rank Arcane Forging rank - * @return The chance of keeping the enchantment + * @param inventory PlayerInventory to work in + * @param index Item index to decrement */ - public static int getEnchantChance(int rank) { - switch (rank) { - case 4: - return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); + protected static void removeOneFrom(PlayerInventory inventory, int index) { + ItemStack item = inventory.getItem(index).clone(); + item.setAmount(1); - case 3: - return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); - - case 2: - return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); - - case 1: - return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); - - default: - return 0; - } - } - - /** - * Gets chance of enchantment being downgraded during repair. - * - * @param rank Arcane Forging rank - * @return The chance of the enchantment being downgraded - */ - public static int getDowngradeChance(int rank) { - switch (rank) { - case 4: - return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); - - case 3: - return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); - - case 2: - return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); - - case 1: - return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); - - default: - return 100; - } - } - - /** - * Checks for Super Repair bonus. - * - * @param player The player repairing an item - * @return true if bonus granted, false otherwise - */ - public static boolean checkPlayerProcRepair(Player player) { - int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR); - - int chance = (int) ((superRepairMaxChance / superRepairMaxBonusLevel) * skillLevel); - if (skillLevel >= superRepairMaxBonusLevel) { - chance = (int) superRepairMaxChance; - } - - int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.REPAIR); - - if (chance > Misc.getRandom().nextInt(activationChance) && Permissions.superRepair(player)) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy")); - return true; - } - return false; - } - - /** - * 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(Player player, int anvilID) { - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - - if (!mcMMOPlayer.getPlacedAnvil()) { - if (mcMMO.spoutEnabled) { - SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); - - if (spoutPlayer.isSpoutCraftEnabled()) { - spoutPlayer.sendNotification(LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2"), Material.getMaterial(anvilID)); - } - } - else { - player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil")); - } - - player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - mcMMOPlayer.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; + inventory.removeItem(item); } } 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 f7a2007e4..e3f509960 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -1,55 +1,318 @@ -package com.gmail.nossr50.skills.repair; - -import java.util.List; - -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.datatypes.player.McMMOPlayer; - -public interface RepairManager { - /** - * Register a repairable with the RepairManager - * - * @param repairable Repairable to register - */ - public void registerRepairable(Repairable repairable); - - /** - * Register a list of repairables with the RepairManager - * - * @param repairables List to register - */ - public void registerRepairables(List repairables); - - /** - * Checks if an item is repairable - * - * @param itemId id to check if repairable - * @return true if repairable, false if not - */ - public boolean isRepairable(int itemId); - - /** - * Checks if an item is repairable - * - * @param itemStack Item to check if repairable - * @return true if repairable, false if not - */ - public boolean isRepairable(ItemStack itemStack); - - /** - * Gets the repairable with this id - * - * @param id Id of the repairable to look for - * @return the repairable, can be null - */ - public Repairable getRepairable(int id); - - /** - * Handle the repairing of this object - * - * @param mcMMOPlayer Player that is repairing an item - * @param item ItemStack that is being repaired - */ - public void handleRepair(McMMOPlayer mcMMOPlayer, ItemStack item); -} +package com.gmail.nossr50.skills.repair; + +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.getspout.spoutapi.SpoutManager; +import org.getspout.spoutapi.player.SpoutPlayer; + +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.repair.McMMOPlayerRepairCheckEvent; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.repair.Repair.Tier; +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 RepairManager extends SkillManager { + public RepairManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.REPAIR); + } + + /** + * Handles notifications for placing an anvil. + * + * @param anvilID The item ID of the anvil block + */ + public void placedAnvilCheck(int anvilID) { + Player player = getPlayer(); + + if (mcMMOPlayer.getPlacedAnvil()) { + return; + } + + if (mcMMO.spoutEnabled) { + SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); + + if (spoutPlayer.isSpoutCraftEnabled()) { + spoutPlayer.sendNotification(LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2"), Material.getMaterial(anvilID)); + } + } + else { + player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil")); + } + + player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + mcMMOPlayer.togglePlacedAnvil(); + } + + public void handleRepair(ItemStack item) { + Player player = getPlayer(); + int itemId = item.getTypeId(); + + Repairable repairable = mcMMO.repairableManager.getRepairable(itemId); + + // Permissions checks on material and item types + if (!repairable.getRepairItemType().getPermissions(player)) { + player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); + return; + } + + if (!repairable.getRepairMaterialType().getPermissions(player)) { + player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); + return; + } + + int skillLevel = getSkillLevel(); + int minimumRepairableLevel = repairable.getMinimumLevel(); + + // Level check + if (skillLevel < minimumRepairableLevel) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", minimumRepairableLevel, StringUtils.getPrettyItemString(itemId))); + return; + } + + PlayerInventory inventory = player.getInventory(); + + int repairMaterialId = repairable.getRepairMaterialId(); + byte repairMaterialMetadata = repairable.getRepairMaterialMetadata(); + + // Check if they have the proper material to repair with + if (!inventory.contains(repairMaterialId)) { + String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterialId)); + + if (repairMaterialMetadata != (byte) -1) { + // TODO: Do something nicer than append the metadata as a :# ? + if (Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata) == -1) { + message += ":" + repairMaterialMetadata; + } + } + + player.sendMessage(message); + return; + } + + short startDurability = item.getDurability(); + + // Do not repair if at full durability + if (startDurability <= 0) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability")); + return; + } + + // Do not repair stacked items + if (item.getAmount() != 1) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems")); + 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? + short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons? + + // We're going to hold onto our repair item location + int repairItemLocation; + if (repairable.getRepairMaterialMetadata() == (byte) -1) { + repairItemLocation = Repair.findInInventory(inventory, repairMaterialId); + } + else { + // Special case for when the repairable has metadata that must be addressed + repairItemLocation = Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata); + } + + // This should never happen, but if it does we need to complain loudly about it. + if (repairItemLocation == -1) { + player.sendMessage(LocaleLoader.getString("Repair.Error")); + return; + } + + // Call event + McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), inventory.getItem(repairItemLocation), item); + mcMMO.p.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + + // Handle the enchants + if (Repair.arcaneForgingEnchantLoss) { + addEnchants(item); + } + + // Remove the item + Repair.removeOneFrom(inventory, repairItemLocation); + + // Give out XP like candy + applyXpGain((int) ((startDurability - newDurability) * repairable.getXpMultiplier()) * 10); + + // BWONG BWONG BWONG + player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + + // Repair the item! + item.setDurability(newDurability); + } + + /** + * Gets the Arcane Forging rank + * + * @return the current Arcane Forging rank + */ + public int getArcaneForgingRank() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.toNumerical(); + } + } + + return 0; + } + + /** + * Gets chance of keeping enchantment during repair. + * + * @return The chance of keeping the enchantment + */ + public int getKeepEnchantChance() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getKeepEnchantChance(); + } + } + + return 0; + } + + /** + * Gets chance of enchantment being downgraded during repair. + * + * @return The chance of the enchantment being downgraded + */ + public int getDowngradeEnchantChance() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getDowngradeEnchantChance(); + } + } + + return 100; + } + + /** + * Computes repair bonuses. + * + * @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 + */ + private short repairCalculate(short durability, int repairAmount) { + Player player = getPlayer(); + + if (Permissions.repairMastery(player)) { + double bonus = repairAmount * Math.min((((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * getSkillLevel()) / 100.0D), Repair.repairMasteryMaxBonus / 100.0D); + repairAmount += bonus; + } + + if (Permissions.superRepair(player) && checkPlayerProcRepair()) { + repairAmount *= 2.0D; + } + + if (repairAmount <= 0 || repairAmount > Short.MAX_VALUE) { + repairAmount = Short.MAX_VALUE; + } + + return (short) Math.max(durability - repairAmount, 0); + } + + /** + * Checks for Super Repair bonus. + * + * @return true if bonus granted, false otherwise + */ + private boolean checkPlayerProcRepair() { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Repair.superRepairMaxChance, Repair.superRepairMaxBonusLevel)) { + getPlayer().sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy")); + return true; + } + + return false; + } + + /** + * Handles removing & downgrading enchants. + * + * @param item Item being repaired + */ + private void addEnchants(ItemStack item) { + Player player = getPlayer(); + + if (Permissions.arcaneBypass(player)) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); + return; + } + + Map enchants = item.getEnchantments(); + + if (enchants.size() == 0) { + return; + } + + if (getArcaneForgingRank() == 0 || !Permissions.arcaneForging(player)) { + for (Enchantment enchant : enchants.keySet()) { + item.removeEnchantment(enchant); + } + + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost")); + return; + } + + boolean downgraded = false; + + for (Entry enchant : enchants.entrySet()) { + Enchantment enchantment = enchant.getKey(); + + if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) { + int enchantLevel = enchant.getValue(); + + if (Repair.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) { + item.addEnchantment(enchantment, enchantLevel--); + downgraded = true; + } + } + else { + item.removeEnchantment(enchantment); + } + } + + Map newEnchants = item.getEnchantments(); + + if (newEnchants.isEmpty()) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail")); + } + else if (downgraded || newEnchants.size() < enchants.size()) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade")); + } + else { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManagerFactory.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManagerFactory.java deleted file mode 100644 index dcdec8e6c..000000000 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManagerFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.gmail.nossr50.skills.repair; - -public class RepairManagerFactory { - public static RepairManager getRepairManager() { - // TODO: Add in loading from config what type of manager we want. - return new SimpleRepairManager(); - } - - public static RepairManager getRepairManager(int repairablesSize) { - // TODO: Add in loading from config what type of manager we want. - return new SimpleRepairManager(repairablesSize); - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairableManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairableManager.java new file mode 100644 index 000000000..41f1ab067 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairableManager.java @@ -0,0 +1,45 @@ +package com.gmail.nossr50.skills.repair; + +import java.util.List; + +import org.bukkit.inventory.ItemStack; + +public interface RepairableManager { + /** + * Register a repairable with the RepairManager + * + * @param repairable Repairable to register + */ + public void registerRepairable(Repairable repairable); + + /** + * Register a list of repairables with the RepairManager + * + * @param repairables List to register + */ + public void registerRepairables(List repairables); + + /** + * Checks if an item is repairable + * + * @param itemId id to check if repairable + * @return true if repairable, false if not + */ + public boolean isRepairable(int itemId); + + /** + * Checks if an item is repairable + * + * @param itemStack Item to check if repairable + * @return true if repairable, false if not + */ + public boolean isRepairable(ItemStack itemStack); + + /** + * Gets the repairable with this id + * + * @param id Id of the repairable to look for + * @return the repairable, can be null + */ + public Repairable getRepairable(int id); +} diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairableManagerFactory.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairableManagerFactory.java new file mode 100644 index 000000000..32cdd47b9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairableManagerFactory.java @@ -0,0 +1,13 @@ +package com.gmail.nossr50.skills.repair; + +public class RepairableManagerFactory { + public static RepairableManager getRepairManager() { + // TODO: Add in loading from config what type of manager we want. + return new SimpleRepairableManager(); + } + + public static RepairableManager getRepairManager(int repairablesSize) { + // TODO: Add in loading from config what type of manager we want. + return new SimpleRepairableManager(repairablesSize); + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java deleted file mode 100644 index ffdb1aa28..000000000 --- a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java +++ /dev/null @@ -1,214 +0,0 @@ -package com.gmail.nossr50.skills.repair; - -import java.util.HashMap; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; - -import com.gmail.nossr50.config.AdvancedConfig; -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.util.Permissions; -import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.skills.SkillUtils; - -public class SimpleRepairManager implements RepairManager { - private HashMap repairables; - - protected SimpleRepairManager() { - this(55); - } - - protected SimpleRepairManager(int repairablesSize) { - this.repairables = new HashMap(repairablesSize); - } - - @Override - public void registerRepairable(Repairable repairable) { - Integer itemId = repairable.getItemId(); - repairables.put(itemId, repairable); - } - - @Override - public void registerRepairables(List repairables) { - for (Repairable repairable : repairables) { - registerRepairable(repairable); - } - } - - @Override - public boolean isRepairable(int itemId) { - return repairables.containsKey(itemId); - } - - @Override - public boolean isRepairable(ItemStack itemStack) { - return isRepairable(itemStack.getTypeId()); - } - - @Override - public Repairable getRepairable(int id) { - return repairables.get(id); - } - - @Override - public void handleRepair(McMMOPlayer mcMMOPlayer, ItemStack item) { - Player player = mcMMOPlayer.getPlayer(); - Repairable repairable = repairables.get(item.getTypeId()); - - // Permissions checks on material and item types - if (!repairable.getRepairItemType().getPermissions(player)) { - player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); - return; - } - - if (!repairable.getRepairMaterialType().getPermissions(player)) { - player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); - return; - } - - int skillLevel = mcMMOPlayer.getProfile().getSkillLevel(SkillType.REPAIR); - - // Level check - if (skillLevel < repairable.getMinimumLevel()) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", repairable.getMinimumLevel(), StringUtils.getPrettyItemString(item.getTypeId()))); - return; - } - - PlayerInventory inventory = player.getInventory(); - - // Check if they have the proper material to repair with - if (!inventory.contains(repairable.getRepairMaterialId())) { - String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairable.getRepairMaterialId())); - if (repairable.getRepairMaterialMetadata() != (byte) -1) { - // TODO: Do something nicer than append the metadata as a :# ? - if (findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata()) == -1) { - message += ":" + repairable.getRepairMaterialMetadata(); - } - } - player.sendMessage(message); - return; - } - - short startDurability = item.getDurability(); - - // Do not repair if at full durability - if (startDurability <= 0) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability")); - return; - } - - // Do not repair stacked items - if (item.getAmount() != 1) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems")); - 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? - short newDurability = Repair.repairCalculate(player, skillLevel, startDurability, baseRepairAmount); // When I asked for sons? - - // We're going to hold onto our repair item location - int repairItemLocation; - if (repairable.getRepairMaterialMetadata() == (byte) -1) { - repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId()); - } - else { - // Special case for when the repairable has metadata that must be addressed - repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata()); - } - - // This should never happen, but if it does we need to complain loudly about it. - if (repairItemLocation == -1) { - player.sendMessage(LocaleLoader.getString("Repair.Error")); - return; - } - - // Call event - McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), inventory.getItem(repairItemLocation), item); - Bukkit.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - - // Handle the enchants - if (AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled() && !Permissions.arcaneBypass(player)) { - // Generalize away enchantment work - Repair.addEnchants(player, item); - } - - // Remove the item - removeOneFrom(inventory, repairItemLocation); - - // Give out XP like candy - Repair.xpHandler(mcMMOPlayer, startDurability, newDurability, repairable.getXpMultiplier()); - - // Repair the item! - item.setDurability(newDurability); - } - - /** - * Decrease the amount of items in this slot by one - * - * @param inventory PlayerInventory to work in - * @param index Item index to decrement - */ - private void removeOneFrom(PlayerInventory inventory, int index) { - ItemStack item = inventory.getItem(index).clone(); - item.setAmount(1); - - inventory.removeItem(item); - } - - /** - * Search the inventory for an item and return the index. - * - * @param inventory PlayerInventory to scan - * @param itemId Item id to look for - * @return index location where the item was found, or -1 if not found - */ - private int findInInventory(PlayerInventory inventory, int itemId) { - int location = inventory.first(itemId); - - // VALIDATE - if (inventory.getItem(location).getTypeId() == itemId) { - return location; - } - - return -1; - } - - /** - * Search the inventory for an item and return the index. - * - * @param inventory PlayerInventory to scan - * @param itemId Item id to look for - * @param metadata Metadata to look for - * @return index location where the item was found, or -1 if not found - */ - private int findInInventory(PlayerInventory inventory, int itemId, byte metadata) { - int location = -1; - - for (ItemStack item : inventory.getContents()) { - if (item == null) { - continue; - } - - if (item.getTypeId() == itemId && item.getData().getData() == metadata) { - return location; - } - } - - return location; - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairableManager.java b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairableManager.java new file mode 100644 index 000000000..ae1e7f089 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairableManager.java @@ -0,0 +1,46 @@ +package com.gmail.nossr50.skills.repair; + +import java.util.HashMap; +import java.util.List; + +import org.bukkit.inventory.ItemStack; + +public class SimpleRepairableManager implements RepairableManager { + private HashMap repairables; + + protected SimpleRepairableManager() { + this(55); + } + + protected SimpleRepairableManager(int repairablesSize) { + this.repairables = new HashMap(repairablesSize); + } + + @Override + public void registerRepairable(Repairable repairable) { + Integer itemId = repairable.getItemId(); + repairables.put(itemId, repairable); + } + + @Override + public void registerRepairables(List repairables) { + for (Repairable repairable : repairables) { + registerRepairable(repairable); + } + } + + @Override + public boolean isRepairable(int itemId) { + return repairables.containsKey(itemId); + } + + @Override + public boolean isRepairable(ItemStack itemStack) { + return isRepairable(itemStack.getTypeId()); + } + + @Override + public Repairable getRepairable(int id) { + return repairables.get(id); + } +} From 5f4e269efa1bbbb3441b56977bfb6d7f3f215743 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 09:43:09 -0500 Subject: [PATCH 02/94] Fixed bug with repairing using materials with byte metadata --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/skills/repair/Repair.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 69f728fa5..ca84bffad 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ Key: Version 1.4.03-dev = Fixed bug where players were unable to salvage leather armor + = Fixed bug with repairing using materials with byte metadata Version 1.4.02 + Added API to get the skill and power level caps. 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 aa281c7a3..e2cd49f31 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -82,13 +82,17 @@ public class Repair { protected static int findInInventory(PlayerInventory inventory, int itemId, byte metadata) { int location = -1; - for (ItemStack item : inventory.getContents()) { + ItemStack[] contents = inventory.getContents(); + + for (int i = 0; i < contents.length; i++) { + ItemStack item = contents[i]; + if (item == null) { continue; } if (item.getTypeId() == itemId && item.getData().getData() == metadata) { - return location; + return i; } } From 08960a2dbc98471399ec724e36277d142434f057 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 10:02:34 -0500 Subject: [PATCH 03/94] Move Salvage checks into our RepairManager --- .../nossr50/listeners/BlockListener.java | 12 +--- .../nossr50/listeners/PlayerListener.java | 2 +- .../nossr50/skills/repair/RepairManager.java | 66 ++++++++++++++++- .../gmail/nossr50/skills/repair/Salvage.java | 72 +------------------ 4 files changed, 69 insertions(+), 83 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 4bd87939a..608dc2179 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -35,8 +35,6 @@ 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.RepairManager; -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; @@ -117,15 +115,7 @@ public class BlockListener implements Listener { } if (Repair.anvilMessagesEnabled) { - RepairManager repairManager = UserManager.getPlayer(player).getRepairManager(); - int blockID = blockState.getTypeId(); - - if (blockID == Repair.anvilID) { - repairManager.placedAnvilCheck(blockID); - } - else if (blockID == Salvage.anvilID) { - Salvage.placedAnvilCheck(player, blockID); - } + UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId()); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 837794269..d335c10b8 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -292,7 +292,7 @@ public class PlayerListener implements Listener { } /* SALVAGE CHECKS */ else if (blockID == Salvage.anvilID && Permissions.salvage(player) && Salvage.isSalvageable(heldItem)) { - Salvage.handleSalvage(player, block.getLocation(), heldItem); + UserManager.getPlayer(player).getRepairManager().handleSalvage(block.getLocation(), heldItem); event.setCancelled(true); player.updateInventory(); } 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 e3f509960..f3b07dc06 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -3,6 +3,8 @@ package com.gmail.nossr50.skills.repair; import java.util.Map; import java.util.Map.Entry; +import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.enchantments.Enchantment; @@ -13,6 +15,7 @@ import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.player.SpoutPlayer; 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.events.skills.repair.McMMOPlayerRepairCheckEvent; @@ -29,12 +32,21 @@ public class RepairManager extends SkillManager { super(mcMMOPlayer, SkillType.REPAIR); } + public void placedAnvilCheck(int anvilId) { + if (anvilId == Repair.anvilID) { + repairAnvilCheck(anvilId); + } + else if (anvilId == Salvage.anvilID) { + salvageAnvilCheck(anvilId); + } + } + /** * Handles notifications for placing an anvil. * * @param anvilID The item ID of the anvil block */ - public void placedAnvilCheck(int anvilID) { + public void repairAnvilCheck(int anvilID) { Player player = getPlayer(); if (mcMMOPlayer.getPlacedAnvil()) { @@ -56,6 +68,32 @@ public class RepairManager extends SkillManager { mcMMOPlayer.togglePlacedAnvil(); } + /** + * Handles notifications for placing an anvil. + * + * @param player The player placing the anvil + * @param anvilID The item ID of the anvil block + */ + public void salvageAnvilCheck(int anvilID) { + Player player = getPlayer(); + + if (!mcMMOPlayer.getPlacedSalvageAnvil()) { + if (mcMMO.spoutEnabled) { + final SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); + + if (spoutPlayer.isSpoutCraftEnabled()) { + spoutPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to salvage!", Material.getMaterial(anvilID)); + } + } + else { + player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil2")); + } + + player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + mcMMOPlayer.togglePlacedSalvageAnvil(); + } + } + public void handleRepair(ItemStack item) { Player player = getPlayer(); int itemId = item.getTypeId(); @@ -166,6 +204,32 @@ public class RepairManager extends SkillManager { item.setDurability(newDurability); } + public void handleSalvage(Location location, ItemStack item) { + Player player = getPlayer(); + + if (!Config.getInstance().getSalvageEnabled() || player.getGameMode() != GameMode.SURVIVAL) { + return; + } + + if (getSkillLevel() < Salvage.salvageUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage")); + return; + } + + if (item.getDurability() == 0) { + player.setItemInHand(new ItemStack(Material.AIR)); + location.setY(location.getY() + 1); + + Misc.dropItems(location, new ItemStack(Salvage.getSalvagedItem(item)), Salvage.getSalvagedAmount(item)); + + player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess")); + } + else { + player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability")); + } + } + /** * Gets the Arcane Forging rank * 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 912abf387..9a1d32f27 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -1,83 +1,15 @@ package com.gmail.nossr50.skills.repair; -import org.bukkit.GameMode; -import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.getspout.spoutapi.SpoutManager; -import org.getspout.spoutapi.player.SpoutPlayer; -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.util.ItemUtils; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.player.UserManager; public class Salvage { 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 (!Config.getInstance().getSalvageEnabled()) { - return; - } - - if (player.getGameMode() == GameMode.SURVIVAL) { - final int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR); - - if (skillLevel < salvageUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage")); - return; - } - - final float currentDurability = item.getDurability(); - - if (currentDurability == 0) { - player.setItemInHand(new ItemStack(Material.AIR)); - location.setY(location.getY() + 1); - - Misc.dropItems(location, new ItemStack(getSalvagedItem(item)), getSalvagedAmount(item)); - - player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess")); - } - else { - 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) { - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - - if (!mcMMOPlayer.getPlacedSalvageAnvil()) { - if (mcMMO.spoutEnabled) { - final SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); - - if (spoutPlayer.isSpoutCraftEnabled()) { - spoutPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to salvage!", Material.getMaterial(anvilID)); - } - } - else { - player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil2")); - } - - player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - mcMMOPlayer.togglePlacedSalvageAnvil(); - } - } - /** * Checks if the item is salvageable. * @@ -96,7 +28,7 @@ public class Salvage { return false; } - private static Material getSalvagedItem(final ItemStack inHand) { + protected static Material getSalvagedItem(final ItemStack inHand) { if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) { return Material.DIAMOND; } @@ -123,7 +55,7 @@ public class Salvage { } } - private static int getSalvagedAmount(final ItemStack inHand) { + protected static int getSalvagedAmount(final ItemStack inHand) { if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) { return 3; } From 6b18cec7fb4a65aa6907d08f160f290e66ac7236 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 10:47:56 -0500 Subject: [PATCH 04/94] Combine our placedAnvil checks into one function. --- .../nossr50/datatypes/player/McMMOPlayer.java | 36 ++++++++------ .../nossr50/listeners/BlockListener.java | 6 ++- .../gmail/nossr50/skills/repair/Repair.java | 25 ++++++++++ .../nossr50/skills/repair/RepairManager.java | 49 ++++--------------- 4 files changed, 58 insertions(+), 58 deletions(-) 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 55b367fc5..63d1e283c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -28,7 +28,9 @@ 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.repair.Repair; import com.gmail.nossr50.skills.repair.RepairManager; +import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.TamingManager; @@ -66,7 +68,7 @@ public class McMMOPlayer { private boolean displaySkillNotifications = true; private boolean abilityUse = true; - private boolean placedAnvil; + private boolean placedRepairAnvil; private boolean placedSalvageAnvil; private boolean godMode; @@ -313,24 +315,26 @@ public class McMMOPlayer { * Repair Anvil Placement */ - public void togglePlacedAnvil() { - placedAnvil = !placedAnvil; + public boolean getPlacedAnvil(int anvilId) { + if (anvilId == Repair.anvilID) { + return placedRepairAnvil; + } + + if (anvilId == Salvage.anvilID) { + return placedSalvageAnvil; + } + + return true; } - public Boolean getPlacedAnvil() { - return placedAnvil; - } + public void togglePlacedAnvil(int anvilId) { + if (anvilId == Repair.anvilID) { + placedRepairAnvil = !placedRepairAnvil; + } - /* - * Salvage Anvil Placement - */ - - public void togglePlacedSalvageAnvil() { - placedSalvageAnvil = !placedSalvageAnvil; - } - - public Boolean getPlacedSalvageAnvil() { - return placedSalvageAnvil; + if (anvilId == Salvage.anvilID) { + placedSalvageAnvil = !placedSalvageAnvil; + } } /* diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 608dc2179..5913bc903 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -35,6 +35,7 @@ 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; @@ -108,14 +109,15 @@ public class BlockListener implements Listener { } BlockState blockState = event.getBlock().getState(); + int blockId = blockState.getTypeId(); /* Check if the blocks placed should be monitored so they do not give out XP in the future */ if (BlockUtils.shouldBeWatched(blockState)) { mcMMO.placeStore.setTrue(blockState); } - if (Repair.anvilMessagesEnabled) { - UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId()); + if (Repair.anvilMessagesEnabled && (blockId == Repair.anvilID || blockId == Salvage.anvilID)) { + UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId); } } 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 e2cd49f31..b56b92be4 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -5,6 +5,7 @@ import org.bukkit.inventory.PlayerInventory; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; public class Repair { // The order of the values is extremely important, a few methods depend on it to work properly @@ -111,4 +112,28 @@ public class Repair { inventory.removeItem(item); } + + protected static String[] getSpoutAnvilMessages(int blockId) { + if (blockId == Repair.anvilID) { + return new String[] {LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2")}; + } + + if (blockId == Salvage.anvilID) { + return new String[] {"[mcMMO] Anvil Placed", "Right click to salvage!"}; + } + + return new String[] {"", ""}; + } + + protected static String getAnvilMessage(int blockId) { + if (blockId == Repair.anvilID) { + return LocaleLoader.getString("Repair.Listener.Anvil"); + } + + if (blockId == Salvage.anvilID) { + return LocaleLoader.getString("Repair.Listener.Anvil2"); + } + + return ""; + } } 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 f3b07dc06..5f8004e5e 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -32,24 +32,15 @@ public class RepairManager extends SkillManager { super(mcMMOPlayer, SkillType.REPAIR); } - public void placedAnvilCheck(int anvilId) { - if (anvilId == Repair.anvilID) { - repairAnvilCheck(anvilId); - } - else if (anvilId == Salvage.anvilID) { - salvageAnvilCheck(anvilId); - } - } - /** * Handles notifications for placing an anvil. * * @param anvilID The item ID of the anvil block */ - public void repairAnvilCheck(int anvilID) { + public void placedAnvilCheck(int anvilId) { Player player = getPlayer(); - if (mcMMOPlayer.getPlacedAnvil()) { + if (mcMMOPlayer.getPlacedAnvil(anvilId)) { return; } @@ -57,41 +48,19 @@ public class RepairManager extends SkillManager { SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); if (spoutPlayer.isSpoutCraftEnabled()) { - spoutPlayer.sendNotification(LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2"), Material.getMaterial(anvilID)); + String[] spoutMessages = Repair.getSpoutAnvilMessages(anvilId); + spoutPlayer.sendNotification(spoutMessages[0], spoutMessages[1], Material.getMaterial(anvilId)); + } + else { + player.sendMessage(Repair.getAnvilMessage(anvilId)); } } else { - player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil")); + player.sendMessage(Repair.getAnvilMessage(anvilId)); } player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - mcMMOPlayer.togglePlacedAnvil(); - } - - /** - * Handles notifications for placing an anvil. - * - * @param player The player placing the anvil - * @param anvilID The item ID of the anvil block - */ - public void salvageAnvilCheck(int anvilID) { - Player player = getPlayer(); - - if (!mcMMOPlayer.getPlacedSalvageAnvil()) { - if (mcMMO.spoutEnabled) { - final SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); - - if (spoutPlayer.isSpoutCraftEnabled()) { - spoutPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to salvage!", Material.getMaterial(anvilID)); - } - } - else { - player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil2")); - } - - player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - mcMMOPlayer.togglePlacedSalvageAnvil(); - } + mcMMOPlayer.togglePlacedAnvil(anvilId); } public void handleRepair(ItemStack item) { From 2c7f931c4de606bcd61345442f883d78809d6a9c Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 10:50:59 -0500 Subject: [PATCH 05/94] Removed option to disable Salvage via the config file. This should be handled via permissions instead. --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/config/Config.java | 1 - .../java/com/gmail/nossr50/skills/repair/RepairManager.java | 2 +- src/main/resources/config.yml | 1 - 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index ca84bffad..d68d29e9a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Key: Version 1.4.03-dev = Fixed bug where players were unable to salvage leather armor = Fixed bug with repairing using materials with byte metadata + - Removed option to disable Salvage via the config file. This should be handled via permissions instead. Version 1.4.02 + Added API to get the skill and power level caps. diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 86d6ee56b..93f3e8bad 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -183,7 +183,6 @@ public class Config extends AutoUpdateConfigLoader { /* Repair */ public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); } public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); } - public boolean getSalvageEnabled() { return config.getBoolean("Skills.Repair.Salvage_enabled", true); } public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); } public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); } public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); } 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 5f8004e5e..12e5436e9 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -176,7 +176,7 @@ public class RepairManager extends SkillManager { public void handleSalvage(Location location, ItemStack item) { Player player = getPlayer(); - if (!Config.getInstance().getSalvageEnabled() || player.getGameMode() != GameMode.SURVIVAL) { + if (player.getGameMode() != GameMode.SURVIVAL) { return; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7466dcc75..af3d51c3a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -160,7 +160,6 @@ Skills: Level_Cap: 0 Anvil_Messages: true Anvil_ID: 42 - Salvage_enabled: true Salvage_Anvil_ID: 41 Salvage_UnlockLevel: 600 Salvage_tools: true From 3e084b3b5d8ef53ee79b70a217ca27efdc1a6c3a Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 11:05:41 -0500 Subject: [PATCH 06/94] Unlock levels go in advanced.yml, not config.yml --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/config/AdvancedConfig.java | 1 + src/main/java/com/gmail/nossr50/config/Config.java | 1 - .../java/com/gmail/nossr50/skills/repair/RepairManager.java | 1 - src/main/java/com/gmail/nossr50/skills/repair/Salvage.java | 3 ++- src/main/resources/advanced.yml | 3 +++ src/main/resources/config.yml | 1 - 7 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index d68d29e9a..8f6d2b5da 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Key: Version 1.4.03-dev = Fixed bug where players were unable to salvage leather armor = Fixed bug with repairing using materials with byte metadata + ! Moved the Salvage unlock level from config.yml to advanced.yml - Removed option to disable Salvage via the config file. This should be handled via permissions instead. Version 1.4.02 diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index d1c3cdec4..b47796208 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -178,6 +178,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); } public double getSuperRepairChanceMax() { return config.getDouble("Skills.Repair.SuperRepair_ChanceMax", 100.0D); } public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); } + public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); } /* Arcane Forging */ public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.Downgrades.Enabled", true); } diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 93f3e8bad..eae117ec7 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -184,7 +184,6 @@ public class Config extends AutoUpdateConfigLoader { public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); } public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); } public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); } - public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); } public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); } public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); } 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 12e5436e9..478530de3 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -15,7 +15,6 @@ import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.player.SpoutPlayer; 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.events.skills.repair.McMMOPlayerRepairCheckEvent; 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 9a1d32f27..42a651b61 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -3,11 +3,12 @@ package com.gmail.nossr50.skills.repair; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.util.ItemUtils; public class Salvage { - public static int salvageUnlockLevel = Config.getInstance().getSalvageUnlockLevel(); + public static int salvageUnlockLevel = AdvancedConfig.getInstance().getSalvageUnlockLevel(); public static int anvilID = Config.getInstance().getSalvageAnvilId(); /** diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index ec35aa44a..1c1b4dacf 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -247,6 +247,9 @@ Skills: SuperRepair_ChanceMax: 100.0 SuperRepair_MaxBonusLevel: 1000 + # Salvage_UnlockLevel: Level when Salvage become available + Salvage_UnlockLevel: 600 + Arcane_Forging: May_Lose_Enchants: true Rank_Levels: diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index af3d51c3a..5f6e22ff4 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -161,7 +161,6 @@ Skills: Anvil_Messages: true Anvil_ID: 42 Salvage_Anvil_ID: 41 - Salvage_UnlockLevel: 600 Salvage_tools: true Salvage_armor: true Smelting: From f6a18ef777b95f040733f3a02204e14346ab5afc Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 11:31:51 -0500 Subject: [PATCH 07/94] Move Salvage functions into Repair --- .../commands/skills/RepairCommand.java | 5 +- .../nossr50/datatypes/player/McMMOPlayer.java | 9 +- .../nossr50/listeners/BlockListener.java | 3 +- .../nossr50/listeners/PlayerListener.java | 5 +- .../gmail/nossr50/skills/repair/Repair.java | 87 +++++++++++++++++-- .../nossr50/skills/repair/RepairManager.java | 4 +- .../gmail/nossr50/skills/repair/Salvage.java | 85 ------------------ 7 files changed, 93 insertions(+), 105 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/repair/Salvage.java diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index e01fce126..6f6f56a45 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -7,7 +7,6 @@ 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; import com.gmail.nossr50.util.player.UserManager; @@ -123,8 +122,8 @@ public class RepairCommand extends SkillCommand { 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 (canSalvage && Repair.salvageUnlockLevel > 0) { + player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17"))); } if (canArcaneForge) { 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 63d1e283c..3d8d6392a 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -30,7 +30,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.RepairManager; -import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.TamingManager; @@ -316,11 +315,11 @@ public class McMMOPlayer { */ public boolean getPlacedAnvil(int anvilId) { - if (anvilId == Repair.anvilID) { + if (anvilId == Repair.repairAnvilId) { return placedRepairAnvil; } - if (anvilId == Salvage.anvilID) { + if (anvilId == Repair.salvageAnvilId) { return placedSalvageAnvil; } @@ -328,11 +327,11 @@ public class McMMOPlayer { } public void togglePlacedAnvil(int anvilId) { - if (anvilId == Repair.anvilID) { + if (anvilId == Repair.repairAnvilId) { placedRepairAnvil = !placedRepairAnvil; } - if (anvilId == Salvage.anvilID) { + if (anvilId == Repair.salvageAnvilId) { placedSalvageAnvil = !placedSalvageAnvil; } } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 5913bc903..4ce6d067d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -35,7 +35,6 @@ 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; @@ -116,7 +115,7 @@ public class BlockListener implements Listener { mcMMO.placeStore.setTrue(blockState); } - if (Repair.anvilMessagesEnabled && (blockId == Repair.anvilID || blockId == Salvage.anvilID)) { + if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) { UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index d335c10b8..4358662a9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -39,7 +39,6 @@ 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; @@ -285,13 +284,13 @@ public class PlayerListener implements Listener { int blockID = block.getTypeId(); /* REPAIR CHECKS */ - if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairableManager.isRepairable(heldItem)) { + if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairableManager.isRepairable(heldItem)) { UserManager.getPlayer(player).getRepairManager().handleRepair(heldItem); event.setCancelled(true); player.updateInventory(); } /* SALVAGE CHECKS */ - else if (blockID == Salvage.anvilID && Permissions.salvage(player) && Salvage.isSalvageable(heldItem)) { + else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) { UserManager.getPlayer(player).getRepairManager().handleSalvage(block.getLocation(), heldItem); event.setCancelled(true); player.updateInventory(); 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 b56b92be4..511a69062 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -1,11 +1,13 @@ package com.gmail.nossr50.skills.repair; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.ItemUtils; public class Repair { // The order of the values is extremely important, a few methods depend on it to work properly @@ -51,9 +53,30 @@ public class Repair { public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled(); public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled(); - public static int anvilID = Config.getInstance().getRepairAnvilId(); + public static int salvageUnlockLevel = AdvancedConfig.getInstance().getSalvageUnlockLevel(); + + public static int salvageAnvilId = Config.getInstance().getSalvageAnvilId(); + public static int repairAnvilId = Config.getInstance().getRepairAnvilId(); public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled(); + /** + * Checks if the item is salvageable. + * + * @param item Item to check + * @return true if the item is salvageable, false otherwise + */ + public static boolean isSalvageable(ItemStack item) { + if (Config.getInstance().getSalvageTools() && (ItemUtils.isMinecraftTool(item) || ItemUtils.isStringTool(item) || item.getType() == Material.BUCKET)) { + return true; + } + + if (Config.getInstance().getSalvageArmor() && ItemUtils.isMinecraftArmor(item)) { + return true; + } + + return false; + } + /** * Search the inventory for an item and return the index. * @@ -114,11 +137,11 @@ public class Repair { } protected static String[] getSpoutAnvilMessages(int blockId) { - if (blockId == Repair.anvilID) { + if (blockId == repairAnvilId) { return new String[] {LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2")}; } - if (blockId == Salvage.anvilID) { + if (blockId == salvageAnvilId) { return new String[] {"[mcMMO] Anvil Placed", "Right click to salvage!"}; } @@ -126,14 +149,68 @@ public class Repair { } protected static String getAnvilMessage(int blockId) { - if (blockId == Repair.anvilID) { + if (blockId == repairAnvilId) { return LocaleLoader.getString("Repair.Listener.Anvil"); } - if (blockId == Salvage.anvilID) { + if (blockId == salvageAnvilId) { return LocaleLoader.getString("Repair.Listener.Anvil2"); } return ""; } + + protected static Material getSalvagedItem(ItemStack inHand) { + if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) { + return Material.DIAMOND; + } + else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) { + return Material.GOLD_INGOT; + } + else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) { + return Material.IRON_INGOT; + } + else if (ItemUtils.isStoneTool(inHand)) { + return Material.COBBLESTONE; + } + else if (ItemUtils.isWoodTool(inHand)) { + return Material.WOOD; + } + else if (ItemUtils.isLeatherArmor(inHand)) { + return Material.LEATHER; + } + else if (ItemUtils.isStringTool(inHand)) { + return Material.STRING; + } + else { + return null; + } + } + + protected static int getSalvagedAmount(ItemStack inHand) { + if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) { + return 3; + } + else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) { + return 1; + } + 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 (ItemUtils.isHelmet(inHand)) { + return 5; + } + else if (ItemUtils.isChestplate(inHand)) { + return 8; + } + else if (ItemUtils.isLeggings(inHand)) { + return 7; + } + else if (ItemUtils.isBoots(inHand)) { + return 4; + } + else { + return 0; + } + } } 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 478530de3..a4ac95751 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -179,7 +179,7 @@ public class RepairManager extends SkillManager { return; } - if (getSkillLevel() < Salvage.salvageUnlockLevel) { + if (getSkillLevel() < Repair.salvageUnlockLevel) { player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage")); return; } @@ -188,7 +188,7 @@ public class RepairManager extends SkillManager { player.setItemInHand(new ItemStack(Material.AIR)); location.setY(location.getY() + 1); - Misc.dropItems(location, new ItemStack(Salvage.getSalvagedItem(item)), Salvage.getSalvagedAmount(item)); + Misc.dropItems(location, new ItemStack(Repair.getSalvagedItem(item)), Repair.getSalvagedAmount(item)); player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess")); diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java deleted file mode 100644 index 42a651b61..000000000 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.gmail.nossr50.skills.repair; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.util.ItemUtils; - -public class Salvage { - public static int salvageUnlockLevel = AdvancedConfig.getInstance().getSalvageUnlockLevel(); - public static int anvilID = Config.getInstance().getSalvageAnvilId(); - - /** - * 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; - } - - protected static Material getSalvagedItem(final ItemStack inHand) { - if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) { - return Material.DIAMOND; - } - else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) { - return Material.GOLD_INGOT; - } - else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) { - return Material.IRON_INGOT; - } - else if (ItemUtils.isStoneTool(inHand)) { - return Material.COBBLESTONE; - } - else if (ItemUtils.isWoodTool(inHand)) { - return Material.WOOD; - } - else if (ItemUtils.isLeatherArmor(inHand)) { - return Material.LEATHER; - } - else if (ItemUtils.isStringTool(inHand)) { - return Material.STRING; - } - else { - return null; - } - } - - protected static int getSalvagedAmount(final ItemStack inHand) { - if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) { - return 3; - } - else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) { - return 1; - } - 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 (ItemUtils.isHelmet(inHand)) { - return 5; - } - else if (ItemUtils.isChestplate(inHand)) { - return 8; - } - else if (ItemUtils.isLeggings(inHand)) { - return 7; - } - else if (ItemUtils.isBoots(inHand)) { - return 4; - } - else { - return 0; - } - } -} From 869d731b81184ed3fd63949ef8bf687e033e16a3 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 12:19:57 -0500 Subject: [PATCH 08/94] We now have a RepairManager. --- .../java/com/gmail/nossr50/datatypes/skills/SkillType.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 565ee66de..70673716f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java @@ -11,6 +11,7 @@ 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.repair.RepairManager; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.TamingManager; @@ -25,7 +26,7 @@ public enum SkillType { 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 + REPAIR(RepairManager.class), SMELTING(SmeltingManager.class), SWORDS(SwordsManager.class, AbilityType.SERRATED_STRIKES, ToolType.SWORD), TAMING(TamingManager.class), From 91d8cd5da89297202f34ead29c3f56fc2edb1cbc Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 12:21:02 -0500 Subject: [PATCH 09/94] Reorganize our imports after Repair refactoring. --- src/main/java/com/gmail/nossr50/mcMMO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index f4ec03e5c..261b005c3 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -45,9 +45,9 @@ 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.Repairable; import com.gmail.nossr50.skills.repair.RepairableManager; import com.gmail.nossr50.skills.repair.RepairableManagerFactory; -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; From 80927417f2169adefad0af4ae970e6843181ef01 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Wed, 6 Mar 2013 22:20:11 +0100 Subject: [PATCH 10/94] Fix the update checker Now it's able to parse x.x.x-type-bxxx and x.x.x-bxxx --- .../java/com/gmail/nossr50/util/UpdateChecker.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/UpdateChecker.java b/src/main/java/com/gmail/nossr50/util/UpdateChecker.java index ea57f3ea9..3ff13d750 100644 --- a/src/main/java/com/gmail/nossr50/util/UpdateChecker.java +++ b/src/main/java/com/gmail/nossr50/util/UpdateChecker.java @@ -43,12 +43,18 @@ public class UpdateChecker { jo = (JSONObject) jo.get("versions"); newVersion = (String) jo.get("version"); - String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]"); - String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]"); + String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b"); + String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b"); for (int i = 0; i < 4; i++) { Integer newVer = Integer.parseInt(newTokens[i]); - Integer oldVer = Integer.parseInt(oldTokens[i]); + Integer oldVer; + try { + oldVer = Integer.parseInt(oldTokens[i]); + } + catch (NumberFormatException e) { + oldVer = 0; + } if (oldVer < newVer) { isr.close(); return true; From c1161da6de1c6cba2fb5c91fb56f9a4201d235fb Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 12:32:13 -0500 Subject: [PATCH 11/94] We don't use this function anymore. --- .../gmail/nossr50/util/skills/SkillUtils.java | 16 ---------------- 1 file changed, 16 deletions(-) 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 8f3cbf82d..8b1f8e0bf 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -460,22 +460,6 @@ public class SkillUtils { } } - /** - * 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(); From 44ede5c3f8a7818f69cc46f895794f74a30ad35c Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 16:23:19 -0500 Subject: [PATCH 12/94] Create a WoodcuttingManager --- .../nossr50/datatypes/player/McMMOPlayer.java | 12 +- .../nossr50/datatypes/skills/SkillType.java | 3 +- .../nossr50/listeners/BlockListener.java | 35 +-- .../skills/woodcutting/TreeFeller.java | 276 ------------------ .../skills/woodcutting/Woodcutting.java | 187 ++++++++---- .../woodcutting/WoodcuttingManager.java | 192 ++++++++++++ 6 files changed, 344 insertions(+), 361 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java create mode 100644 src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java 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 3d8d6392a..56e84f4f9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -34,6 +34,7 @@ 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.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ModUtils; import com.gmail.nossr50.util.Permissions; @@ -94,12 +95,7 @@ public class McMMOPlayer { */ 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)); - } + skillManagers.put(skillType, skillType.getManagerClass().getConstructor(McMMOPlayer.class).newInstance(this)); } } catch (Exception e) { @@ -166,6 +162,10 @@ public class McMMOPlayer { return (UnarmedManager) skillManagers.get(SkillType.UNARMED); } + public WoodcuttingManager getWoodcuttingManager() { + return (WoodcuttingManager) skillManagers.get(SkillType.WOODCUTTING); + } + /* * Abilities */ 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 70673716f..9a2146aca 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java @@ -16,6 +16,7 @@ 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.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.StringUtils; public enum SkillType { @@ -31,7 +32,7 @@ public enum SkillType { 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 + WOODCUTTING(WoodcuttingManager.class, AbilityType.TREE_FELLER, ToolType.AXE); private Class managerClass; private AbilityType ability; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 4ce6d067d..d89e6dc74 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -20,8 +20,6 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; 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.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.AbilityType; @@ -37,7 +35,7 @@ import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; 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.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; @@ -179,18 +177,13 @@ public class BlockListener implements Listener { /* WOOD CUTTING */ else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) { - if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) { - Woodcutting.beginTreeFeller(blockState, player); + WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); + + if (woodcuttingManager.canUseTreeFeller(heldItem)) { + woodcuttingManager.processTreeFeller(blockState); } else { - if (Config.getInstance().getWoodcuttingRequiresTool()) { - if (ItemUtils.isAxe(heldItem)) { - Woodcutting.beginWoodcutting(player, blockState); - } - } - else { - Woodcutting.beginWoodcutting(player, blockState); - } + woodcuttingManager.woodcuttingBlockCheck(blockState); } } @@ -367,18 +360,10 @@ public class BlockListener implements Listener { } } } - 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)) { - event.setInstaBreak(true); - Woodcutting.beginLeafBlower(player, blockState); - } - } - else if (!(heldItem.getType() == Material.SHEARS)) { - event.setInstaBreak(true); - Woodcutting.beginLeafBlower(player, blockState); - } + else if (BlockUtils.isLeaves(blockState)) { + if (UserManager.getPlayer(player).getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) { + event.setInstaBreak(true); + player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java deleted file mode 100644 index 6e813f352..000000000 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ /dev/null @@ -1,276 +0,0 @@ -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 47df1d5c2..cb99beb9c 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -1,10 +1,12 @@ 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.Sound; import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.material.Tree; @@ -12,18 +14,17 @@ 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.BlockUtils; 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(); + public static int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel(); + public static int treeFellerThreshold = Config.getInstance().getTreeFellerThreshold(); + protected enum ExperienceGainMethod { DEFAULT, TREE_FELLER, @@ -31,47 +32,6 @@ public final class Woodcutting { 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 * @@ -126,11 +86,7 @@ public final class Woodcutting { * @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; - } - + protected static void checkForDoubleDrop(BlockState blockState) { if (ModUtils.isCustomLogBlock(blockState)) { CustomBlock customBlock = ModUtils.getCustomBlock(blockState); int minimumDropAmount = customBlock.getMinimumDropAmount(); @@ -179,4 +135,129 @@ public final class Woodcutting { } } } + + /** + * Processes Tree Feller for generic Trees + * + * @param blockState Block being checked + * @param treeFellerBlocks List of blocks to be removed + */ + protected static void processRegularTrees(BlockState blockState, List treeFellerBlocks) { + List futureCenterBlocks = new ArrayList(); + + // 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 = blockState.getBlock().getRelative(x, y, z).getState(); + handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks); + + if (WoodcuttingManager.treeFellerReachedThreshold) { + return; + } + } + } + } + + // Recursive call for each log found + for (BlockState futureCenterBlock : futureCenterBlocks) { + if (WoodcuttingManager.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 + */ + protected static void processRedMushroomTrees(BlockState blockState, List treeFellerBlocks) { + List futureCenterBlocks = new ArrayList(); + + // 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 = blockState.getBlock().getRelative(x, y, z).getState(); + BlockState otherNextBlock = blockState.getBlock().getRelative(x, y - (y * 2), z).getState(); + + handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks); + handleBlock(otherNextBlock, futureCenterBlocks, treeFellerBlocks); + + if (WoodcuttingManager.treeFellerReachedThreshold) { + return; + } + } + } + } + + // Recursive call for each log found + for (BlockState futureCenterBlock : futureCenterBlocks) { + if (WoodcuttingManager.treeFellerReachedThreshold) { + return; + } + + processRedMushroomTrees(futureCenterBlock, treeFellerBlocks); + } + } + + /** + * 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 + */ + protected static boolean handleDurabilityLoss(List treeFellerBlocks, ItemStack inHand) { + Material inHandMaterial = inHand.getType(); + + if (inHandMaterial == Material.AIR) { + return false; + } + + 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) { + return false; + } + + inHand.setDurability(finalDurability); + return true; + } + + /** + * 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() > treeFellerThreshold) { + WoodcuttingManager.treeFellerReachedThreshold = true; + return; + } + + futureCenterBlocks.add(blockState); + } } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java new file mode 100644 index 000000000..e15c816b3 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -0,0 +1,192 @@ +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.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Tree; + +import com.gmail.nossr50.datatypes.mods.CustomBlock; +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.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod; +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.skills.CombatUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class WoodcuttingManager extends SkillManager { + protected static boolean treeFellerReachedThreshold = false; + + public WoodcuttingManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.WOODCUTTING); + } + + public boolean canUseLeafBlower(ItemStack heldItem) { + return getSkillLevel() >= Woodcutting.leafBlowerUnlockLevel && ItemUtils.isAxe(heldItem); + } + + public boolean canUseTreeFeller(ItemStack heldItem) { + return mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(getPlayer()) && ItemUtils.isAxe(heldItem); + } + + protected boolean canGetDoubleDrops() { + return Permissions.doubleDrops(getPlayer(), skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Woodcutting.doubleDropsMaxChance, Woodcutting.doubleDropsMaxLevel); + } + + /** + * Begins Woodcutting + * + * @param blockState Block being broken + */ + public void woodcuttingBlockCheck(BlockState blockState) { + int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); + + switch (blockState.getType()) { + case HUGE_MUSHROOM_1: + case HUGE_MUSHROOM_2: + break; + + default: + if (canGetDoubleDrops()) { + Woodcutting.checkForDoubleDrop(blockState); + } + } + + applyXpGain(xp); + } + + /** + * Begins Tree Feller + * + * @param blockState Block being broken + */ + public void processTreeFeller(BlockState blockState) { + Player player = getPlayer(); + List treeFellerBlocks = new ArrayList(); + + switch (blockState.getType()) { + case LOG: + case HUGE_MUSHROOM_1: + Woodcutting.processRegularTrees(blockState, treeFellerBlocks); + break; + + case HUGE_MUSHROOM_2: + Woodcutting.processRedMushroomTrees(blockState, treeFellerBlocks); + break; + + default: + if (ModUtils.isCustomLogBlock(blockState)) { + Woodcutting.processRegularTrees(blockState, treeFellerBlocks); + } + break; + } + + // 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 (!Woodcutting.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); + treeFellerReachedThreshold = false; // Reset the value after we're done with Tree Feller each time. + } + + /** + * Handles the dropping of blocks + * + * @param treeFellerBlocks List of blocks to be dropped + * @param player Player using the ability + */ + private void dropBlocks(List treeFellerBlocks) { + Player player = getPlayer(); + 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)) { + if (canGetDoubleDrops()) { + Woodcutting.checkForDoubleDrop(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: + if (canGetDoubleDrops()) { + Woodcutting.checkForDoubleDrop(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); + } + + applyXpGain(xp); + } + +} From 109e9725a9527460b1fb56825f3d2e0f32112906 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 16:25:46 -0500 Subject: [PATCH 13/94] No need to create our mcMMOPlayer again. --- .../java/com/gmail/nossr50/listeners/BlockListener.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index d89e6dc74..af69d5f1b 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -142,7 +142,7 @@ public class BlockListener implements Listener { /* HERBALISM */ if (BlockUtils.affectedByGreenTerra(blockState)) { - HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager(); + HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); /* Green Terra */ if (herbalismManager.canActivateAbility()) { @@ -167,7 +167,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 = UserManager.getPlayer(player).getMiningManager(); + MiningManager miningManager = mcMMOPlayer.getMiningManager(); miningManager.miningBlockCheck(blockState); if (mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) { @@ -189,7 +189,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 = UserManager.getPlayer(player).getExcavationManager(); + ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager(); excavationManager.excavationBlockCheck(blockState); if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) { @@ -361,7 +361,7 @@ public class BlockListener implements Listener { } } else if (BlockUtils.isLeaves(blockState)) { - if (UserManager.getPlayer(player).getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) { + if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) { event.setInstaBreak(true); player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); } From c30fdef615ab8cca05c926a61952f752e6d25533 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 16:27:10 -0500 Subject: [PATCH 14/94] Removed the option to use Woodcutting without an axe from the config file. --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/config/Config.java | 2 -- src/main/resources/config.yml | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 8f6d2b5da..833919166 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,6 +12,7 @@ Version 1.4.03-dev = Fixed bug with repairing using materials with byte metadata ! Moved the Salvage unlock level from config.yml to advanced.yml - Removed option to disable Salvage via the config file. This should be handled via permissions instead. + - Removed the option to use Woodcutting without an axe from the config file. Version 1.4.02 + Added API to get the skill and power level caps. diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index eae117ec7..7c8e86655 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -197,8 +197,6 @@ public class Config extends AutoUpdateConfigLoader { public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); } /* Woodcutting */ - public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); } - public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); } public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); } public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5f6e22ff4..87834ce74 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -184,7 +184,6 @@ Skills: SmoothBrick_To_CrackedBrick: true Woodcutting: Level_Cap: 0 - Requires_Axe: true # # Settings for Double Drops From 09169bd019fb02d932f78fde4442a01fc07c92e2 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 18:17:54 -0500 Subject: [PATCH 15/94] Fixed bug where Fishing was becoming less successful at higher levels --- Changelog.txt | 1 + .../java/com/gmail/nossr50/skills/fishing/FishingManager.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 833919166..55d139c71 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Key: Version 1.4.03-dev = Fixed bug where players were unable to salvage leather armor = Fixed bug with repairing using materials with byte metadata + = Fixed bug where Fishing was becoming less successful at higher levels ! Moved the Salvage unlock level from config.yml to advanced.yml - Removed option to disable Salvage via the config file. This should be handled via permissions instead. - Removed the option to use Woodcutting without an axe from the config file. 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 a985c37d2..3e3f6af53 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -217,7 +217,7 @@ public class FishingManager extends SkillManager { FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size())); ItemStack treasureDrop = treasure.getDrop(); - if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) { + if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), activationChance)) { return null; } From a9438ed52b22f8ae56fd80918d1d6d7e0e8b2743 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 19:19:26 -0500 Subject: [PATCH 16/94] Move BlockCracker into the UnarmedManager --- .../nossr50/listeners/BlockListener.java | 8 ++++--- .../gmail/nossr50/skills/unarmed/Unarmed.java | 24 ------------------- .../skills/unarmed/UnarmedManager.java | 20 ++++++++++++++++ 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index af69d5f1b..b3cdc7b2e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -34,7 +34,7 @@ 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.smelting.SmeltingManager; -import com.gmail.nossr50.skills.unarmed.Unarmed; +import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.ItemUtils; @@ -354,8 +354,10 @@ public class BlockListener implements Listener { } } // Another perm check for the cracked blocks activation - else if (BlockUtils.affectedByBlockCracker(blockState) && Permissions.blockCracker(player)) { - if (Unarmed.blockCracker(player, blockState)) { + else if (BlockUtils.affectedByBlockCracker(blockState)) { + UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager(); + + if (unarmedManager.canUseBlockCracker() && SkillUtils.blockBreakSimulate(block, player, false) && unarmedManager.blockCrackerCheck(blockState)) { blockState.update(); } } 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 2078bfb9f..d33f3089d 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java @@ -1,12 +1,7 @@ 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(); @@ -24,23 +19,4 @@ public class Unarmed { 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 101aa45de..631092193 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.skills.unarmed; import org.bukkit.Material; +import org.bukkit.block.BlockState; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -44,6 +45,25 @@ public class UnarmedManager extends SkillManager { return player.getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect(player); } + public boolean canUseBlockCracker() { + return Permissions.blockCracker(getPlayer()); + } + + public boolean blockCrackerCheck(BlockState blockState) { + Material type = blockState.getType(); + + switch (type) { + case SMOOTH_BRICK: + if (Unarmed.blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) { + blockState.setRawData((byte) 0x2); + } + return true; + + default: + return false; + } + } + /** * Check for disarm. * From 3219674678d1f84aca4dcf732811f2eb52a5322f Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 6 Mar 2013 23:00:37 -0500 Subject: [PATCH 17/94] Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker --- Changelog.txt | 1 + .../java/com/gmail/nossr50/config/AdvancedConfig.java | 1 + .../java/com/gmail/nossr50/util/skills/SkillUtils.java | 8 +++++--- src/main/resources/advanced.yml | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 55d139c71..e8ef5cb12 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,7 @@ Key: - Removal Version 1.4.03-dev + + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker = Fixed bug where players were unable to salvage leather armor = Fixed bug with repairing using materials with byte metadata = Fixed bug where Fishing was becoming less successful at higher levels diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index b47796208..6211d7b4b 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 AutoUpdateConfigLoader { /* GENERAL */ public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); } + public int getEnchantBuff() { return config.getInt("Skills.General.Ability_EnchantBuff", 5); } /* ACROBATICS */ public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); } 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 8b1f8e0bf..620a03094 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -40,6 +40,8 @@ import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.spout.SpoutUtils; public class SkillUtils { + private static int enchantBuff = AdvancedConfig.getInstance().getEnchantBuff(); + public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) { int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill); @@ -477,7 +479,7 @@ public class SkillUtils { } itemLore.add("mcMMO Ability Tool"); - itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + 5, true); + itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + enchantBuff, true); itemMeta.setLore(itemLore); heldItem.setItemMeta(itemMeta); @@ -543,11 +545,11 @@ public class SkillUtils { if (itemLore.remove("mcMMO Ability Tool")) { int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED); - if (efficiencyLevel <= 5) { + if (efficiencyLevel <= enchantBuff) { itemMeta.removeEnchant(Enchantment.DIG_SPEED); } else { - itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - 5, true); + itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - enchantBuff, true); } itemMeta.setLore(itemLore); diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 1c1b4dacf..726857f61 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -16,6 +16,8 @@ Skills: General: # This setting will determine when the length of every ability gets longer with 1 second Ability_IncreaseLevel: 50 + # This setting determines how many enchant levels to use when buffing Super Breaker & Giga Drill Breaker + Ability_EnchantBuff: 5 # # Settings for Acrobatics ### From 9377de930fcf7373fff129950529012731c985f9 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 7 Mar 2013 08:03:18 -0500 Subject: [PATCH 18/94] Fixed bug with using Salvage on stacked items. Stacked items will now return the appropriate amount of materials. Fixes #802 --- Changelog.txt | 1 + .../java/com/gmail/nossr50/skills/repair/RepairManager.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index e8ef5cb12..987a55bfe 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,6 +12,7 @@ Version 1.4.03-dev = Fixed bug where players were unable to salvage leather armor = Fixed bug with repairing using materials with byte metadata = Fixed bug where Fishing was becoming less successful at higher levels + = Fixed bug with using Salvage on stacked items. ! Moved the Salvage unlock level from config.yml to advanced.yml - Removed option to disable Salvage via the config file. This should be handled via permissions instead. - Removed the option to use Woodcutting without an axe from the config file. 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 a4ac95751..f8be2ef4c 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -188,7 +188,7 @@ public class RepairManager extends SkillManager { player.setItemInHand(new ItemStack(Material.AIR)); location.setY(location.getY() + 1); - Misc.dropItems(location, new ItemStack(Repair.getSalvagedItem(item)), Repair.getSalvagedAmount(item)); + Misc.dropItems(location, new ItemStack(Repair.getSalvagedItem(item)), Repair.getSalvagedAmount(item) * item.getAmount()); player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess")); From d40d89f29af984e6964862b7720636d96e8f8f1b Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 7 Mar 2013 08:07:55 -0500 Subject: [PATCH 19/94] Fixed bug where the 'mcmmo.commands.ptp.world.all' was registered twice. Fixes #787 --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/util/Permissions.java | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 987a55bfe..439f7d2e7 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -13,6 +13,7 @@ Version 1.4.03-dev = Fixed bug with repairing using materials with byte metadata = Fixed bug where Fishing was becoming less successful at higher levels = Fixed bug with using Salvage on stacked items. + = Fixed bug where the 'mcmmo.commands.ptp.world.all' was registered twice ! Moved the Salvage unlock level from config.yml to advanced.yml - Removed option to disable Salvage via the config file. This should be handled via permissions instead. - Removed the option to use Woodcutting without an axe from the config file. diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index e4bba0500..e8922acbd 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -231,8 +231,6 @@ public final class Permissions { for (World world : server.getWorlds()) { addDynamicPermission("mcmmo.commands.ptp.world." + world.getName(), PermissionDefault.OP, pluginManager); } - - addDynamicPermission("mcmmo.commands.ptp.world.all", PermissionDefault.OP, pluginManager); } private static void addDynamicPermission(String permissionName, PermissionDefault permissionDefault, PluginManager pluginManager) { From 29520dc95c4de321a5da6abb01a979ccc33239a9 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 7 Mar 2013 08:53:13 -0500 Subject: [PATCH 20/94] Get the mcMMOPlayer outside of the loop so it doesn't have to be recreated every time. --- src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 620a03094..9e370d820 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -217,9 +217,10 @@ public class SkillUtils { int xpRemoved = 0; if (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) { + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); while (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) { - if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= UserManager.getPlayer(player).getPowerLevel() + 1)) { + if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= mcMMOPlayer.getPowerLevel() + 1)) { int xp = profile.getXpToLevel(skillType); xpRemoved += xp; From ade9e20cdd627ac6632445adcb2caf48de355d06 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 7 Mar 2013 09:18:27 -0500 Subject: [PATCH 21/94] Fixed bug where Beast Lore wouldn't work on friendly pets. Fixes #805 --- Changelog.txt | 1 + .../java/com/gmail/nossr50/util/skills/CombatUtils.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 439f7d2e7..ee9a9bb64 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,6 +14,7 @@ Version 1.4.03-dev = Fixed bug where Fishing was becoming less successful at higher levels = Fixed bug with using Salvage on stacked items. = Fixed bug where the 'mcmmo.commands.ptp.world.all' was registered twice + = Fixed bug where Beast Lore wouldn't work on friendly pets ! Moved the Salvage unlock level from config.yml to advanced.yml - Removed option to disable Salvage via the config file. This should be handled via permissions instead. - Removed the option to use Woodcutting without an axe from the config file. 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 3d3371420..dd17f5b19 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -64,10 +64,6 @@ public final class CombatUtils { ItemStack heldItem = player.getItemInHand(); if (target instanceof Tameable) { - if (isFriendlyPet(player, (Tameable) target)) { - return; - } - if (heldItem.getType() == Material.BONE) { TamingManager tamingManager = mcMMOPlayer.getTamingManager(); @@ -77,6 +73,10 @@ public final class CombatUtils { return; } } + + if (isFriendlyPet(player, (Tameable) target)) { + return; + } } if (ItemUtils.isSword(heldItem)) { From 3a809dab32437c1b7ba144e9ca8018d0e70ec07d Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 7 Mar 2013 12:52:43 -0500 Subject: [PATCH 22/94] Fix downgrade chances all being calculated from Rank4. --- src/main/java/com/gmail/nossr50/skills/repair/Repair.java | 6 +++--- .../java/com/gmail/nossr50/skills/repair/RepairManager.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 511a69062..7e33c9914 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -19,15 +19,15 @@ public class Repair { THREE(3) { @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels3(); } @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}, + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); }}, TWO(2) { @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels2(); } @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}, + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); }}, ONE(1) { @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels1(); } @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}; + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); }}; int numerical; 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 f8be2ef4c..c21de8ec0 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -304,7 +304,7 @@ public class RepairManager extends SkillManager { Map enchants = item.getEnchantments(); - if (enchants.size() == 0) { + if (enchants.isEmpty()) { return; } From 03d0ecd4500f31efc8003458a287cb05bf83fea6 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Thu, 7 Mar 2013 14:43:03 -0500 Subject: [PATCH 23/94] text=auto --- .gitattributes | 2 +- .../nossr50/skills/repair/RepairManager.java | 700 +++++++++--------- .../woodcutting/WoodcuttingManager.java | 384 +++++----- 3 files changed, 543 insertions(+), 543 deletions(-) diff --git a/.gitattributes b/.gitattributes index a981216a2..1fb5395e5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -* text +* text=auto *.png binary *.wav binary 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 c21de8ec0..a5cc6811b 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -1,350 +1,350 @@ -package com.gmail.nossr50.skills.repair; - -import java.util.Map; -import java.util.Map.Entry; - -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.getspout.spoutapi.SpoutManager; -import org.getspout.spoutapi.player.SpoutPlayer; - -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.repair.McMMOPlayerRepairCheckEvent; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.repair.Repair.Tier; -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 RepairManager extends SkillManager { - public RepairManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.REPAIR); - } - - /** - * Handles notifications for placing an anvil. - * - * @param anvilID The item ID of the anvil block - */ - public void placedAnvilCheck(int anvilId) { - Player player = getPlayer(); - - if (mcMMOPlayer.getPlacedAnvil(anvilId)) { - return; - } - - if (mcMMO.spoutEnabled) { - SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); - - if (spoutPlayer.isSpoutCraftEnabled()) { - String[] spoutMessages = Repair.getSpoutAnvilMessages(anvilId); - spoutPlayer.sendNotification(spoutMessages[0], spoutMessages[1], Material.getMaterial(anvilId)); - } - else { - player.sendMessage(Repair.getAnvilMessage(anvilId)); - } - } - else { - player.sendMessage(Repair.getAnvilMessage(anvilId)); - } - - player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - mcMMOPlayer.togglePlacedAnvil(anvilId); - } - - public void handleRepair(ItemStack item) { - Player player = getPlayer(); - int itemId = item.getTypeId(); - - Repairable repairable = mcMMO.repairableManager.getRepairable(itemId); - - // Permissions checks on material and item types - if (!repairable.getRepairItemType().getPermissions(player)) { - player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); - return; - } - - if (!repairable.getRepairMaterialType().getPermissions(player)) { - player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); - return; - } - - int skillLevel = getSkillLevel(); - int minimumRepairableLevel = repairable.getMinimumLevel(); - - // Level check - if (skillLevel < minimumRepairableLevel) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", minimumRepairableLevel, StringUtils.getPrettyItemString(itemId))); - return; - } - - PlayerInventory inventory = player.getInventory(); - - int repairMaterialId = repairable.getRepairMaterialId(); - byte repairMaterialMetadata = repairable.getRepairMaterialMetadata(); - - // Check if they have the proper material to repair with - if (!inventory.contains(repairMaterialId)) { - String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterialId)); - - if (repairMaterialMetadata != (byte) -1) { - // TODO: Do something nicer than append the metadata as a :# ? - if (Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata) == -1) { - message += ":" + repairMaterialMetadata; - } - } - - player.sendMessage(message); - return; - } - - short startDurability = item.getDurability(); - - // Do not repair if at full durability - if (startDurability <= 0) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability")); - return; - } - - // Do not repair stacked items - if (item.getAmount() != 1) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems")); - 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? - short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons? - - // We're going to hold onto our repair item location - int repairItemLocation; - if (repairable.getRepairMaterialMetadata() == (byte) -1) { - repairItemLocation = Repair.findInInventory(inventory, repairMaterialId); - } - else { - // Special case for when the repairable has metadata that must be addressed - repairItemLocation = Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata); - } - - // This should never happen, but if it does we need to complain loudly about it. - if (repairItemLocation == -1) { - player.sendMessage(LocaleLoader.getString("Repair.Error")); - return; - } - - // Call event - McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), inventory.getItem(repairItemLocation), item); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - - // Handle the enchants - if (Repair.arcaneForgingEnchantLoss) { - addEnchants(item); - } - - // Remove the item - Repair.removeOneFrom(inventory, repairItemLocation); - - // Give out XP like candy - applyXpGain((int) ((startDurability - newDurability) * repairable.getXpMultiplier()) * 10); - - // BWONG BWONG BWONG - player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - - // Repair the item! - item.setDurability(newDurability); - } - - public void handleSalvage(Location location, ItemStack item) { - Player player = getPlayer(); - - if (player.getGameMode() != GameMode.SURVIVAL) { - return; - } - - if (getSkillLevel() < Repair.salvageUnlockLevel) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage")); - return; - } - - if (item.getDurability() == 0) { - player.setItemInHand(new ItemStack(Material.AIR)); - location.setY(location.getY() + 1); - - Misc.dropItems(location, new ItemStack(Repair.getSalvagedItem(item)), Repair.getSalvagedAmount(item) * item.getAmount()); - - player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess")); - } - else { - player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability")); - } - } - - /** - * Gets the Arcane Forging rank - * - * @return the current Arcane Forging rank - */ - public int getArcaneForgingRank() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.toNumerical(); - } - } - - return 0; - } - - /** - * Gets chance of keeping enchantment during repair. - * - * @return The chance of keeping the enchantment - */ - public int getKeepEnchantChance() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getKeepEnchantChance(); - } - } - - return 0; - } - - /** - * Gets chance of enchantment being downgraded during repair. - * - * @return The chance of the enchantment being downgraded - */ - public int getDowngradeEnchantChance() { - int skillLevel = getSkillLevel(); - - for (Tier tier : Tier.values()) { - if (skillLevel >= tier.getLevel()) { - return tier.getDowngradeEnchantChance(); - } - } - - return 100; - } - - /** - * Computes repair bonuses. - * - * @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 - */ - private short repairCalculate(short durability, int repairAmount) { - Player player = getPlayer(); - - if (Permissions.repairMastery(player)) { - double bonus = repairAmount * Math.min((((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * getSkillLevel()) / 100.0D), Repair.repairMasteryMaxBonus / 100.0D); - repairAmount += bonus; - } - - if (Permissions.superRepair(player) && checkPlayerProcRepair()) { - repairAmount *= 2.0D; - } - - if (repairAmount <= 0 || repairAmount > Short.MAX_VALUE) { - repairAmount = Short.MAX_VALUE; - } - - return (short) Math.max(durability - repairAmount, 0); - } - - /** - * Checks for Super Repair bonus. - * - * @return true if bonus granted, false otherwise - */ - private boolean checkPlayerProcRepair() { - if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Repair.superRepairMaxChance, Repair.superRepairMaxBonusLevel)) { - getPlayer().sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy")); - return true; - } - - return false; - } - - /** - * Handles removing & downgrading enchants. - * - * @param item Item being repaired - */ - private void addEnchants(ItemStack item) { - Player player = getPlayer(); - - if (Permissions.arcaneBypass(player)) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); - return; - } - - Map enchants = item.getEnchantments(); - - if (enchants.isEmpty()) { - return; - } - - if (getArcaneForgingRank() == 0 || !Permissions.arcaneForging(player)) { - for (Enchantment enchant : enchants.keySet()) { - item.removeEnchantment(enchant); - } - - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost")); - return; - } - - boolean downgraded = false; - - for (Entry enchant : enchants.entrySet()) { - Enchantment enchantment = enchant.getKey(); - - if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) { - int enchantLevel = enchant.getValue(); - - if (Repair.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) { - item.addEnchantment(enchantment, enchantLevel--); - downgraded = true; - } - } - else { - item.removeEnchantment(enchantment); - } - } - - Map newEnchants = item.getEnchantments(); - - if (newEnchants.isEmpty()) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail")); - } - else if (downgraded || newEnchants.size() < enchants.size()) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade")); - } - else { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); - } - } -} +package com.gmail.nossr50.skills.repair; + +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.getspout.spoutapi.SpoutManager; +import org.getspout.spoutapi.player.SpoutPlayer; + +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.repair.McMMOPlayerRepairCheckEvent; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.repair.Repair.Tier; +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 RepairManager extends SkillManager { + public RepairManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.REPAIR); + } + + /** + * Handles notifications for placing an anvil. + * + * @param anvilID The item ID of the anvil block + */ + public void placedAnvilCheck(int anvilId) { + Player player = getPlayer(); + + if (mcMMOPlayer.getPlacedAnvil(anvilId)) { + return; + } + + if (mcMMO.spoutEnabled) { + SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); + + if (spoutPlayer.isSpoutCraftEnabled()) { + String[] spoutMessages = Repair.getSpoutAnvilMessages(anvilId); + spoutPlayer.sendNotification(spoutMessages[0], spoutMessages[1], Material.getMaterial(anvilId)); + } + else { + player.sendMessage(Repair.getAnvilMessage(anvilId)); + } + } + else { + player.sendMessage(Repair.getAnvilMessage(anvilId)); + } + + player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + mcMMOPlayer.togglePlacedAnvil(anvilId); + } + + public void handleRepair(ItemStack item) { + Player player = getPlayer(); + int itemId = item.getTypeId(); + + Repairable repairable = mcMMO.repairableManager.getRepairable(itemId); + + // Permissions checks on material and item types + if (!repairable.getRepairItemType().getPermissions(player)) { + player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); + return; + } + + if (!repairable.getRepairMaterialType().getPermissions(player)) { + player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); + return; + } + + int skillLevel = getSkillLevel(); + int minimumRepairableLevel = repairable.getMinimumLevel(); + + // Level check + if (skillLevel < minimumRepairableLevel) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", minimumRepairableLevel, StringUtils.getPrettyItemString(itemId))); + return; + } + + PlayerInventory inventory = player.getInventory(); + + int repairMaterialId = repairable.getRepairMaterialId(); + byte repairMaterialMetadata = repairable.getRepairMaterialMetadata(); + + // Check if they have the proper material to repair with + if (!inventory.contains(repairMaterialId)) { + String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterialId)); + + if (repairMaterialMetadata != (byte) -1) { + // TODO: Do something nicer than append the metadata as a :# ? + if (Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata) == -1) { + message += ":" + repairMaterialMetadata; + } + } + + player.sendMessage(message); + return; + } + + short startDurability = item.getDurability(); + + // Do not repair if at full durability + if (startDurability <= 0) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability")); + return; + } + + // Do not repair stacked items + if (item.getAmount() != 1) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems")); + 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? + short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons? + + // We're going to hold onto our repair item location + int repairItemLocation; + if (repairable.getRepairMaterialMetadata() == (byte) -1) { + repairItemLocation = Repair.findInInventory(inventory, repairMaterialId); + } + else { + // Special case for when the repairable has metadata that must be addressed + repairItemLocation = Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata); + } + + // This should never happen, but if it does we need to complain loudly about it. + if (repairItemLocation == -1) { + player.sendMessage(LocaleLoader.getString("Repair.Error")); + return; + } + + // Call event + McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), inventory.getItem(repairItemLocation), item); + mcMMO.p.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + + // Handle the enchants + if (Repair.arcaneForgingEnchantLoss) { + addEnchants(item); + } + + // Remove the item + Repair.removeOneFrom(inventory, repairItemLocation); + + // Give out XP like candy + applyXpGain((int) ((startDurability - newDurability) * repairable.getXpMultiplier()) * 10); + + // BWONG BWONG BWONG + player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + + // Repair the item! + item.setDurability(newDurability); + } + + public void handleSalvage(Location location, ItemStack item) { + Player player = getPlayer(); + + if (player.getGameMode() != GameMode.SURVIVAL) { + return; + } + + if (getSkillLevel() < Repair.salvageUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage")); + return; + } + + if (item.getDurability() == 0) { + player.setItemInHand(new ItemStack(Material.AIR)); + location.setY(location.getY() + 1); + + Misc.dropItems(location, new ItemStack(Repair.getSalvagedItem(item)), Repair.getSalvagedAmount(item) * item.getAmount()); + + player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess")); + } + else { + player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability")); + } + } + + /** + * Gets the Arcane Forging rank + * + * @return the current Arcane Forging rank + */ + public int getArcaneForgingRank() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.toNumerical(); + } + } + + return 0; + } + + /** + * Gets chance of keeping enchantment during repair. + * + * @return The chance of keeping the enchantment + */ + public int getKeepEnchantChance() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getKeepEnchantChance(); + } + } + + return 0; + } + + /** + * Gets chance of enchantment being downgraded during repair. + * + * @return The chance of the enchantment being downgraded + */ + public int getDowngradeEnchantChance() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getDowngradeEnchantChance(); + } + } + + return 100; + } + + /** + * Computes repair bonuses. + * + * @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 + */ + private short repairCalculate(short durability, int repairAmount) { + Player player = getPlayer(); + + if (Permissions.repairMastery(player)) { + double bonus = repairAmount * Math.min((((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * getSkillLevel()) / 100.0D), Repair.repairMasteryMaxBonus / 100.0D); + repairAmount += bonus; + } + + if (Permissions.superRepair(player) && checkPlayerProcRepair()) { + repairAmount *= 2.0D; + } + + if (repairAmount <= 0 || repairAmount > Short.MAX_VALUE) { + repairAmount = Short.MAX_VALUE; + } + + return (short) Math.max(durability - repairAmount, 0); + } + + /** + * Checks for Super Repair bonus. + * + * @return true if bonus granted, false otherwise + */ + private boolean checkPlayerProcRepair() { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Repair.superRepairMaxChance, Repair.superRepairMaxBonusLevel)) { + getPlayer().sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy")); + return true; + } + + return false; + } + + /** + * Handles removing & downgrading enchants. + * + * @param item Item being repaired + */ + private void addEnchants(ItemStack item) { + Player player = getPlayer(); + + if (Permissions.arcaneBypass(player)) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); + return; + } + + Map enchants = item.getEnchantments(); + + if (enchants.isEmpty()) { + return; + } + + if (getArcaneForgingRank() == 0 || !Permissions.arcaneForging(player)) { + for (Enchantment enchant : enchants.keySet()) { + item.removeEnchantment(enchant); + } + + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost")); + return; + } + + boolean downgraded = false; + + for (Entry enchant : enchants.entrySet()) { + Enchantment enchantment = enchant.getKey(); + + if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) { + int enchantLevel = enchant.getValue(); + + if (Repair.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) { + item.addEnchantment(enchantment, enchantLevel--); + downgraded = true; + } + } + else { + item.removeEnchantment(enchantment); + } + } + + Map newEnchants = item.getEnchantments(); + + if (newEnchants.isEmpty()) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail")); + } + else if (downgraded || newEnchants.size() < enchants.size()) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade")); + } + else { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index e15c816b3..1905a76f8 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -1,192 +1,192 @@ -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.block.BlockState; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.Tree; - -import com.gmail.nossr50.datatypes.mods.CustomBlock; -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.locale.LocaleLoader; -import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod; -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.skills.CombatUtils; -import com.gmail.nossr50.util.skills.SkillUtils; - -public class WoodcuttingManager extends SkillManager { - protected static boolean treeFellerReachedThreshold = false; - - public WoodcuttingManager(McMMOPlayer mcMMOPlayer) { - super(mcMMOPlayer, SkillType.WOODCUTTING); - } - - public boolean canUseLeafBlower(ItemStack heldItem) { - return getSkillLevel() >= Woodcutting.leafBlowerUnlockLevel && ItemUtils.isAxe(heldItem); - } - - public boolean canUseTreeFeller(ItemStack heldItem) { - return mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(getPlayer()) && ItemUtils.isAxe(heldItem); - } - - protected boolean canGetDoubleDrops() { - return Permissions.doubleDrops(getPlayer(), skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Woodcutting.doubleDropsMaxChance, Woodcutting.doubleDropsMaxLevel); - } - - /** - * Begins Woodcutting - * - * @param blockState Block being broken - */ - public void woodcuttingBlockCheck(BlockState blockState) { - int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); - - switch (blockState.getType()) { - case HUGE_MUSHROOM_1: - case HUGE_MUSHROOM_2: - break; - - default: - if (canGetDoubleDrops()) { - Woodcutting.checkForDoubleDrop(blockState); - } - } - - applyXpGain(xp); - } - - /** - * Begins Tree Feller - * - * @param blockState Block being broken - */ - public void processTreeFeller(BlockState blockState) { - Player player = getPlayer(); - List treeFellerBlocks = new ArrayList(); - - switch (blockState.getType()) { - case LOG: - case HUGE_MUSHROOM_1: - Woodcutting.processRegularTrees(blockState, treeFellerBlocks); - break; - - case HUGE_MUSHROOM_2: - Woodcutting.processRedMushroomTrees(blockState, treeFellerBlocks); - break; - - default: - if (ModUtils.isCustomLogBlock(blockState)) { - Woodcutting.processRegularTrees(blockState, treeFellerBlocks); - } - break; - } - - // 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 (!Woodcutting.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); - treeFellerReachedThreshold = false; // Reset the value after we're done with Tree Feller each time. - } - - /** - * Handles the dropping of blocks - * - * @param treeFellerBlocks List of blocks to be dropped - * @param player Player using the ability - */ - private void dropBlocks(List treeFellerBlocks) { - Player player = getPlayer(); - 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)) { - if (canGetDoubleDrops()) { - Woodcutting.checkForDoubleDrop(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: - if (canGetDoubleDrops()) { - Woodcutting.checkForDoubleDrop(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); - } - - applyXpGain(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.block.BlockState; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Tree; + +import com.gmail.nossr50.datatypes.mods.CustomBlock; +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.locale.LocaleLoader; +import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod; +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.skills.CombatUtils; +import com.gmail.nossr50.util.skills.SkillUtils; + +public class WoodcuttingManager extends SkillManager { + protected static boolean treeFellerReachedThreshold = false; + + public WoodcuttingManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.WOODCUTTING); + } + + public boolean canUseLeafBlower(ItemStack heldItem) { + return getSkillLevel() >= Woodcutting.leafBlowerUnlockLevel && ItemUtils.isAxe(heldItem); + } + + public boolean canUseTreeFeller(ItemStack heldItem) { + return mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(getPlayer()) && ItemUtils.isAxe(heldItem); + } + + protected boolean canGetDoubleDrops() { + return Permissions.doubleDrops(getPlayer(), skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Woodcutting.doubleDropsMaxChance, Woodcutting.doubleDropsMaxLevel); + } + + /** + * Begins Woodcutting + * + * @param blockState Block being broken + */ + public void woodcuttingBlockCheck(BlockState blockState) { + int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); + + switch (blockState.getType()) { + case HUGE_MUSHROOM_1: + case HUGE_MUSHROOM_2: + break; + + default: + if (canGetDoubleDrops()) { + Woodcutting.checkForDoubleDrop(blockState); + } + } + + applyXpGain(xp); + } + + /** + * Begins Tree Feller + * + * @param blockState Block being broken + */ + public void processTreeFeller(BlockState blockState) { + Player player = getPlayer(); + List treeFellerBlocks = new ArrayList(); + + switch (blockState.getType()) { + case LOG: + case HUGE_MUSHROOM_1: + Woodcutting.processRegularTrees(blockState, treeFellerBlocks); + break; + + case HUGE_MUSHROOM_2: + Woodcutting.processRedMushroomTrees(blockState, treeFellerBlocks); + break; + + default: + if (ModUtils.isCustomLogBlock(blockState)) { + Woodcutting.processRegularTrees(blockState, treeFellerBlocks); + } + break; + } + + // 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 (!Woodcutting.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); + treeFellerReachedThreshold = false; // Reset the value after we're done with Tree Feller each time. + } + + /** + * Handles the dropping of blocks + * + * @param treeFellerBlocks List of blocks to be dropped + * @param player Player using the ability + */ + private void dropBlocks(List treeFellerBlocks) { + Player player = getPlayer(); + 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)) { + if (canGetDoubleDrops()) { + Woodcutting.checkForDoubleDrop(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: + if (canGetDoubleDrops()) { + Woodcutting.checkForDoubleDrop(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); + } + + applyXpGain(xp); + } + +} From cd4c32832083a0cf79ea9afa7e0ad23741ea6431 Mon Sep 17 00:00:00 2001 From: bm01 Date: Fri, 8 Mar 2013 02:03:25 +0100 Subject: [PATCH 24/94] Improved SkillMonitorTask --- .../nossr50/runnables/skills/SkillMonitorTask.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) 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 dffbba9ca..4dbc73a52 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java @@ -1,12 +1,8 @@ package com.gmail.nossr50.runnables.skills; -import org.bukkit.entity.Player; - -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.util.Misc; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; @@ -15,13 +11,7 @@ public class SkillMonitorTask implements Runnable { public void run() { long curTime = System.currentTimeMillis(); - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { - if (Misc.isNPCEntity(player)) { - continue; - } - - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - + for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) { /* * MONITOR SKILLS */ From c0986a1f89f2b57df57dca6a6483e8b064aba2bf Mon Sep 17 00:00:00 2001 From: bm01 Date: Fri, 8 Mar 2013 02:09:43 +0100 Subject: [PATCH 25/94] Removed unneeded null checks --- src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java | 4 ---- 1 file changed, 4 deletions(-) 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 9e370d820..b1dbbd444 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -94,10 +94,6 @@ public class SkillUtils { * @param ability The ability to watch cooldowns for */ public static void watchCooldown(McMMOPlayer mcMMOPlayer, AbilityType ability) { - if (mcMMOPlayer == null || ability == null) { - return; - } - Player player = mcMMOPlayer.getPlayer(); if (!mcMMOPlayer.getAbilityInformed(ability) && cooldownOver(mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { From dff03109a3c157fbdcf380bc8954a32d82f0b5b7 Mon Sep 17 00:00:00 2001 From: bm01 Date: Fri, 8 Mar 2013 05:28:40 +0100 Subject: [PATCH 26/94] Parties should only be saved once per call --- .../java/com/gmail/nossr50/party/PartyManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 28f1acd07..b758e06ca 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -488,13 +488,13 @@ public final class PartyManager { } partiesFile.set(partyName + ".Members", memberNames); + } - try { - partiesFile.save(new File(partiesFilePath)); - } - catch (Exception e) { - e.printStackTrace(); - } + try { + partiesFile.save(new File(partiesFilePath)); + } + catch (Exception e) { + e.printStackTrace(); } } From cddcf36016dbc7c98d467b7db85a5ccee52b62e0 Mon Sep 17 00:00:00 2001 From: bm01 Date: Fri, 8 Mar 2013 10:11:33 +0100 Subject: [PATCH 27/94] Reworked some methods related to Herbalism Fixes double seed consumption for Green Terra when used on crops Fixes wheat consumption instead of seed for Green Thumb Fixes XP and double drop exploit with some blocks (flowers...) --- Changelog.txt | 3 + .../nossr50/listeners/BlockListener.java | 7 - .../skills/HerbalismBlockUpdaterTask.java | 16 ++ .../skills/herbalism/GreenTerraTimerTask.java | 46 ------ .../skills/herbalism/GreenThumbTimerTask.java | 66 -------- .../nossr50/skills/herbalism/Herbalism.java | 13 +- .../skills/herbalism/HerbalismManager.java | 154 ++++++++++++------ 7 files changed, 124 insertions(+), 181 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java delete mode 100644 src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenTerraTimerTask.java delete mode 100644 src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenThumbTimerTask.java diff --git a/Changelog.txt b/Changelog.txt index ee9a9bb64..00f8dd1d6 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,9 @@ Key: Version 1.4.03-dev + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + = Fixed bug where Green Thumb would consume wheat instead of seeds + = Fixed bug where Green Terra would consume twice the amount of seed when used on crops + = Fixed bug where experience would be awarded in Herbalism for some player-placed blocks = Fixed bug where players were unable to salvage leather armor = Fixed bug with repairing using materials with byte metadata = Fixed bug where Fishing was becoming less successful at higher levels diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index b3cdc7b2e..2e43af207 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -154,14 +154,7 @@ public class BlockListener implements Listener { * Instead, we check it inside the drops handler. */ if (Permissions.skillEnabled(player, SkillType.HERBALISM)) { - - // Double drops herbalismManager.herbalismBlockCheck(blockState); - - // Triple drops - if (herbalismManager.canGreenTerraPlant()) { - herbalismManager.herbalismBlockCheck(blockState); - } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java new file mode 100644 index 000000000..5674273a3 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java @@ -0,0 +1,16 @@ +package com.gmail.nossr50.runnables.skills; + +import org.bukkit.block.BlockState; + +public class HerbalismBlockUpdaterTask implements Runnable { + private BlockState blockState; + + public HerbalismBlockUpdaterTask(BlockState blockState) { + this.blockState = blockState; + } + + @Override + public void run() { + blockState.update(true); + } +} 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 deleted file mode 100644 index 846e04d13..000000000 --- a/src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenTerraTimerTask.java +++ /dev/null @@ -1,46 +0,0 @@ -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 deleted file mode 100644 index 5b9d8da17..000000000 --- a/src/main/java/com/gmail/nossr50/runnables/skills/herbalism/GreenThumbTimerTask.java +++ /dev/null @@ -1,66 +0,0 @@ -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/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 0578f39f2..1875fe05c 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -63,24 +63,17 @@ public class Herbalism { 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++; - } + int dropAmount = 1; // 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) { + if (relativeBlock.getType() != blockType) { break; } - if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) { + if (!mcMMO.placeStore.isTrue(relativeBlock)) { dropAmount++; } } 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 f1546ab0b..3b0778efa 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -3,12 +3,14 @@ package com.gmail.nossr50.skills.herbalism; import java.util.ArrayList; import java.util.List; -import org.bukkit.Location; +import org.bukkit.CropState; 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 org.bukkit.material.CocoaPlant; +import org.bukkit.material.CocoaPlant.CocoaPlantSize; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; @@ -20,8 +22,7 @@ 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.runnables.skills.HerbalismBlockUpdaterTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Misc; @@ -107,65 +108,61 @@ public class HerbalismManager extends SkillManager { } /** - * 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; + if (mcMMO.placeStore.isTrue(blockState)) { + return; + } + Material material = blockState.getType(); + HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(material); + ItemStack drop = null; + int amount = 1; int xp = 0; - int dropAmount = 1; - ItemStack dropItem = null; + boolean greenTerra = mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA); if (herbalismBlock != null) { - if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) { - dropItem = herbalismBlock.getDropItem(); - dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState); - xp = herbalismBlock.getXpGain() * dropAmount; + if (herbalismBlock.hasGreenThumbPermission(getPlayer())) { + processGreenThumbPlants(blockState, greenTerra); } - else if (herbalismBlock.hasGreenThumbPermission(player)) { - dropItem = herbalismBlock.getDropItem(); - xp = herbalismBlock.getXpGain(); - processGreenThumbPlants(blockState); + + xp = herbalismBlock.getXpGain(); + + if (herbalismBlock.canDoubleDrop() && Permissions.doubleDrops(getPlayer(), skill)) { + drop = herbalismBlock.getDropItem(); } - else { - if (!mcMMO.placeStore.isTrue(blockState)) { - dropItem = herbalismBlock.getDropItem(); - xp = herbalismBlock.getXpGain(); - } + + if (material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK) { + amount = Herbalism.calculateCatciAndSugarDrops(blockState); + xp *= amount; } } else { - customBlock = ModUtils.getCustomBlock(blockState); - dropItem = customBlock.getItemDrop(); + CustomBlock customBlock = ModUtils.getCustomBlock(blockState); xp = customBlock.getXpGain(); - } - if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) { - Location location = blockState.getLocation(); - - if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) { - Misc.dropItems(location, dropItem, dropAmount); - } - else if (customBlock != null) { + if (Permissions.doubleDrops(getPlayer(), skill)) { int minimumDropAmount = customBlock.getMinimumDropAmount(); int maximumDropAmount = customBlock.getMaximumDropAmount(); - - if (minimumDropAmount != maximumDropAmount) { - Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount); - } - - Misc.dropItems(location, dropItem, minimumDropAmount); + drop = customBlock.getItemDrop(); + amount = Misc.getRandom().nextInt(maximumDropAmount - minimumDropAmount + 1) + minimumDropAmount; } } applyXpGain(xp); + + if (drop == null) { + return; + } + + for (int i = greenTerra ? 2 : 1; i != 0; i--) { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) { + Misc.dropItems(blockState.getLocation(), drop, amount); + } + } } /** @@ -269,29 +266,82 @@ public class HerbalismManager extends SkillManager { * Process the Green Thumb ability for plants. * * @param blockState The {@link BlockState} to check ability activation for + * @param greenTerra */ - private void processGreenThumbPlants(BlockState blockState) { + private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) { Player player = getPlayer(); PlayerInventory playerInventory = player.getInventory(); - ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); + ItemStack seed = (blockState.getType() == Material.CROPS) ? new ItemStack(Material.SEEDS) : HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem(); if (!playerInventory.containsAtLeast(seed, 1)) { return; } - if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA)) { - playerInventory.removeItem(seed); - player.updateInventory(); // Needed until replacement available - - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimerTask(blockState), 0); + if (!greenTerra && !SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) { return; } - else if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), 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); + if (!handleBlockState(blockState, greenTerra)) { return; } + + playerInventory.removeItem(seed); + player.updateInventory(); // Needed until replacement available + mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new HerbalismBlockUpdaterTask(blockState), 0); + } + + private boolean handleBlockState(BlockState blockState, boolean greenTerra) { + switch (blockState.getType()) { + case CROPS: + case CARROT: + case POTATO: + if (greenTerra) { + blockState.setRawData(CropState.MEDIUM.getData()); // 2 + } + else { + blockState.setRawData(getGreenThumbStage()); + } + + return true; + + case NETHER_WARTS: + if (greenTerra) { + blockState.setRawData((byte) 2); + } + else { + int greenThumbStage = getGreenThumbStage(); + + if (greenThumbStage > 2) { + blockState.setRawData((byte) 2); + } + else if (greenThumbStage == 2) { + blockState.setRawData((byte) 1); + } + else { + blockState.setRawData((byte) 0); + } + } + + return true; + + case COCOA: + CocoaPlant plant = (CocoaPlant) blockState.getData(); + + if (greenTerra || getGreenThumbStage() > 1) { + plant.setSize(CocoaPlantSize.MEDIUM); + } + else { + plant.setSize(CocoaPlantSize.SMALL); + } + + return true; + + default: + return false; + } + } + + private byte getGreenThumbStage() { + return (byte) Math.min(Math.min(getProfile().getSkillLevel(SkillType.HERBALISM), Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4); } } From 57e33bbf392df0c3ec5830734136251293c5c778 Mon Sep 17 00:00:00 2001 From: bm01 Date: Fri, 8 Mar 2013 10:31:32 +0100 Subject: [PATCH 28/94] Fixed triple drop awarding experience twice in mining The previous commit also fixed this for Herbalism --- Changelog.txt | 1 + .../nossr50/listeners/BlockListener.java | 5 ---- .../gmail/nossr50/skills/mining/Mining.java | 12 +------- .../nossr50/skills/mining/MiningManager.java | 28 +++++++++++++------ 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 00f8dd1d6..29fd7c229 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ Key: Version 1.4.03-dev + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + = Fixed bug where triple drops would award twice the amount of experience in Herbalism and Mining = Fixed bug where Green Thumb would consume wheat instead of seeds = Fixed bug where Green Terra would consume twice the amount of seed when used on crops = Fixed bug where experience would be awarded in Herbalism for some player-placed blocks diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 2e43af207..1aacc2dfb 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -137,7 +137,6 @@ public class BlockListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); BlockState blockState = event.getBlock().getState(); - ItemStack heldItem = player.getItemInHand(); /* HERBALISM */ @@ -162,10 +161,6 @@ public class BlockListener implements Listener { else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) { MiningManager miningManager = mcMMOPlayer.getMiningManager(); miningManager.miningBlockCheck(blockState); - - if (mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) { - miningManager.miningBlockCheck(blockState); - } } /* WOOD CUTTING */ 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 ddf9e80f6..30d806869 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -43,10 +43,6 @@ public class Mining { 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: @@ -89,13 +85,7 @@ public class Mining { */ 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: @@ -130,7 +120,7 @@ public class Mining { int minimumDropAmount = customBlock.getMinimumDropAmount(); int maximumDropAmount = customBlock.getMaximumDropAmount(); - dropItem = customBlock.getItemDrop(); + ItemStack dropItem = customBlock.getItemDrop(); if (minimumDropAmount != maximumDropAmount) { Misc.dropItems(location, dropItem, minimumDropAmount); 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 c76b4a2d8..862b37b95 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -12,6 +12,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; 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; @@ -54,18 +55,29 @@ public class MiningManager extends SkillManager{ */ public void miningBlockCheck(BlockState blockState) { Player player = getPlayer(); - int xp = Mining.getBlockXp(blockState); - if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { - if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { - Mining.handleSilkTouchDrops(blockState); - } - else { - Mining.handleMiningDrops(blockState); + if (!Permissions.doubleDrops(player, skill)) { + return; + } + + Material material = blockState.getType(); + + if (material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) { + return; + } + + for (int i = mcMMOPlayer.getAbilityMode(skill.getAbility()) ? 2 : 1; i != 0; i--) { + if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { + if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { + Mining.handleSilkTouchDrops(blockState); + } + else { + Mining.handleMiningDrops(blockState); + } } } - applyXpGain(xp); + applyXpGain(Mining.getBlockXp(blockState)); } /** From 1633617006cc13da9cf0d225ee28dde33edb97c0 Mon Sep 17 00:00:00 2001 From: bm01 Date: Fri, 8 Mar 2013 10:33:20 +0100 Subject: [PATCH 29/94] Minor cleanup --- .../com/gmail/nossr50/skills/herbalism/HerbalismManager.java | 4 ++-- .../java/com/gmail/nossr50/skills/mining/MiningManager.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) 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 3b0778efa..28268a3b0 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -77,7 +77,7 @@ public class HerbalismManager extends SkillManager { * @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); + return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange); } /** @@ -342,6 +342,6 @@ public class HerbalismManager extends SkillManager { } private byte getGreenThumbStage() { - return (byte) Math.min(Math.min(getProfile().getSkillLevel(SkillType.HERBALISM), Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4); + return (byte) Math.min(Math.min(getProfile().getSkillLevel(skill), Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4); } } 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 862b37b95..0fdd74bb6 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -66,9 +66,11 @@ public class MiningManager extends SkillManager{ return; } + boolean skillTouch = player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH); + for (int i = mcMMOPlayer.getAbilityMode(skill.getAbility()) ? 2 : 1; i != 0; i--) { if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { - if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { + if (skillTouch) { Mining.handleSilkTouchDrops(blockState); } else { From 3839373f5a763953c6184dc4b9824ba27943bf53 Mon Sep 17 00:00:00 2001 From: bm01 Date: Fri, 8 Mar 2013 10:35:52 +0100 Subject: [PATCH 30/94] Forgot this one --- .../com/gmail/nossr50/skills/herbalism/HerbalismManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 28268a3b0..818c91dfa 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -122,7 +122,7 @@ public class HerbalismManager extends SkillManager { ItemStack drop = null; int amount = 1; int xp = 0; - boolean greenTerra = mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA); + boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility()); if (herbalismBlock != null) { if (herbalismBlock.hasGreenThumbPermission(getPlayer())) { From 9618e45a1181b8d474fdae56e75e84aa1b988274 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 8 Mar 2013 07:26:43 -0500 Subject: [PATCH 31/94] That was bothering me. --- .../java/com/gmail/nossr50/skills/mining/MiningManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 0fdd74bb6..37d99dec8 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -66,11 +66,11 @@ public class MiningManager extends SkillManager{ return; } - boolean skillTouch = player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH); + boolean silkTouch = player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH); for (int i = mcMMOPlayer.getAbilityMode(skill.getAbility()) ? 2 : 1; i != 0; i--) { if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) { - if (skillTouch) { + if (silkTouch) { Mining.handleSilkTouchDrops(blockState); } else { From bd45fff1b4bc9d3015c4d6c359f565adb42091e7 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 8 Mar 2013 07:40:25 -0500 Subject: [PATCH 32/94] Fixed bug relating to "empty" ItemStacks. Fixes #807 --- Changelog.txt | 2 ++ .../gmail/nossr50/skills/mining/Mining.java | 2 +- .../nossr50/skills/mining/MiningManager.java | 4 ++-- .../java/com/gmail/nossr50/util/ModUtils.java | 18 +++++++++--------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 29fd7c229..c3c253487 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,8 @@ Key: Version 1.4.03-dev + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + = Fixed bug with Blast Mining not dropping blocks correctly + = Fixed bug with custom blocks not working = Fixed bug where triple drops would award twice the amount of experience in Herbalism and Mining = Fixed bug where Green Thumb would consume wheat instead of seeds = Fixed bug where Green Terra would consume twice the amount of seed when used on crops 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 30d806869..f9d463dc3 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -72,7 +72,7 @@ public class Mining { default: if (ModUtils.isCustomMiningBlock(blockState)) { - Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); + Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1)); } 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 37d99dec8..dcccde525 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -142,7 +142,7 @@ public class MiningManager extends SkillManager{ xp += Mining.getBlockXp(blockState); } - Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); // Initial block that would have been dropped + Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1)); // Initial block that would have been dropped if (!mcMMO.placeStore.isTrue(blockState)) { for (int i = 1; i < dropMultiplier; i++) { @@ -156,7 +156,7 @@ public class MiningManager extends SkillManager{ if (debrisYield > 0) { for (BlockState blockState : debris) { if (Misc.getRandom().nextFloat() < debrisYield) { - Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); + Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1)); } } } diff --git a/src/main/java/com/gmail/nossr50/util/ModUtils.java b/src/main/java/com/gmail/nossr50/util/ModUtils.java index 34dee45b5..c012022ce 100644 --- a/src/main/java/com/gmail/nossr50/util/ModUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ModUtils.java @@ -52,7 +52,7 @@ public final class ModUtils { */ public static CustomBlock getCustomBlock(BlockState blockState) { if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); + ItemStack item = blockState.getData().toItemStack(1); if (CustomBlockConfig.getInstance().customItems.contains(item)) { for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { @@ -88,7 +88,7 @@ public final class ModUtils { */ public static boolean isCustomWoodcuttingBlock(BlockState blockState) { if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); + ItemStack item = blockState.getData().toItemStack(1); if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) { for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { @@ -110,7 +110,7 @@ public final class ModUtils { */ public static boolean isCustomAbilityBlock(BlockState blockState) { if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); + ItemStack item = blockState.getData().toItemStack(1); if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) { for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { @@ -132,7 +132,7 @@ public final class ModUtils { */ public static boolean isCustomMiningBlock(BlockState blockState) { if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); + ItemStack item = blockState.getData().toItemStack(1); if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) { for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { @@ -154,7 +154,7 @@ public final class ModUtils { */ public static boolean isCustomExcavationBlock(BlockState blockState) { if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); + ItemStack item = blockState.getData().toItemStack(1); if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) { for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { @@ -176,7 +176,7 @@ public final class ModUtils { */ public static boolean isCustomHerbalismBlock(BlockState blockState) { if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); + ItemStack item = blockState.getData().toItemStack(1); if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) { for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { @@ -198,7 +198,7 @@ public final class ModUtils { */ public static boolean isCustomLeafBlock(BlockState blockState) { if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); + ItemStack item = blockState.getData().toItemStack(1); if (CustomBlockConfig.getInstance().customLeaves.contains(item)) { for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { @@ -220,7 +220,7 @@ public final class ModUtils { */ public static boolean isCustomLogBlock(BlockState blockState) { if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); + ItemStack item = blockState.getData().toItemStack(1); if (CustomBlockConfig.getInstance().customLogs.contains(item)) { for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { @@ -242,7 +242,7 @@ public final class ModUtils { */ public static boolean isCustomOreBlock(BlockState blockState) { if (customBlocksEnabled) { - ItemStack item = blockState.getData().toItemStack(); + ItemStack item = blockState.getData().toItemStack(1); if (CustomBlockConfig.getInstance().customOres.contains(item)) { for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) { From 3f71dab0b148f7c06878317c3136351e15a05f89 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 8 Mar 2013 08:39:28 -0500 Subject: [PATCH 33/94] Improved stats display for child skills --- Changelog.txt | 1 + .../nossr50/commands/skills/SkillCommand.java | 17 +++++++++++++++-- .../resources/locale/locale_en_US.properties | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c3c253487..c56bb722b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ Key: Version 1.4.03-dev + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + + Improved stats display for child skills = Fixed bug with Blast Mining not dropping blocks correctly = Fixed bug with custom blocks not working = Fixed bug where triple drops would award twice the amount of experience in Herbalism and Mining diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 1c7ee9654..2013251b4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.commands.skills; import java.text.DecimalFormat; +import java.util.Set; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -11,6 +12,7 @@ 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.skills.child.FamilyTree; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.commands.CommandUtils; @@ -57,12 +59,23 @@ public abstract class SkillCommand implements CommandExecutor { dataCalculations(); permissionsCheck(); - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString(skillString + ".SkillName"))); - if (!skill.isChildSkill()) { + player.sendMessage(LocaleLoader.getString("Skills.Header", SkillUtils.getSkillName(skill))); 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))); } + else { + player.sendMessage(LocaleLoader.getString("Skills.Header", SkillUtils.getSkillName(skill) + " " + LocaleLoader.getString("Skills.Child"))); + player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child"))); + player.sendMessage(LocaleLoader.getString("Effects.Child", profile.getSkillLevel(skill))); + + player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents"))); + Set parents = FamilyTree.getParents(skill); + + for (SkillType parent : parents) { + player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent))); + } + } if (effectsHeaderPermissions()) { player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 3f4b864ab..efff6cac4 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -566,6 +566,7 @@ Party.ItemShare.Disabled=[[RED]]Party item sharing is disabled. Commands.XPGain.Acrobatics=Falling Commands.XPGain.Archery=Attacking Monsters Commands.XPGain.Axes=Attacking Monsters +Commands.XPGain.Child=Gains levels from Parent Skills Commands.XPGain.Excavation=Digging and finding treasures Commands.XPGain.Fishing=Fishing (Go figure!) Commands.XPGain.Herbalism=Harvesting Herbs @@ -590,7 +591,9 @@ XPRate.Event= [[GOLD]]mcMMO is currently in an XP rate event! XP rate is {0}x! #EFFECTS ##generic Effects.Effects=EFFECTS +Effects.Child=[[DARK_GRAY]]LVL: [[GREEN]]{0} Effects.Level=[[DARK_GRAY]]LVL: [[GREEN]]{0} [[DARK_AQUA]]XP[[YELLOW]]([[GOLD]]{1}[[YELLOW]]/[[GOLD]]{2}[[YELLOW]]) +Effects.Parent = [[GOLD]]{0} - Effects.Template=[[DARK_AQUA]]{0}: [[GREEN]]{1} #GUIDES @@ -625,9 +628,11 @@ Item.ChimaeraWing.Pass=**CHIMAERA WING** Item.Injured.Wait=You were injured recently and must wait to use this. [[YELLOW]]({0}s) #SKILLS +Skills.Child=[[GOLD]](CHILD SKILL) Skills.Disarmed=[[DARK_RED]]You have been disarmed! Skills.Header=[[RED]]-----[][[GREEN]]{0}[[RED]][]----- Skills.NeedMore=[[DARK_RED]]You need more [[GRAY]]{0} +Skills.Parents = PARENTS Skills.Stats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]]) Skills.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s) From 0654f275997d2ca22ac5f3173da8e21f69dfc353 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 8 Mar 2013 08:45:16 -0500 Subject: [PATCH 34/94] Fixed bug where Blast Mining was awarding too much XP --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index c56bb722b..aaa095fdf 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,6 +12,7 @@ Version 1.4.03-dev + Improved stats display for child skills = Fixed bug with Blast Mining not dropping blocks correctly = Fixed bug with custom blocks not working + = Fixed bug where Blast Mining was awarding too much XP = Fixed bug where triple drops would award twice the amount of experience in Herbalism and Mining = Fixed bug where Green Thumb would consume wheat instead of seeds = Fixed bug where Green Terra would consume twice the amount of seed when used on crops 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 dcccde525..2c5ab86f3 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -146,7 +146,6 @@ public class MiningManager extends SkillManager{ 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 } } From 4bddbbf56ede9dce383c216d4d045c551e757ad1 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 8 Mar 2013 08:49:07 -0500 Subject: [PATCH 35/94] This must be handled first, else no XP is awarded if double-drops are disabled. --- .../java/com/gmail/nossr50/skills/mining/MiningManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 2c5ab86f3..3f70d4964 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -56,7 +56,9 @@ public class MiningManager extends SkillManager{ public void miningBlockCheck(BlockState blockState) { Player player = getPlayer(); - if (!Permissions.doubleDrops(player, skill)) { + applyXpGain(Mining.getBlockXp(blockState)); + + if (Permissions.doubleDrops(player, skill)) { return; } @@ -78,8 +80,6 @@ public class MiningManager extends SkillManager{ } } } - - applyXpGain(Mining.getBlockXp(blockState)); } /** From e31b7d5c48d30f0e79bfc1aaf954cd7d3b9236fa Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 8 Mar 2013 08:53:54 -0500 Subject: [PATCH 36/94] Cacti & Sugar Cane are an exception, because the bottom block is normally player-placed but the top two are grown naturally. --- .../com/gmail/nossr50/skills/herbalism/HerbalismManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 818c91dfa..ea90412c9 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -113,11 +113,12 @@ public class HerbalismManager extends SkillManager { * @param blockState The {@link BlockState} to check ability activation for */ public void herbalismBlockCheck(BlockState blockState) { - if (mcMMO.placeStore.isTrue(blockState)) { + Material material = blockState.getType(); + + if (mcMMO.placeStore.isTrue(blockState) && (material != Material.CACTUS || material != Material.SUGAR_CANE_BLOCK)) { return; } - Material material = blockState.getType(); HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(material); ItemStack drop = null; int amount = 1; From d9bd0ace9a5d1606afd087b8458100e1c9accbef Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 8 Mar 2013 10:23:21 -0500 Subject: [PATCH 37/94] Fixed bug with Smelting not properly tracking furnaces. Fixes #806 --- Changelog.txt | 1 + .../nossr50/listeners/InventoryListener.java | 44 ++++++++++++------- src/main/java/com/gmail/nossr50/mcMMO.java | 19 +------- 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index aaa095fdf..b02ab6b13 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Key: Version 1.4.03-dev + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + Improved stats display for child skills + = Fixed bug with Smelting not properly tracking furnaces = Fixed bug with Blast Mining not dropping blocks correctly = Fixed bug with custom blocks not working = Fixed bug where Blast Mining was awarding too much XP diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 88f293b9a..8b4f7a2a6 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -1,5 +1,6 @@ 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; @@ -16,6 +17,7 @@ import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.inventory.FurnaceInventory; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.skills.SkillType; @@ -49,11 +51,12 @@ public class InventoryListener implements Listener { if (furnace == null) { return; } + if (furnace.getBurnTime() == 0) { + Block furnaceBlock = furnace.getBlock(); - BlockState furnaceBlock = furnace.getBlock().getState(); - - if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) { - plugin.addToOpenFurnaceTracker(furnaceBlock, player.getName()); + if (!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) { + furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, new FixedMetadataValue(plugin, player.getName())); + } } } } @@ -75,23 +78,27 @@ public class InventoryListener implements Listener { return; } - BlockState furnaceBlock = furnace.getBlock().getState(); + if (furnace.getBurnTime() == 0) { + Block furnaceBlock = furnace.getBlock(); - if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) { - plugin.removeFromFurnaceTracker(furnaceBlock); + if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) { + furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, plugin); + } } } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFurnaceBurnEvent(FurnaceBurnEvent event) { - BlockState furnaceBlock = event.getBlock().getState(); + Block furnaceBlock = event.getBlock(); + BlockState furnaceState = furnaceBlock.getState(); - if (furnaceBlock instanceof Furnace) { + if (furnaceState instanceof Furnace) { ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); - if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) { - Player player = plugin.getFurnacePlayer(furnaceBlock); + if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) { + // We can make this assumption because we (should) be the only ones using this exact metadata + Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString()); if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) { return; @@ -104,13 +111,15 @@ public class InventoryListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) { - BlockState furnaceBlock = event.getBlock().getState(); + Block furnaceBlock = event.getBlock(); + BlockState furnaceState = furnaceBlock.getState(); - if (furnaceBlock instanceof Furnace) { + if (furnaceState instanceof Furnace) { ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); - if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) { - Player player = plugin.getFurnacePlayer(furnaceBlock); + if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) { + // We can make this assumption because we (should) be the only ones using this exact metadata + Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString()); if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) { return; @@ -128,8 +137,9 @@ public class InventoryListener implements Listener { if (furnaceBlock instanceof Furnace) { ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult(); - if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemUtils.isSmelted(result)) { - Player player = event.getPlayer(); + if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && result != null && ItemUtils.isSmelted(result)) { + // We can make this assumption because we (should) be the only ones using this exact metadata + Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString()); SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager(); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 261b005c3..05a43b948 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -10,7 +10,6 @@ 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; @@ -66,7 +65,6 @@ public class mcMMO extends JavaPlugin { private final WorldListener worldListener = new WorldListener(); private HashMap tntTracker = new HashMap(); - private HashMap furnaceTracker = new HashMap(); public static mcMMO p; @@ -95,6 +93,7 @@ public class mcMMO extends JavaPlugin { public static FixedMetadataValue metadataValue; public final static String entityMetadataKey = "mcMMO: Spawned Entity"; public final static String blockMetadataKey = "mcMMO: Piston Tracking"; + public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace"; /** * Things to be run when the plugin is enabled. @@ -273,22 +272,6 @@ public class mcMMO extends JavaPlugin { 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; } From 0e2746622d5e81ef0843a673ff83f61e45ebe9c1 Mon Sep 17 00:00:00 2001 From: bm01 Date: Fri, 8 Mar 2013 19:33:03 +0100 Subject: [PATCH 38/94] Fixed the Cacti & Sugar Cane fix! --- .../java/com/gmail/nossr50/skills/herbalism/Herbalism.java | 7 +++++-- .../gmail/nossr50/skills/herbalism/HerbalismManager.java | 5 +++-- 2 files changed, 8 insertions(+), 4 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 1875fe05c..317feb539 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -63,7 +63,7 @@ public class Herbalism { protected static int calculateCatciAndSugarDrops(BlockState blockState) { Block block = blockState.getBlock(); Material blockType = blockState.getType(); - int dropAmount = 1; + int dropAmount = mcMMO.placeStore.isTrue(block) ? 0 : 1; // Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally for (int y = 1; y < 3; y++) { @@ -73,7 +73,10 @@ public class Herbalism { break; } - if (!mcMMO.placeStore.isTrue(relativeBlock)) { + if (mcMMO.placeStore.isTrue(relativeBlock)) { + mcMMO.placeStore.setFalse(relativeBlock); + } + else { dropAmount++; } } 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 ea90412c9..27b4e33ee 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -114,8 +114,9 @@ public class HerbalismManager extends SkillManager { */ public void herbalismBlockCheck(BlockState blockState) { Material material = blockState.getType(); + boolean oneBlockPlant = (material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK) ? false : true; - if (mcMMO.placeStore.isTrue(blockState) && (material != Material.CACTUS || material != Material.SUGAR_CANE_BLOCK)) { + if (oneBlockPlant && mcMMO.placeStore.isTrue(blockState)) { return; } @@ -136,7 +137,7 @@ public class HerbalismManager extends SkillManager { drop = herbalismBlock.getDropItem(); } - if (material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK) { + if (!oneBlockPlant) { amount = Herbalism.calculateCatciAndSugarDrops(blockState); xp *= amount; } From 3349e9cb05254cf2a7ccf2cafcbc65ccb000fe5a Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Fri, 8 Mar 2013 21:42:26 +0100 Subject: [PATCH 39/94] Normalize line endings --- .gitignore | 82 +++++++++++++++++------------------ src/main/assembly/package.xml | 26 +++++------ 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/.gitignore b/.gitignore index 2745f88b2..7be1d85bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,42 @@ -# Eclipse stuff -/.classpath -/.project -/.settings - -# netbeans -/nbproject - -# we use maven! -/build.xml - -# maven -/target - -# vim -.*.sw[a-p] - -# various other potential build files -/build -/bin -/dist -/manifest.mf - -/world - -# Mac filesystem dust -*.DS_Store - -# intellij -*.iml -*.ipr -*.iws -.idea/ - -# Project Stuff -/src/main/resources/mcMMO - -# Other Libraries -*.jar - -# Atlassian Stuff +# Eclipse stuff +/.classpath +/.project +/.settings + +# netbeans +/nbproject + +# we use maven! +/build.xml + +# maven +/target + +# vim +.*.sw[a-p] + +# various other potential build files +/build +/bin +/dist +/manifest.mf + +/world + +# Mac filesystem dust +*.DS_Store + +# intellij +*.iml +*.ipr +*.iws +.idea/ + +# Project Stuff +/src/main/resources/mcMMO + +# Other Libraries +*.jar + +# Atlassian Stuff /atlassian-ide-plugin.xml diff --git a/src/main/assembly/package.xml b/src/main/assembly/package.xml index 66a085131..465536829 100644 --- a/src/main/assembly/package.xml +++ b/src/main/assembly/package.xml @@ -1,14 +1,14 @@ - - bin - false - - zip - - - - ${project.build.directory}/${artifactId}.jar - / - mcMMO.jar - - + + bin + false + + zip + + + + ${project.build.directory}/${artifactId}.jar + / + mcMMO.jar + + \ No newline at end of file From a07f14e3265f0529f736c72da72c3dbbe29447c6 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Fri, 8 Mar 2013 21:46:05 +0100 Subject: [PATCH 40/94] Improving Chimaera Wing - part 1 * Added cooldown between using Chimaera Wings * Added shapeless recipe to craft a Chimaera Wing (by default 5 feathers) --- Changelog.txt | 2 + .../java/com/gmail/nossr50/config/Config.java | 5 +- .../nossr50/datatypes/player/McMMOPlayer.java | 18 +++++ src/main/java/com/gmail/nossr50/mcMMO.java | 8 +++ .../com/gmail/nossr50/util/ChimaeraWing.java | 65 +++++++++++++++---- .../com/gmail/nossr50/util/ItemUtils.java | 28 ++++++++ src/main/resources/config.yml | 4 +- 7 files changed, 115 insertions(+), 15 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index b02ab6b13..2f50f575d 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Key: Version 1.4.03-dev + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + Improved stats display for child skills + + Added cooldown between using Chimaera Wings = Fixed bug with Smelting not properly tracking furnaces = Fixed bug with Blast Mining not dropping blocks correctly = Fixed bug with custom blocks not working @@ -25,6 +26,7 @@ Version 1.4.03-dev = Fixed bug where the 'mcmmo.commands.ptp.world.all' was registered twice = Fixed bug where Beast Lore wouldn't work on friendly pets ! Moved the Salvage unlock level from config.yml to advanced.yml + ! Changed how Chimaera Wings are acquired, you need to craft them now. (By default, use 5 feathers in a shapeless recipe) - Removed option to disable Salvage via the config file. This should be handled via permissions instead. - Removed the option to use Woodcutting without an axe from the config file. diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 7c8e86655..0b22550d8 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -101,9 +101,12 @@ public class Config extends AutoUpdateConfigLoader { public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); } /* Items */ - public int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); } + public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); } + public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); } public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); } public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); } + public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); } + public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); } /* Particles */ public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", 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 56e84f4f9..ae0b921fd 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -79,6 +79,7 @@ public class McMMOPlayer { private Map toolATS = new HashMap(); private int recentlyHurt; + private int chimaeraWing; private int respawnATS; public McMMOPlayer(Player player) { @@ -298,6 +299,23 @@ public class McMMOPlayer { recentlyHurt = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); } + /* + * Chimaera Wing + */ + + public int getLastChimaeraTeleport() { + return chimaeraWing; + } + + public void setLastChimaeraTeleport(int value) { + chimaeraWing = value; + } + + public void actualizeLastChimaeraTeleport() { + chimaeraWing = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + + /* * Exploit Prevention */ diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 05a43b948..d4a1e6fad 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -48,6 +48,7 @@ import com.gmail.nossr50.skills.repair.Repairable; import com.gmail.nossr50.skills.repair.RepairableManager; import com.gmail.nossr50.skills.repair.RepairableManagerFactory; import com.gmail.nossr50.skills.repair.config.RepairConfigManager; +import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.LogFilter; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.UpdateChecker; @@ -114,6 +115,7 @@ public class mcMMO extends JavaPlugin { } registerEvents(); + registerCustomRecipes(); // Setup the leader boards if (Config.getInstance().getUseMySQL()) { @@ -433,6 +435,12 @@ public class mcMMO extends JavaPlugin { CommandRegistrationManager.registerMchudCommand(); } + private void registerCustomRecipes() { + if (Config.getInstance().getChimaeraEnabled()) { + getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe()); + } + } + private void scheduleTasks() { BukkitScheduler scheduler = getServer().getScheduler(); diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index db05ac465..6e4df42ce 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -1,9 +1,15 @@ package com.gmail.nossr50.util; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ShapelessRecipe; +import org.bukkit.inventory.meta.ItemMeta; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; @@ -22,23 +28,31 @@ public final class ChimaeraWing { public static void activationCheck(Player player) { ItemStack inHand = player.getItemInHand(); - if (!Config.getInstance().getChimaeraEnabled() || inHand.getTypeId() != Config.getInstance().getChimaeraItemId()) { + if (!Config.getInstance().getChimaeraEnabled() || !ItemUtils.isChimaeraWing(inHand)) { return; } Block block = player.getLocation().getBlock(); int amount = inHand.getAmount(); - long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR; + long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt(); + long lastChimaeraWing = (UserManager.getPlayer(player).getLastChimaeraTeleport()); - if (Permissions.chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) { - if (SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) { - player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost())); + if (Permissions.chimaeraWing(player) && ItemUtils.isChimaeraWing(inHand)) { + if (!SkillUtils.cooldownOver(lastChimaeraWing * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) { + player.sendMessage(ChatColor.RED + "You need to wait before you can use this again! " + ChatColor.YELLOW + "(" + SkillUtils.calculateTimeLeft(lastChimaeraWing * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player) + ")"); //TODO Locale! + return; + } - for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) { - if (!(block.getRelative(0, y, 0).getType() == Material.AIR)) { - player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); - player.teleport(block.getRelative(0, y - 1, 0).getLocation()); - return; + if (SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player) && amount >= Config.getInstance().getChimaeraUseCost()) { + player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost()))); + + if (Config.getInstance().getChimaeraPreventUseUnderground()) { + for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) { + if (!(block.getRelative(0, y, 0).getType() == Material.AIR)) { + player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); + player.teleport(block.getRelative(0, y - 1, 0).getLocation()); + return; + } } } @@ -49,15 +63,40 @@ public final class ChimaeraWing { player.teleport(player.getWorld().getSpawnLocation()); } + UserManager.getPlayer(player).actualizeLastChimaeraTeleport(); MetricsManager.chimeraWingUsed(); player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass")); } - else if (!SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) { + else if (!SkillUtils.cooldownOver(recentlyHurt, 60 * Misc.TIME_CONVERSION_FACTOR, player) && amount >= Config.getInstance().getChimaeraUseCost()) { 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()))); + else if (amount <= Config.getInstance().getChimaeraUseCost()) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", "Chimaera Wings")); //TODO Locale! } } } + + public static ItemStack getChimaeraWing(int amount) { + ItemStack itemStack = new ItemStack(Material.FEATHER, amount); + ItemMeta itemMeta = itemStack.getItemMeta(); + itemMeta.setDisplayName(ChatColor.GOLD + "Chimaera Wing"); //TODO Locale! + List itemLore = new ArrayList(); + itemLore.add("mcMMO Item"); + itemLore.add(ChatColor.GRAY + "Teleports you to your bed."); //TODO Locale! + itemMeta.setLore(itemLore); + itemStack.setItemMeta(itemMeta); + return itemStack; + } + + public static ShapelessRecipe getChimaeraWingRecipe() { + Material ingredient = Material.getMaterial(Config.getInstance().getChimaeraItemId()); + int amount = Config.getInstance().getChimaeraRecipeCost(); + if (amount > 9) { + amount = 9; + } + + ShapelessRecipe ChimaeraWing = new ShapelessRecipe(getChimaeraWing(1)); + ChimaeraWing.addIngredient(amount, ingredient); + return ChimaeraWing; + } } diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index db6bd9311..fe40db38a 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -1,8 +1,12 @@ package com.gmail.nossr50.util; +import java.util.List; + +import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.api.SpoutToolsAPI; @@ -644,4 +648,28 @@ public class ItemUtils { return false; } } + + public static boolean isMcMMOItem(ItemStack is) { + ItemMeta itemMeta = is.getItemMeta(); + if (itemMeta.hasLore()) { + List itemLore = itemMeta.getLore(); + if (itemLore.contains("mcMMO Item")) { + return true; + } + } + return false; + } + + public static boolean isChimaeraWing(ItemStack is) { + if (!isMcMMOItem(is)) { + return false; + } + + ItemMeta itemMeta = is.getItemMeta(); + if (itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + "Chimaera Wing")) { //TODO Get localized name + return true; + } + + return false; + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 87834ce74..9c8914981 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -72,7 +72,9 @@ Mods: Items: Chimaera_Wing: Enabled: true - Feather_Cost: 10 + Prevent_Use_Underground: true + Use_Cost: 1 + Recipe_Cost: 5 Item_ID: 288 # From 0b53f8266a379531f5df42e2c931cb3cb08be298 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Fri, 8 Mar 2013 16:32:44 -0500 Subject: [PATCH 41/94] Squashed commit of the following: commit ba0ba3d2881dc672ef3dc40010278a0fbe158436 Author: NuclearW Date: Fri Mar 8 16:27:19 2013 -0500 Line endings, yo commit b93f0f54f5ec48b0a9e59da3b760603257cf0305 Author: md-5 Date: Sat Mar 9 08:18:49 2013 +1100 Use correct state, not block refrence to fix compile. commit 1063ad5c6823ebb46d75c777533ca26cd2d5f821 Author: md-5 Date: Sat Mar 9 08:12:34 2013 +1100 Fix errors in furnace listener. Bad GJ! --- .../gmail/nossr50/listeners/InventoryListener.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 8b4f7a2a6..94fd00cc4 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 { BlockState furnaceState = furnaceBlock.getState(); if (furnaceState instanceof Furnace) { - ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); + ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting(); if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) { // We can make this assumption because we (should) be the only ones using this exact metadata @@ -115,7 +115,7 @@ public class InventoryListener implements Listener { BlockState furnaceState = furnaceBlock.getState(); if (furnaceState instanceof Furnace) { - ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); + ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting(); if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) { // We can make this assumption because we (should) be the only ones using this exact metadata @@ -132,14 +132,14 @@ public class InventoryListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFurnaceExtractEvent(FurnaceExtractEvent event) { - BlockState furnaceBlock = event.getBlock().getState(); + BlockState furnaceState = event.getBlock().getState(); - if (furnaceBlock instanceof Furnace) { - ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult(); + if (furnaceState instanceof Furnace) { + ItemStack result = ((Furnace) furnaceState).getInventory().getResult(); - if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && result != null && ItemUtils.isSmelted(result)) { + if (furnaceState.hasMetadata(mcMMO.furnaceMetadataKey) && result != null && ItemUtils.isSmelted(result)) { // We can make this assumption because we (should) be the only ones using this exact metadata - Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString()); + Player player = plugin.getServer().getPlayer(furnaceState.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString()); SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager(); From 12709bcd7ff2ec46a8e9b92e9832336bfeaf907b Mon Sep 17 00:00:00 2001 From: NuclearW Date: Fri, 8 Mar 2013 22:20:26 -0500 Subject: [PATCH 42/94] Check hasItemMeta --- src/main/java/com/gmail/nossr50/util/ItemUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index fe40db38a..c0987a97d 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -650,6 +650,10 @@ public class ItemUtils { } public static boolean isMcMMOItem(ItemStack is) { + if (!is.hasItemMeta()) { + return false; + } + ItemMeta itemMeta = is.getItemMeta(); if (itemMeta.hasLore()) { List itemLore = itemMeta.getLore(); From 82bccd357b1582924c57f37a0720d5da0afaf17b Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 9 Mar 2013 10:21:05 +0100 Subject: [PATCH 43/94] Removed trailing whitespace --- src/main/resources/plugin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 30e71dcd6..f48691813 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1190,11 +1190,11 @@ permissions: default: false description: Implies all mcmmo.item permissions children: - mcmmo.item.all: true + mcmmo.item.all: true mcmmo.item.all: description: Implies all mcmmo.item permissions children: - mcmmo.item.chimaerawing: true + mcmmo.item.chimaerawing: true mcmmo.item.chimaerawing: description: Allows use of Chimaera Wing item mcmmo.motd: From 4b384abc5139e7586cb57b356f254aeab0b316e3 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 9 Mar 2013 10:26:57 +0100 Subject: [PATCH 44/94] Adding comments to config.yml and itemweights.yml --- src/main/resources/config.yml | 3 +++ src/main/resources/itemweights.yml | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9c8914981..2b54c48dd 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -359,8 +359,11 @@ Commands: # Settings for particles ### Particles: + # These settings determine if fireworks should get launched when a player activates/deactivates an ability Ability_Activation: true Ability_Deactivation: true + + # Use particle effect when these abilities trigger Dodge: true Bleed: true Greater_Impact: true diff --git a/src/main/resources/itemweights.yml b/src/main/resources/itemweights.yml index 7e4a36fa0..657e75e80 100644 --- a/src/main/resources/itemweights.yml +++ b/src/main/resources/itemweights.yml @@ -1,3 +1,13 @@ +# +# Item Weights configuration +# +# This file is used to determine the value of an item. This will only +# happen when users are sharing items in a party using the EQUAL item share mode. +# +# Rare items should have a higher value than common items. If an item is not listed +# here, the value from "Default" will be used instead. +# +##### Item_Weights: Default: 5 Emerald: 150 From ce32792668cc2517f4f55c8367e865fdfcc35331 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 9 Mar 2013 14:44:29 +0100 Subject: [PATCH 45/94] Fixed bug where Deflect was calculated based on the attacker, not the defender Closes #794 --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 2f50f575d..b83041cec 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -25,6 +25,7 @@ Version 1.4.03-dev = Fixed bug with using Salvage on stacked items. = Fixed bug where the 'mcmmo.commands.ptp.world.all' was registered twice = Fixed bug where Beast Lore wouldn't work on friendly pets + = Fixed bug where Deflect was calculated based on the attacker, not the defender. (We really did this time!) ! Moved the Salvage unlock level from config.yml to advanced.yml ! Changed how Chimaera Wings are acquired, you need to craft them now. (By default, use 5 feathers in a shapeless recipe) - Removed option to disable Salvage via the config file. This should be handled via permissions instead. 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 dd17f5b19..8e44e9774 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -232,7 +232,7 @@ public final class CombatUtils { UnarmedManager unarmedManager = UserManager.getPlayer((Player) target).getUnarmedManager(); if (unarmedManager.canDeflect()) { - event.setCancelled(mcMMOPlayer.getUnarmedManager().deflectCheck()); + event.setCancelled(unarmedManager.deflectCheck()); if (event.isCancelled()) { return; From 655dcb1c9b473320a94490103fc66904b4a66cba Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 9 Mar 2013 21:43:06 +0100 Subject: [PATCH 46/94] Add Cooldown setting for Chimaera Wing to default config.yml --- src/main/resources/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2b54c48dd..c6326227a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -72,6 +72,7 @@ Mods: Items: Chimaera_Wing: Enabled: true + Cooldown: 240 Prevent_Use_Underground: true Use_Cost: 1 Recipe_Cost: 5 From df67bd672098de2c10474d22dbb74dea68cf7459 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Sat, 9 Mar 2013 20:05:15 -0500 Subject: [PATCH 47/94] Message player only when enchants actually exist --- .../com/gmail/nossr50/skills/repair/RepairManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 a5cc6811b..0e4d101b1 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -297,17 +297,17 @@ public class RepairManager extends SkillManager { private void addEnchants(ItemStack item) { Player player = getPlayer(); - if (Permissions.arcaneBypass(player)) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); - return; - } - Map enchants = item.getEnchantments(); if (enchants.isEmpty()) { return; } + if (Permissions.arcaneBypass(player)) { + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); + return; + } + if (getArcaneForgingRank() == 0 || !Permissions.arcaneForging(player)) { for (Enchantment enchant : enchants.keySet()) { item.removeEnchantment(enchant); From 2cef6700c78e87e56c33643e6407d0714651e6a3 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 10 Mar 2013 14:53:51 -0400 Subject: [PATCH 48/94] Just to be 100% sure this gets processed correctly. The blockstate DOES current store the metadata of the block, but I'd rather stick with using the Block every time to be absolutely certain that things are handled correctly. --- .../com/gmail/nossr50/listeners/InventoryListener.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 94fd00cc4..3fcd9b724 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -132,14 +132,15 @@ public class InventoryListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFurnaceExtractEvent(FurnaceExtractEvent event) { - BlockState furnaceState = event.getBlock().getState(); + Block furnaceBlock = event.getBlock(); + BlockState furnaceState = furnaceBlock.getState(); if (furnaceState instanceof Furnace) { ItemStack result = ((Furnace) furnaceState).getInventory().getResult(); - if (furnaceState.hasMetadata(mcMMO.furnaceMetadataKey) && result != null && ItemUtils.isSmelted(result)) { + if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && result != null && ItemUtils.isSmelted(result)) { // We can make this assumption because we (should) be the only ones using this exact metadata - Player player = plugin.getServer().getPlayer(furnaceState.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString()); + Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString()); SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager(); From c0b4a33346f3cc335eee594a3c1805286ff6f902 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 10 Mar 2013 15:07:07 -0400 Subject: [PATCH 49/94] Importing Bukkit is usually bad. --- .../com/gmail/nossr50/commands/player/McrankCommand.java | 3 +-- .../com/gmail/nossr50/commands/player/MctopCommand.java | 3 +-- src/main/java/com/gmail/nossr50/mcMMO.java | 3 +-- .../runnables/commands/McrankCommandAsyncTask.java | 3 +-- .../runnables/commands/MctopCommandAsyncTask.java | 3 +-- src/main/java/com/gmail/nossr50/util/HolidayManager.java | 3 +-- .../nossr50/util/blockmeta/HashChunkletManager.java | 9 +++++---- .../util/blockmeta/chunkmeta/HashChunkManager.java | 6 +++--- 8 files changed, 14 insertions(+), 19 deletions(-) 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 5e0e60cad..8200265f3 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.player; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -119,6 +118,6 @@ public class McrankCommand implements CommandExecutor { } private void sqlDisplay(CommandSender sender, String playerName) { - Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McrankCommandAsyncTask(playerName, sender)); + mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new McrankCommandAsyncTask(playerName, sender)); } } 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 d0fcea9e5..d4ea6e6aa 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.player; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -124,6 +123,6 @@ public class MctopCommand implements CommandExecutor { } private void sqlDisplay(int page, String query, CommandSender sender, Command command) { - Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command)); + mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command)); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index d4a1e6fad..f0bc48c31 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -8,7 +8,6 @@ import java.util.List; import net.shatteredlands.shatt.backup.ZipLibrary; -import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; @@ -156,7 +155,7 @@ public class mcMMO extends JavaPlugin { getLogger().info("Please do not replace the mcMMO jar while the server is running."); } - Bukkit.getPluginManager().disablePlugin(this); + getServer().getPluginManager().disablePlugin(this); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java index 85ff65364..44b59f466 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables.commands; import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; @@ -24,7 +23,7 @@ public class McrankCommandAsyncTask implements Runnable { public void run() { final Map skills = DatabaseManager.readSQLRank(playerName); - Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { @Override public void run() { sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java index 9d04d98c6..4110b84f7 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.commands; import java.util.ArrayList; import java.util.HashMap; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -40,7 +39,7 @@ public class MctopCommandAsyncTask implements Runnable { } String tablePrefix = Config.getInstance().getMySQLTablePrefix(); 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() { + mcMMO.p.getServer().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")) { diff --git a/src/main/java/com/gmail/nossr50/util/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java index 42a72ae81..c0ddfd63a 100644 --- a/src/main/java/com/gmail/nossr50/util/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java @@ -12,7 +12,6 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -98,7 +97,7 @@ public final class HolidayManager { final int firework_amount = 10; for (int i = 0; i < firework_amount; i++) { int delay = (int) (Math.random() * 3) + 4; - Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { @Override public void run() { spawnFireworks((Player) sender); 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 8b60c6f19..fa970e58d 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -11,10 +11,11 @@ import java.io.StreamCorruptedException; import java.io.UTFDataFormatException; import java.util.HashMap; -import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.Block; +import com.gmail.nossr50.mcMMO; + public class HashChunkletManager implements ChunkletManager { public HashMap store = new HashMap(); @@ -168,7 +169,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void saveAll() { - for (World world : Bukkit.getWorlds()) { + for (World world : mcMMO.p.getServer().getWorlds()) { saveWorld(world); } } @@ -176,7 +177,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void unloadAll() { saveAll(); - for (World world : Bukkit.getWorlds()) { + for (World world : mcMMO.p.getServer().getWorlds()) { unloadWorld(world); } } @@ -276,7 +277,7 @@ public class HashChunkletManager implements ChunkletManager { for (String key : store.keySet()) { if (store.get(key).isEmpty()) { String[] info = key.split(","); - File dataDir = new File(Bukkit.getWorld(info[0]).getWorldFolder(), "mcmmo_data"); + File dataDir = new File(mcMMO.p.getServer().getWorld(info[0]).getWorldFolder(), "mcmmo_data"); File cxDir = new File(dataDir, "" + info[1]); if (!cxDir.exists()) { 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 c6f2daa5f..9495d29dd 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 @@ -11,12 +11,12 @@ import java.util.Iterator; import java.util.List; 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 com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory; public class HashChunkManager implements ChunkManager { @@ -283,7 +283,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void saveAll() { closeAll(); - for (World world : Bukkit.getWorlds()) { + for (World world : mcMMO.p.getServer().getWorlds()) { saveWorld(world); } } @@ -292,7 +292,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void unloadAll() { closeAll(); - for (World world : Bukkit.getWorlds()) { + for (World world : mcMMO.p.getServer().getWorlds()) { unloadWorld(world); } } From d78a1efbf61e12c51a037e0b2699e74be22cf4ef Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 10 Mar 2013 15:48:16 -0400 Subject: [PATCH 50/94] Fixed bug with Repair not decreasing enchanting levels properly. Fixes #817 --- Changelog.txt | 1 + .../java/com/gmail/nossr50/skills/repair/RepairManager.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index b83041cec..62dc748f0 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -11,6 +11,7 @@ Version 1.4.03-dev + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + Improved stats display for child skills + Added cooldown between using Chimaera Wings + = Fixed bug with Repair not decreasing enchanting levels properly = Fixed bug with Smelting not properly tracking furnaces = Fixed bug with Blast Mining not dropping blocks correctly = Fixed bug with custom blocks not working 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 0e4d101b1..979ce59e1 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -326,7 +326,7 @@ public class RepairManager extends SkillManager { int enchantLevel = enchant.getValue(); if (Repair.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) { - item.addEnchantment(enchantment, enchantLevel--); + item.addEnchantment(enchantment, enchantLevel - 1); downgraded = true; } } From 8059636b62fbcc664002b183b801e37ecf58790c Mon Sep 17 00:00:00 2001 From: T00thpick1 Date: Sun, 10 Mar 2013 15:45:25 -0400 Subject: [PATCH 51/94] Permissions for stat displays --- .../gmail/nossr50/commands/player/McrankCommand.java | 4 ++++ .../gmail/nossr50/commands/player/MctopCommand.java | 10 +++++----- .../runnables/commands/McrankCommandAsyncTask.java | 6 ++++++ 3 files changed, 15 insertions(+), 5 deletions(-) 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 8200265f3..b6eca1a1a 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -98,6 +98,10 @@ public class McrankCommand implements CommandExecutor { continue; } + if ((sender instanceof Player) && !Permissions.skillEnabled((Player) sender, skillType)) { + continue; + } + if (rankInts[1] == 0) { sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills } 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 d4ea6e6aa..0982c3882 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -72,6 +72,11 @@ public class MctopCommand implements CommandExecutor { } private void display(int page, String skill, CommandSender sender, boolean sql, Command command) { + if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) { + sender.sendMessage(command.getPermissionMessage()); + return; + } + if (sql) { if (skill.equalsIgnoreCase("all")) { sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command); @@ -86,11 +91,6 @@ public class MctopCommand implements CommandExecutor { } 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); diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java index 44b59f466..5b5216387 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -3,11 +3,13 @@ package com.gmail.nossr50.runnables.commands; import java.util.Map; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.database.DatabaseManager; 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 McrankCommandAsyncTask implements Runnable { @@ -34,6 +36,10 @@ public class McrankCommandAsyncTask implements Runnable { continue; } + if ((sender instanceof Player) && !Permissions.skillEnabled((Player) sender, skillType)) { + continue; + } + if (skills.get(skillType.name()) == null) { sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); } From 9eba2c683bfd5603080b24f590ab5141cbeed0ee Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 10 Mar 2013 17:07:07 -0400 Subject: [PATCH 52/94] Use equalsIgnoreCase() instead of equals(), and use == for compaing worlds. Fixes #815 --- .../gmail/nossr50/commands/party/PartyCommand.java | 2 +- .../nossr50/commands/party/PartyInfoCommand.java | 2 +- .../nossr50/commands/party/PartyRenameCommand.java | 2 +- .../nossr50/datatypes/player/PlayerProfile.java | 6 +++--- .../java/com/gmail/nossr50/party/PartyManager.java | 12 ++++++------ .../runnables/commands/MctopCommandAsyncTask.java | 2 +- .../runnables/database/SQLConversionTask.java | 2 +- .../gmail/nossr50/skills/archery/ArcheryManager.java | 2 +- src/main/java/com/gmail/nossr50/util/Misc.java | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) 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 8f765dc0f..f79c94987 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -104,7 +104,7 @@ public class PartyCommand implements CommandExecutor { } // Party leader commands - if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) { + if (!mcMMOPlayer.getParty().getLeader().equalsIgnoreCase(player.getName())) { sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index d079b5426..14304ba88 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -35,7 +35,7 @@ public class PartyInfoCommand implements CommandExecutor { StringBuilder memberList = new StringBuilder(); for (OfflinePlayer member : playerParty.getMembers()) { - if (playerParty.getLeader().equals(member.getName())) { + if (playerParty.getLeader().equalsIgnoreCase(member.getName())) { memberList.append(ChatColor.GOLD).append(member.getName()).append(" "); } else if (member.isOnline()) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java index 0072863cd..0b3ade249 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java @@ -40,7 +40,7 @@ public class PartyRenameCommand implements CommandExecutor { return true; } - if (!member.getName().equals(leaderName)) { + if (!member.getName().equalsIgnoreCase(leaderName)) { member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName)); } } 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 8b36d2cf0..e8f4c14cd 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -92,7 +92,7 @@ public class PlayerProfile { } else { for (HudType type : HudType.values()) { - if (type.toString().equals(huds.get(1).get(0))) { + if (type.toString().equalsIgnoreCase(huds.get(1).get(0))) { hudType = type; } } @@ -186,7 +186,7 @@ public class PlayerProfile { // Find if the line contains the player we want. String[] character = line.split(":"); - if (!character[0].equals(playerName)) { + if (!character[0].equalsIgnoreCase(playerName)) { continue; } @@ -400,7 +400,7 @@ public class PlayerProfile { // 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)) { + if (!line.split(":")[0].equalsIgnoreCase(playerName)) { writer.append(line).append("\r\n"); } else { diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index b758e06ca..9770f71ed 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -75,7 +75,7 @@ public final class PartyManager { List nearMembers = new ArrayList(); if (party != null) { for (Player member : party.getOnlineMembers()) { - if (!player.getName().equals(member.getName()) && Misc.isNear(player.getLocation(), member.getLocation(), range)) { + if (!player.getName().equalsIgnoreCase(member.getName()) && Misc.isNear(player.getLocation(), member.getLocation(), range)) { nearMembers.add(member); } } @@ -150,7 +150,7 @@ public final class PartyManager { public static Party getPlayerParty(String playerName) { for (Party party : parties) { for (OfflinePlayer member : party.getMembers()) { - if (member.getName().equals(playerName)) { + if (member.getName().equalsIgnoreCase(playerName)) { return party; } } @@ -184,7 +184,7 @@ public final class PartyManager { } else { // If the leaving player was the party leader, appoint a new leader from the party members - if (party.getLeader().equals(player.getName())) { + if (party.getLeader().equalsIgnoreCase(player.getName())) { String newLeader = members.get(0).getName(); party.setLeader(newLeader); } @@ -374,10 +374,10 @@ public final class PartyManager { String leaderName = party.getLeader(); for (Player member : party.getOnlineMembers()) { - if (member.getName().equals(playerName)) { + if (member.getName().equalsIgnoreCase(playerName)) { member.sendMessage(LocaleLoader.getString("Party.Owner.Player")); } - else if (member.getName().equals(leaderName)) { + else if (member.getName().equalsIgnoreCase(leaderName)) { member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader")); } else { @@ -396,7 +396,7 @@ public final class PartyManager { * @return true if the player can invite */ public static boolean canInvite(Player player, Party party) { - if (party.isLocked() && !party.getLeader().equals(player.getName())) { + if (party.isLocked() && !party.getLeader().equalsIgnoreCase(player.getName())) { return false; } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java index 4110b84f7..6dcd2f8b7 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java @@ -42,7 +42,7 @@ public class MctopCommandAsyncTask implements Runnable { mcMMO.p.getServer().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")) { + if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); } else { diff --git a/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java index 8297772f7..e2a840519 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java @@ -55,7 +55,7 @@ public class SQLConversionTask implements Runnable { 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")) { + if (playerName == null || playerName.equalsIgnoreCase("null") || playerName.equalsIgnoreCase("#Storage place for user information")) { continue; } 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 ca7858ed9..ab512d769 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -45,7 +45,7 @@ public class ArcheryManager extends SkillManager { Location shooterLocation = player.getLocation(); Location targetLocation = target.getLocation(); - if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) { + if (shooterLocation.getWorld() != targetLocation.getWorld()) { return; } diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index e19eebde6..cd018c33b 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -77,7 +77,7 @@ public final class Misc { * @return true if the distance between first and second is less than maxDistance, false otherwise */ public static boolean isNear(Location first, Location second, double maxDistance) { - if (!first.getWorld().equals(second.getWorld())) { + if (first.getWorld() != second.getWorld()) { return false; } From 3a7d88db4f1075364c5acc6708265ae9a0e8ff81 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 10 Mar 2013 21:30:35 -0400 Subject: [PATCH 53/94] Fixed bug with Blast Mining increasing TNT damage. --- Changelog.txt | 1 + .../java/com/gmail/nossr50/skills/mining/MiningManager.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 62dc748f0..d7f8593db 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -15,6 +15,7 @@ Version 1.4.03-dev = Fixed bug with Smelting not properly tracking furnaces = Fixed bug with Blast Mining not dropping blocks correctly = Fixed bug with custom blocks not working + = Fixed bug with Blast Mining increasing TNT damage. = Fixed bug where Blast Mining was awarding too much XP = Fixed bug where triple drops would award twice the amount of experience in Herbalism and Mining = Fixed bug where Green Thumb would consume wheat instead of seeds 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 3f70d4964..b56ac5929 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -173,7 +173,7 @@ public class MiningManager extends SkillManager{ } public int processDemolitionsExpertise(int damage) { - return (int) (damage * (100.0 - getBlastDamageModifier())); + return (int) (damage * ((100.0D - getBlastDamageModifier()) / 100.0D)); } /** From 410c946faf599d139823dc55fc44fb0c60aa477e Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Mar 2013 12:48:00 -0400 Subject: [PATCH 54/94] Tidying up Permission checks for /mcrank and /mctop --- .../nossr50/commands/player/McrankCommand.java | 14 +++++--------- .../nossr50/commands/player/MctopCommand.java | 12 ++++++------ .../runnables/commands/McrankCommandAsyncTask.java | 6 +----- .../runnables/commands/MctopCommandAsyncTask.java | 13 +------------ 4 files changed, 13 insertions(+), 32 deletions(-) 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 b6eca1a1a..a7fe0591b 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -23,15 +23,15 @@ public class McrankCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: + if (!(sender instanceof Player)) { + return false; + } + if (!Permissions.mcrank(sender)) { sender.sendMessage(command.getPermissionMessage()); return true; } - if (!(sender instanceof Player)) { - return false; - } - if (Config.getInstance().getUseMySQL()) { sqlDisplay(sender, sender.getName()); } @@ -94,11 +94,7 @@ public class McrankCommand implements CommandExecutor { for (SkillType skillType : SkillType.values()) { int[] rankInts = LeaderboardManager.getPlayerRank(playerName, skillType); - if (skillType.isChildSkill()) { - continue; - } - - if ((sender instanceof Player) && !Permissions.skillEnabled((Player) sender, skillType)) { + if ((sender instanceof Player && !Permissions.skillEnabled(sender, skillType)) || skillType.isChildSkill()) { continue; } 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 0982c3882..e86ee2dfc 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -79,18 +79,18 @@ public class MctopCommand implements CommandExecutor { if (sql) { if (skill.equalsIgnoreCase("all")) { - sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command); + sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender); } else { - sqlDisplay(page, skill, sender, command); + sqlDisplay(page, skill, sender); } } else { - flatfileDisplay(page, skill, sender, command); + flatfileDisplay(page, skill, sender); } } - private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) { + private void flatfileDisplay(int page, String skill, CommandSender sender) { LeaderboardManager.updateLeaderboards(); // Make sure we have the latest information String[] info = LeaderboardManager.retrieveInfo(skill, page); @@ -122,7 +122,7 @@ public class MctopCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip")); } - private void sqlDisplay(int page, String query, CommandSender sender, Command command) { - mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command)); + private void sqlDisplay(int page, String query, CommandSender sender) { + mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender)); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java index 5b5216387..27ad089bb 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -32,11 +32,7 @@ public class McrankCommandAsyncTask implements Runnable { sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName)); for (SkillType skillType : SkillType.values()) { - if (skillType.isChildSkill()) { - continue; - } - - if ((sender instanceof Player) && !Permissions.skillEnabled((Player) sender, skillType)) { + if ((sender instanceof Player && !Permissions.skillEnabled(sender, skillType)) || skillType.isChildSkill()) { continue; } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java index 6dcd2f8b7..085974058 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java @@ -4,15 +4,12 @@ import java.util.ArrayList; import java.util.HashMap; import org.bukkit.ChatColor; -import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.DatabaseManager; -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; public class MctopCommandAsyncTask implements Runnable { @@ -20,23 +17,15 @@ public class MctopCommandAsyncTask implements Runnable { private CommandSender sender; private String query; private int page; - private Command command; - public MctopCommandAsyncTask(int page, String query, CommandSender sender, Command command) { + public MctopCommandAsyncTask(int page, String query, CommandSender sender) { this.page = page; this.query = query; this.sender = sender; - this.command = command; } @Override public void run() { - if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { - if (!Permissions.mctop(sender, SkillType.getSkill(query))) { - sender.sendMessage(command.getPermissionMessage()); - return; - } - } String tablePrefix = Config.getInstance().getMySQLTablePrefix(); 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"); mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { From d0171809ecc0591f0f0c0ee66f90455e67a7a28a Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Mar 2013 21:06:26 -0400 Subject: [PATCH 55/94] Fixed bug with '/party chat (on|off)' and '/partychat (on|off)' not working --- Changelog.txt | 1 + .../nossr50/commands/chat/ChatCommand.java | 28 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index d7f8593db..a30212c04 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -11,6 +11,7 @@ Version 1.4.03-dev + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + Improved stats display for child skills + Added cooldown between using Chimaera Wings + = Fixed bug with '/party chat (on|off)' and '/partychat (on|off)' not working = Fixed bug with Repair not decreasing enchanting levels properly = Fixed bug with Smelting not properly tracking furnaces = Fixed bug with Blast Mining not dropping blocks correctly diff --git a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index 89372157e..06e3ab244 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -7,6 +7,8 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.chat.ChatMode; import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; public abstract class ChatCommand implements CommandExecutor { @@ -21,8 +23,8 @@ public abstract class ChatCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: - if (!(sender instanceof Player)) { - return false; + if (CommandUtils.noConsoleUsage(sender)) { + return true; } mcMMOPlayer = UserManager.getPlayer((Player) sender); @@ -38,19 +40,23 @@ public abstract class ChatCommand implements CommandExecutor { case 1: if (args[0].equalsIgnoreCase("on")) { - if (!(sender instanceof Player)) { - return false; + if (CommandUtils.noConsoleUsage(sender)) { + return true; } + mcMMOPlayer = UserManager.getPlayer((Player) sender); + enableChatMode(sender); return true; } if (args[0].equalsIgnoreCase("off")) { - if (!(sender instanceof Player)) { - return false; + if (CommandUtils.noConsoleUsage(sender)) { + return true; } + mcMMOPlayer = UserManager.getPlayer((Player) sender); + disableChatMode(sender); return true; } @@ -78,11 +84,21 @@ public abstract class ChatCommand implements CommandExecutor { protected abstract void handleChatSending(CommandSender sender, String[] args); private void enableChatMode(CommandSender sender) { + if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + return; + } + chatMode.enable(mcMMOPlayer); sender.sendMessage(chatMode.getEnabledMessage()); } private void disableChatMode(CommandSender sender) { + if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + return; + } + chatMode.disable(mcMMOPlayer); sender.sendMessage(chatMode.getDisabledMessage()); } From eabf0f7f8207340244952b50b15bcc07ac7bfd49 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Mar 2013 21:06:56 -0400 Subject: [PATCH 56/94] No need to use an empty locale string for this. --- .../java/com/gmail/nossr50/commands/party/PartyInfoCommand.java | 2 +- src/main/resources/locale/locale_en_US.properties | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index 14304ba88..06dea9f2b 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -97,6 +97,6 @@ public class PartyInfoCommand implements CommandExecutor { 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())); + player.sendMessage(createMembersList()); } } diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index efff6cac4..be3fa24cd 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -464,7 +464,6 @@ 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 Commands.Party.Members.Header=[[RED]]-----[][[GREEN]]MEMBERS[[RED]][]----- -Commands.Party.Members={0} Commands.Party.None=[[RED]]You are not in a party. Commands.Party.Quit=[[RED]]- Leave your current party Commands.Party.Teleport= [[RED]]- Teleport to party member From 9aa676cee123f42967ee90ef08c52101541dee15 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Mar 2013 22:51:44 -0400 Subject: [PATCH 57/94] We don't need to have two different executors for these commands. --- .../java/com/gmail/nossr50/commands/party/PartyCommand.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 f79c94987..48813700a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -5,7 +5,7 @@ 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.mcMMO; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Permissions; @@ -31,8 +31,8 @@ public class PartyCommand implements CommandExecutor { 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(); + private CommandExecutor partyTeleportCommand = mcMMO.p.getCommand("ptp").getExecutor(); + private CommandExecutor partyChatCommand = mcMMO.p.getCommand("partychat").getExecutor(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { From b2f400f61a4188b2def2078fe391881acd2166ed Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Tue, 12 Mar 2013 23:31:44 +0100 Subject: [PATCH 58/94] "Splinter the axe into dozens of pieces" --- Changelog.txt | 1 + .../java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java | 1 + 2 files changed, 2 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index a30212c04..eedc33025 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -29,6 +29,7 @@ Version 1.4.03-dev = Fixed bug where the 'mcmmo.commands.ptp.world.all' was registered twice = Fixed bug where Beast Lore wouldn't work on friendly pets = Fixed bug where Deflect was calculated based on the attacker, not the defender. (We really did this time!) + = Fixed bug where Treefeller would not deal durability damage when the axe "splinters into dozens of pieces" ! Moved the Salvage unlock level from config.yml to advanced.yml ! Changed how Chimaera Wings are acquired, you need to craft them now. (By default, use 5 feathers in a shapeless recipe) - Removed option to disable Salvage via the config file. This should be handled via permissions instead. 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 cb99beb9c..b4e5c7c17 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -232,6 +232,7 @@ public final class Woodcutting { short maxDurability = ModUtils.isCustomTool(inHand) ? ModUtils.getToolFromItemStack(inHand).getDurability() : inHandMaterial.getMaxDurability(); if (finalDurability >= maxDurability) { + inHand.setDurability(maxDurability); return false; } From 1313e3fe4b30606c6e72429d2727674441043156 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 13 Mar 2013 15:44:07 -0400 Subject: [PATCH 59/94] Fix CraftBukkit / Bukkit bug regarding event.getCurrentItem() throwing an ArrayIndexOutOfBounds error. --- .../java/com/gmail/nossr50/listeners/InventoryListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 3fcd9b724..4f8b7ecf7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -153,6 +153,8 @@ public class InventoryListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryClickEvent(InventoryClickEvent event) { - SkillUtils.removeAbilityBuff(event.getCurrentItem()); + if (event.getSlot() >= 0) { + SkillUtils.removeAbilityBuff(event.getCurrentItem()); + } } } From 3a26194a7191af71771306a70c3d305d4a941071 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 14 Mar 2013 10:25:54 -0400 Subject: [PATCH 60/94] Optimized a few things with our FFS leaderboards. --- .../nossr50/database/LeaderboardManager.java | 165 +++++++----------- 1 file changed, 67 insertions(+), 98 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java b/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java index a23daa114..fea4337de 100644 --- a/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java +++ b/src/main/java/com/gmail/nossr50/database/LeaderboardManager.java @@ -60,79 +60,79 @@ public final class LeaderboardManager { ArrayList players = new ArrayList(); while ((line = in.readLine()) != null) { - String[] character = line.split(":"); + String[] data = line.split(":"); - String p = character[0]; + String playerName = data[0]; int powerLevel = 0; // Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...) - if (players.contains(p)) { + if (players.contains(playerName)) { continue; } - players.add(p); + players.add(playerName); - if (character.length > 1 && StringUtils.isInt(character[1])) { - mining.add(new PlayerStat(p, Integer.parseInt(character[1]))); - powerLevel += Integer.parseInt(character[1]); + if (data.length > 1 && StringUtils.isInt(data[1])) { + mining.add(new PlayerStat(playerName, Integer.parseInt(data[1]))); + powerLevel += Integer.parseInt(data[1]); } - if (character.length > 5 && StringUtils.isInt(character[5])) { - woodcutting.add(new PlayerStat(p, Integer.parseInt(character[5]))); - powerLevel += Integer.parseInt(character[5]); + if (data.length > 5 && StringUtils.isInt(data[5])) { + woodcutting.add(new PlayerStat(playerName, Integer.parseInt(data[5]))); + powerLevel += Integer.parseInt(data[5]); } - if (character.length > 7 && StringUtils.isInt(character[7])) { - repair.add(new PlayerStat(p, Integer.parseInt(character[7]))); - powerLevel += Integer.parseInt(character[7]); + if (data.length > 7 && StringUtils.isInt(data[7])) { + repair.add(new PlayerStat(playerName, Integer.parseInt(data[7]))); + powerLevel += Integer.parseInt(data[7]); } - if (character.length > 8 && StringUtils.isInt(character[8])) { - unarmed.add(new PlayerStat(p, Integer.parseInt(character[8]))); - powerLevel += Integer.parseInt(character[8]); + if (data.length > 8 && StringUtils.isInt(data[8])) { + unarmed.add(new PlayerStat(playerName, Integer.parseInt(data[8]))); + powerLevel += Integer.parseInt(data[8]); } - if (character.length > 9 && StringUtils.isInt(character[9])) { - herbalism.add(new PlayerStat(p, Integer.parseInt(character[9]))); - powerLevel += Integer.parseInt(character[9]); + if (data.length > 9 && StringUtils.isInt(data[9])) { + herbalism.add(new PlayerStat(playerName, Integer.parseInt(data[9]))); + powerLevel += Integer.parseInt(data[9]); } - if (character.length > 10 && StringUtils.isInt(character[10])) { - excavation.add(new PlayerStat(p, Integer.parseInt(character[10]))); - powerLevel += Integer.parseInt(character[10]); + if (data.length > 10 && StringUtils.isInt(data[10])) { + excavation.add(new PlayerStat(playerName, Integer.parseInt(data[10]))); + powerLevel += Integer.parseInt(data[10]); } - if (character.length > 11 && StringUtils.isInt(character[11])) { - archery.add(new PlayerStat(p, Integer.parseInt(character[11]))); - powerLevel += Integer.parseInt(character[11]); + if (data.length > 11 && StringUtils.isInt(data[11])) { + archery.add(new PlayerStat(playerName, Integer.parseInt(data[11]))); + powerLevel += Integer.parseInt(data[11]); } - if (character.length > 12 && StringUtils.isInt(character[12])) { - swords.add(new PlayerStat(p, Integer.parseInt(character[12]))); - powerLevel += Integer.parseInt(character[12]); + if (data.length > 12 && StringUtils.isInt(data[12])) { + swords.add(new PlayerStat(playerName, Integer.parseInt(data[12]))); + powerLevel += Integer.parseInt(data[12]); } - if (character.length > 13 && StringUtils.isInt(character[13])) { - axes.add(new PlayerStat(p, Integer.parseInt(character[13]))); - powerLevel += Integer.parseInt(character[13]); + if (data.length > 13 && StringUtils.isInt(data[13])) { + axes.add(new PlayerStat(playerName, Integer.parseInt(data[13]))); + powerLevel += Integer.parseInt(data[13]); } - if (character.length > 14 && StringUtils.isInt(character[14])) { - acrobatics.add(new PlayerStat(p, Integer.parseInt(character[14]))); - powerLevel += Integer.parseInt(character[14]); + if (data.length > 14 && StringUtils.isInt(data[14])) { + acrobatics.add(new PlayerStat(playerName, Integer.parseInt(data[14]))); + powerLevel += Integer.parseInt(data[14]); } - if (character.length > 24 && StringUtils.isInt(character[24])) { - taming.add(new PlayerStat(p, Integer.parseInt(character[24]))); - powerLevel += Integer.parseInt(character[24]); + if (data.length > 24 && StringUtils.isInt(data[24])) { + taming.add(new PlayerStat(playerName, Integer.parseInt(data[24]))); + powerLevel += Integer.parseInt(data[24]); } - if (character.length > 34 && StringUtils.isInt(character[34])) { - fishing.add(new PlayerStat(p, Integer.parseInt(character[34]))); - powerLevel += Integer.parseInt(character[34]); + if (data.length > 34 && StringUtils.isInt(data[34])) { + fishing.add(new PlayerStat(playerName, Integer.parseInt(data[34]))); + powerLevel += Integer.parseInt(data[34]); } - powerLevels.add(new PlayerStat(p, powerLevel)); + powerLevels.add(new PlayerStat(playerName, powerLevel)); } in.close(); } @@ -188,72 +188,22 @@ public final class LeaderboardManager { statsList = playerStatHash.get(SkillType.getSkill(skillType)); } - int destination; + int destination = (pageNumber - 1) * 10; - // How many lines to skip through - if (pageNumber == 1) { - destination = 0; - } - else { - destination = (pageNumber * 10) - 9; - } - - int currentPos = 0; - - for (PlayerStat ps : statsList) { - if (currentPos == 10) { - break; - } - - if (destination > 1) { - destination--; - continue; - } - - info[currentPos] = ps.name + ":" + ps.statVal; - currentPos++; + for (int i = 0; i < 10; i++) { + PlayerStat ps = statsList.get(destination + i); + info[i] = ps.name + ":" + ps.statVal; } return info; } public static int[] getPlayerRank(String playerName) { - int currentPos = 1; - - if (powerLevels != null) { - for (PlayerStat stat : powerLevels) { - if (stat.name.equalsIgnoreCase(playerName)) { - return new int[] {currentPos, stat.statVal}; - } - - currentPos++; - continue; - } - - return new int[] {0, 0}; - } - - return new int[] {0, 0}; + return getPlayerRank(playerName, powerLevels); } public static int[] getPlayerRank(String playerName, SkillType skillType) { - int currentPos = 1; - List statsList = playerStatHash.get(skillType); - - if (statsList != null) { - for (PlayerStat stat : statsList) { - if (stat.name.equalsIgnoreCase(playerName)) { - return new int[] {currentPos, stat.statVal}; - } - - currentPos++; - continue; - } - - return new int[] {0, 0}; - } - - return new int[] {0, 0}; + return getPlayerRank(playerName, playerStatHash.get(skillType)); } public static boolean removeFlatFileUser(String playerName) { @@ -315,8 +265,9 @@ public final class LeaderboardManager { mcMMO.p.getLogger().info("Purging powerless users..."); int purgedUsers = 0; + for (PlayerStat stat : powerLevels) { - if (stat.statVal == 0 && removeFlatFileUser(stat.name) && !mcMMO.p.getServer().getOfflinePlayer(stat.name).isOnline()) { + if (stat.statVal == 0 && !mcMMO.p.getServer().getOfflinePlayer(stat.name).isOnline() && removeFlatFileUser(stat.name)) { purgedUsers++; } } @@ -394,6 +345,24 @@ public final class LeaderboardManager { return removedPlayers; } + private static int[] getPlayerRank(String playerName, List statsList) { + int currentPos = 1; + + if (statsList == null) { + return new int[] {0, 0}; + } + + for (PlayerStat stat : statsList) { + if (stat.name.equalsIgnoreCase(playerName)) { + return new int[] {currentPos, stat.statVal}; + } + + currentPos++; + } + + return new int[] {0, 0}; + } + private static class SkillComparator implements Comparator { @Override public int compare(PlayerStat o1, PlayerStat o2) { From 0cd3e4ed841cea5170127246e5a2e3f2ddfbbfdd Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Thu, 14 Mar 2013 22:13:23 +0100 Subject: [PATCH 61/94] Teleport to save spawn locations Changed underground usage check. --- .../com/gmail/nossr50/util/ChimaeraWing.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 6e4df42ce..ac5429f4e 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -4,12 +4,14 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.Block; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.Vector; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; @@ -32,7 +34,7 @@ public final class ChimaeraWing { return; } - Block block = player.getLocation().getBlock(); + Location location = player.getLocation(); int amount = inHand.getAmount(); long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt(); long lastChimaeraWing = (UserManager.getPlayer(player).getLastChimaeraTeleport()); @@ -47,12 +49,12 @@ public final class ChimaeraWing { player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost()))); if (Config.getInstance().getChimaeraPreventUseUnderground()) { - for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) { - if (!(block.getRelative(0, y, 0).getType() == Material.AIR)) { - player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); - player.teleport(block.getRelative(0, y - 1, 0).getLocation()); - return; - } + + if (location.getY() < player.getWorld().getHighestBlockYAt(location)) { + player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); + player.setVelocity(new Vector(0, 1, 0)); + UserManager.getPlayer(player).actualizeLastChimaeraTeleport(); + return; } } @@ -60,7 +62,13 @@ public final class ChimaeraWing { player.teleport(player.getBedSpawnLocation()); } else { - player.teleport(player.getWorld().getSpawnLocation()); + Location spawnLocation = player.getWorld().getSpawnLocation(); + if (spawnLocation.getBlock().getType() == Material.AIR) { + player.teleport(spawnLocation); + } + else { + player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation()); + } } UserManager.getPlayer(player).actualizeLastChimaeraTeleport(); From 0292d3eefb92cf6b2c86e2a9bbb2888b39689b05 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Thu, 14 Mar 2013 22:24:38 +0100 Subject: [PATCH 62/94] Cleanup ChimaeraWing --- .../com/gmail/nossr50/util/ChimaeraWing.java | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index ac5429f4e..957b2c3ac 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -45,42 +45,44 @@ public final class ChimaeraWing { return; } - if (SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player) && amount >= Config.getInstance().getChimaeraUseCost()) { - player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost()))); + if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player)) { + player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player))); + return; + } - if (Config.getInstance().getChimaeraPreventUseUnderground()) { + if (amount <= Config.getInstance().getChimaeraUseCost()) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", "Chimaera Wings")); //TODO Locale! + return; + } - if (location.getY() < player.getWorld().getHighestBlockYAt(location)) { - player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); - player.setVelocity(new Vector(0, 1, 0)); - UserManager.getPlayer(player).actualizeLastChimaeraTeleport(); - return; - } + player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost()))); + + if (Config.getInstance().getChimaeraPreventUseUnderground()) { + + if (location.getY() < player.getWorld().getHighestBlockYAt(location)) { + player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); + player.setVelocity(new Vector(0, 0.5D, 0)); + UserManager.getPlayer(player).actualizeLastChimaeraTeleport(); + return; } + } - if (player.getBedSpawnLocation() != null) { - player.teleport(player.getBedSpawnLocation()); + if (player.getBedSpawnLocation() != null) { + player.teleport(player.getBedSpawnLocation()); + } + else { + Location spawnLocation = player.getWorld().getSpawnLocation(); + if (spawnLocation.getBlock().getType() == Material.AIR) { + player.teleport(spawnLocation); } else { - Location spawnLocation = player.getWorld().getSpawnLocation(); - if (spawnLocation.getBlock().getType() == Material.AIR) { - player.teleport(spawnLocation); - } - else { - player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation()); - } + player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation()); } + } - UserManager.getPlayer(player).actualizeLastChimaeraTeleport(); - MetricsManager.chimeraWingUsed(); - player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass")); - } - else if (!SkillUtils.cooldownOver(recentlyHurt, 60 * Misc.TIME_CONVERSION_FACTOR, player) && amount >= Config.getInstance().getChimaeraUseCost()) { - player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt, 60, player))); - } - else if (amount <= Config.getInstance().getChimaeraUseCost()) { - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", "Chimaera Wings")); //TODO Locale! - } + UserManager.getPlayer(player).actualizeLastChimaeraTeleport(); + MetricsManager.chimeraWingUsed(); + player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass")); } } From 69bf17a61960ec27e6369553c447bbadfb1afaae Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Thu, 14 Mar 2013 22:26:02 +0100 Subject: [PATCH 63/94] Added Bat takeoff sound when using a Chimaera Wing --- src/main/java/com/gmail/nossr50/util/ChimaeraWing.java | 1 + src/main/java/com/gmail/nossr50/util/Misc.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 957b2c3ac..6eea95d23 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -82,6 +82,7 @@ public final class ChimaeraWing { UserManager.getPlayer(player).actualizeLastChimaeraTeleport(); MetricsManager.chimeraWingUsed(); + player.playSound(location, Sound.BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH); player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass")); } } diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index cd018c33b..e2c71f8d7 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -26,6 +26,8 @@ public final class Misc { 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 BAT_VOLUME = 1.0F; + public static final float BAT_PITCH = 0.6F; private Misc() {}; From 5aecedc074643c002c4f6062222ac78aae05a1c0 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Thu, 14 Mar 2013 22:31:44 +0100 Subject: [PATCH 64/94] Damage the player when ChimaeraWing use failed --- src/main/java/com/gmail/nossr50/util/ChimaeraWing.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 6eea95d23..0557c8865 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -17,6 +17,7 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.metrics.MetricsManager; import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.SkillUtils; public final class ChimaeraWing { @@ -62,6 +63,7 @@ public final class ChimaeraWing { if (location.getY() < player.getWorld().getHighestBlockYAt(location)) { player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); player.setVelocity(new Vector(0, 0.5D, 0)); + CombatUtils.dealDamage(player, Misc.getRandom().nextInt(player.getHealth() - 10)); UserManager.getPlayer(player).actualizeLastChimaeraTeleport(); return; } From 33882983e956166029853bd8e46522700267ed4e Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Thu, 14 Mar 2013 22:32:35 +0100 Subject: [PATCH 65/94] Update the changelog --- Changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.txt b/Changelog.txt index eedc33025..c4b318e61 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -32,6 +32,7 @@ Version 1.4.03-dev = Fixed bug where Treefeller would not deal durability damage when the axe "splinters into dozens of pieces" ! Moved the Salvage unlock level from config.yml to advanced.yml ! Changed how Chimaera Wings are acquired, you need to craft them now. (By default, use 5 feathers in a shapeless recipe) + ! Changed how Chimaera Wings teleport players to the spawnpoint, will now check if the location is save - Removed option to disable Salvage via the config file. This should be handled via permissions instead. - Removed the option to use Woodcutting without an axe from the config file. From 23719ace47e52241188cb3c52a23aa107e6563b8 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 14 Mar 2013 22:27:24 -0400 Subject: [PATCH 66/94] 1.4.03 Bugfix Release --- Changelog.txt | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c4b318e61..a034ef65b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,7 +7,7 @@ Key: ! Change - Removal -Version 1.4.03-dev +Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + Improved stats display for child skills + Added cooldown between using Chimaera Wings @@ -32,7 +32,7 @@ Version 1.4.03-dev = Fixed bug where Treefeller would not deal durability damage when the axe "splinters into dozens of pieces" ! Moved the Salvage unlock level from config.yml to advanced.yml ! Changed how Chimaera Wings are acquired, you need to craft them now. (By default, use 5 feathers in a shapeless recipe) - ! Changed how Chimaera Wings teleport players to the spawnpoint, will now check if the location is save + ! Changed how Chimaera Wings teleport players to the spawnpoint, will now check if the location is safe - Removed option to disable Salvage via the config file. This should be handled via permissions instead. - Removed the option to use Woodcutting without an axe from the config file. diff --git a/pom.xml b/pom.xml index 9e7f242c9..53f19ec6e 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.4.03-dev1 + 1.4.03 mcMMO https://github.com/mcMMO-Dev/mcMMO From dcfdfa0e621dcb210c7d39631ce9913588c8e5f0 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 14 Mar 2013 22:28:05 -0400 Subject: [PATCH 67/94] 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 a034ef65b..744fa7b5a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,8 @@ Key: ! Change - Removal +Version 1.4.04-dev + Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker + Improved stats display for child skills diff --git a/pom.xml b/pom.xml index 53f19ec6e..dab7f3382 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.4.03 + 1.4.04-dev1 mcMMO https://github.com/mcMMO-Dev/mcMMO From 2838a52e0c6760285b0735abd0a96aace54eacac Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Mar 2013 16:25:42 -0400 Subject: [PATCH 68/94] Clean up on all of our commands. Abstracted experience commands and hardcore commands. Moved lots of duplicated code to functions in CommandUtils.java. Split /ptp into individual commands, just like /party. Used ternary logic to simplify some of our /skillname stat displays. Fixed skill guide to not allow for negative pages. Simplified logic for many /skillname data calculations. Use permission checks to prevent calculating data that will never be displayed. Made the skill guide into its own command. --- .../nossr50/commands/McabilityCommand.java | 59 +++-- .../gmail/nossr50/commands/McgodCommand.java | 68 +++--- .../nossr50/commands/McrefreshCommand.java | 52 ++--- .../gmail/nossr50/commands/XprateCommand.java | 21 +- .../nossr50/commands/chat/ChatCommand.java | 13 +- .../commands/database/McremoveCommand.java | 5 +- .../commands/experience/AddlevelsCommand.java | 158 ++----------- .../commands/experience/AddxpCommand.java | 162 ++----------- .../experience/ExperienceCommand.java | 149 ++++++++++++ .../commands/experience/MmoeditCommand.java | 153 ++---------- .../experience/SkillresetCommand.java | 166 +++++-------- .../commands/hardcore/HardcoreCommand.java | 96 +++----- .../hardcore/HardcoreModeCommand.java | 94 ++++++++ .../commands/hardcore/VampirismCommand.java | 101 +++----- .../commands/party/PartyAcceptCommand.java | 7 +- .../party/PartyChangeOwnerCommand.java | 3 +- .../party/PartyChangePasswordCommand.java | 15 +- .../nossr50/commands/party/PartyCommand.java | 5 +- .../commands/party/PartyCreateCommand.java | 13 +- .../commands/party/PartyDisbandCommand.java | 5 +- .../commands/party/PartyExpShareCommand.java | 11 +- .../commands/party/PartyHelpCommand.java | 1 - .../commands/party/PartyInfoCommand.java | 18 +- .../commands/party/PartyInviteCommand.java | 29 +-- .../commands/party/PartyItemShareCommand.java | 31 +-- .../commands/party/PartyJoinCommand.java | 18 +- .../commands/party/PartyKickCommand.java | 3 +- .../commands/party/PartyLockCommand.java | 24 +- .../commands/party/PartyQuitCommand.java | 9 +- .../commands/party/PartyRenameCommand.java | 18 +- .../nossr50/commands/party/PtpCommand.java | 218 ------------------ .../party/teleport/PtpAcceptAnyCommand.java | 34 +++ .../party/teleport/PtpAcceptCommand.java | 64 +++++ .../commands/party/teleport/PtpCommand.java | 133 +++++++++++ .../party/teleport/PtpToggleCommand.java | 34 +++ .../commands/player/InspectCommand.java | 54 ++--- .../commands/player/McrankCommand.java | 32 +-- .../commands/player/McstatsCommand.java | 16 +- .../nossr50/commands/player/MctopCommand.java | 90 ++++---- .../commands/skills/AcrobaticsCommand.java | 45 ++-- .../commands/skills/ArcheryCommand.java | 40 ++-- .../nossr50/commands/skills/AxesCommand.java | 49 ++-- .../commands/skills/ExcavationCommand.java | 15 +- .../commands/skills/FishingCommand.java | 55 +++-- .../commands/skills/HerbalismCommand.java | 109 ++++----- .../commands/skills/MiningCommand.java | 78 +++---- .../commands/skills/RepairCommand.java | 36 ++- .../nossr50/commands/skills/SkillCommand.java | 150 ++++++------ .../commands/skills/SkillGuideCommand.java | 119 ++++------ .../commands/skills/SmeltingCommand.java | 46 ++-- .../commands/skills/SwordsCommand.java | 55 ++--- .../commands/skills/TamingCommand.java | 15 +- .../commands/skills/UnarmedCommand.java | 69 +++--- .../commands/skills/WoodcuttingCommand.java | 42 ++-- .../nossr50/commands/spout/SpoutCommand.java | 3 +- .../nossr50/commands/spout/XplockCommand.java | 11 +- .../nossr50/database/DatabaseManager.java | 33 +-- .../nossr50/datatypes/player/McMMOPlayer.java | 4 + .../datatypes/player/PlayerProfile.java | 4 + .../com/gmail/nossr50/party/PartyManager.java | 9 + .../java/com/gmail/nossr50/util/Misc.java | 28 +++ .../commands/CommandRegistrationManager.java | 4 +- .../nossr50/util/commands/CommandUtils.java | 206 ++++++++++++----- .../gmail/nossr50/util/skills/PerksUtils.java | 4 +- 64 files changed, 1550 insertions(+), 1861 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java delete mode 100644 src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java create mode 100644 src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java diff --git a/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java b/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java index aeaf06e9a..f84098fe0 100644 --- a/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java @@ -6,33 +6,32 @@ 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.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; public class McabilityCommand implements CommandExecutor { + private McMMOPlayer mcMMOPlayer; + private Player player; + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - McMMOPlayer mcMMOPlayer; - switch (args.length) { case 0: + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + if (!Permissions.mcability(sender)) { sender.sendMessage(command.getPermissionMessage()); return true; } - mcMMOPlayer = UserManager.getPlayer((Player) sender); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); - if (mcMMOPlayer.getAbilityUse()) { - sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off")); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Ability.On")); - } - - mcMMOPlayer.toggleAbilityUse(); + toggleAbilityUse(); return true; case 1: @@ -43,37 +42,33 @@ public class McabilityCommand implements CommandExecutor { mcMMOPlayer = UserManager.getPlayer(args[0]); - if (mcMMOPlayer == null) { - PlayerProfile playerProfile = new PlayerProfile(args[0], false); - - if (!playerProfile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + if (CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) { return true; } - Player player = mcMMOPlayer.getPlayer(); + player = mcMMOPlayer.getPlayer(); - if (!player.isOnline()) { - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + if (CommandUtils.isOffline(sender, player)) { return true; } - if (mcMMOPlayer.getAbilityUse()) { - player.sendMessage(LocaleLoader.getString("Commands.Ability.Off")); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.Ability.On")); - } - - mcMMOPlayer.toggleAbilityUse(); + toggleAbilityUse(); + sender.sendMessage("Ability use has been toggled for" + args[0]); // TODO: Localize return true; default: return false; } } + + private void toggleAbilityUse() { + if (mcMMOPlayer.getAbilityUse()) { + player.sendMessage(LocaleLoader.getString("Commands.Ability.Off")); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.Ability.On")); + } + + mcMMOPlayer.toggleAbilityUse(); + } } diff --git a/src/main/java/com/gmail/nossr50/commands/McgodCommand.java b/src/main/java/com/gmail/nossr50/commands/McgodCommand.java index b89b15b70..b9e865d7e 100644 --- a/src/main/java/com/gmail/nossr50/commands/McgodCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McgodCommand.java @@ -6,42 +6,32 @@ 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.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; public class McgodCommand implements CommandExecutor { + private McMMOPlayer mcMMOPlayer; + private Player player; + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - McMMOPlayer mcMMOPlayer; - switch (args.length) { case 0: + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + if (!Permissions.mcgod(sender)) { sender.sendMessage(command.getPermissionMessage()); return true; } - if (!(sender instanceof Player)) { - return false; - } + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); - mcMMOPlayer = UserManager.getPlayer((Player) sender); - - if (mcMMOPlayer == null) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - if (mcMMOPlayer.getGodMode()) { - sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled")); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled")); - } - - mcMMOPlayer.toggleGodMode(); + toggleGodMode(); return true; case 1: @@ -52,37 +42,33 @@ public class McgodCommand implements CommandExecutor { mcMMOPlayer = UserManager.getPlayer(args[0]); - if (mcMMOPlayer == null) { - PlayerProfile playerProfile = new PlayerProfile(args[0], false); - - if (!playerProfile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + if (CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) { return true; } - Player player = mcMMOPlayer.getPlayer(); + player = mcMMOPlayer.getPlayer(); - if (!player.isOnline()) { - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + if (CommandUtils.isOffline(sender, player)) { return true; } - if (mcMMOPlayer.getGodMode()) { - player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled")); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled")); - } - - mcMMOPlayer.toggleGodMode(); + toggleGodMode(); + sender.sendMessage("God mode has been toggled for" + args[0]); // TODO: Localize return true; default: return false; } } + + private void toggleGodMode() { + if (mcMMOPlayer.getGodMode()) { + player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled")); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled")); + } + + mcMMOPlayer.toggleGodMode(); + } } diff --git a/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java b/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java index b6bf8b8b2..70df499a7 100644 --- a/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java @@ -6,35 +6,32 @@ 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.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; public class McrefreshCommand implements CommandExecutor { + private McMMOPlayer mcMMOPlayer; + private Player player; + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - McMMOPlayer mcMMOPlayer; - switch (args.length) { case 0: + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + if (!Permissions.mcrefresh(sender)) { sender.sendMessage(command.getPermissionMessage()); return true; } - if (!(sender instanceof Player)) { - return false; - } - mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); - mcMMOPlayer.setRecentlyHurt(0); - mcMMOPlayer.getProfile().resetCooldowns(); - mcMMOPlayer.resetToolPrepMode(); - mcMMOPlayer.resetAbilityMode(); - - sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); + refreshPlayer(); return true; case 1: @@ -45,31 +42,17 @@ public class McrefreshCommand implements CommandExecutor { mcMMOPlayer = UserManager.getPlayer(args[0]); - if (mcMMOPlayer == null) { - PlayerProfile playerProfile = new PlayerProfile(args[0], false); - - if (!playerProfile.isLoaded()) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + if (CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) { return true; } Player player = mcMMOPlayer.getPlayer(); - if (!player.isOnline()) { - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + if (CommandUtils.isOffline(sender, player)) { return true; } - mcMMOPlayer.setRecentlyHurt(0); - mcMMOPlayer.getProfile().resetCooldowns(); - mcMMOPlayer.resetToolPrepMode(); - mcMMOPlayer.resetAbilityMode(); - - player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); + refreshPlayer(); sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0])); return true; @@ -77,4 +60,13 @@ public class McrefreshCommand implements CommandExecutor { return false; } } + + private void refreshPlayer() { + mcMMOPlayer.setRecentlyHurt(0); + mcMMOPlayer.getProfile().resetCooldowns(); + mcMMOPlayer.resetToolPrepMode(); + mcMMOPlayer.resetAbilityMode(); + + player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); + } } diff --git a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java index 50e9e7c34..5b9214244 100644 --- a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java @@ -8,10 +8,14 @@ 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; +import com.gmail.nossr50.util.commands.CommandUtils; public class XprateCommand implements CommandExecutor { - private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier(); + private double originalRate; + + public XprateCommand() { + originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier(); + } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -35,8 +39,8 @@ public class XprateCommand implements CommandExecutor { return true; case 2: - if (!StringUtils.isInt(args[0])) { - return false; + if (CommandUtils.isInvalidInteger(sender, args[0])) { + return true; } if (!Permissions.xprateSet(sender)) { @@ -44,11 +48,16 @@ public class XprateCommand implements CommandExecutor { return true; } - if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) { + if (CommandUtils.shouldDisableToggle(args[1])) { + mcMMO.p.setXPEventEnabled(false); + } + else if (CommandUtils.shouldEnableToggle(args[1])) { + mcMMO.p.setXPEventEnabled(true); + } + else { return false; } - mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1])); int newXpRate = Integer.parseInt(args[0]); Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate); diff --git a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index 06e3ab244..d6291b0bd 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -3,7 +3,6 @@ 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; @@ -12,8 +11,8 @@ import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; public abstract class ChatCommand implements CommandExecutor { - protected McMMOPlayer mcMMOPlayer; protected ChatMode chatMode; + private McMMOPlayer mcMMOPlayer; public ChatCommand(ChatMode chatMode) { this.chatMode = chatMode; @@ -27,7 +26,7 @@ public abstract class ChatCommand implements CommandExecutor { return true; } - mcMMOPlayer = UserManager.getPlayer((Player) sender); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); if (chatMode.isEnabled(mcMMOPlayer)) { disableChatMode(sender); @@ -39,23 +38,23 @@ public abstract class ChatCommand implements CommandExecutor { return true; case 1: - if (args[0].equalsIgnoreCase("on")) { + if (CommandUtils.shouldEnableToggle(args[0])) { if (CommandUtils.noConsoleUsage(sender)) { return true; } - mcMMOPlayer = UserManager.getPlayer((Player) sender); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); enableChatMode(sender); return true; } - if (args[0].equalsIgnoreCase("off")) { + if (CommandUtils.shouldDisableToggle(args[0])) { if (CommandUtils.noConsoleUsage(sender)) { return true; } - mcMMOPlayer = UserManager.getPlayer((Player) sender); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); disableChatMode(sender); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java index c6615a9f1..0c5cbf64a 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java @@ -8,6 +8,7 @@ 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.Misc; import com.gmail.nossr50.util.Permissions; public class McremoveCommand implements CommandExecutor { @@ -25,7 +26,7 @@ public class McremoveCommand implements CommandExecutor { String tablePrefix = Config.getInstance().getMySQLTablePrefix(); if (DatabaseManager.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) { - DatabaseManager.profileCleanup(args[0]); + Misc.profileCleanup(args[0]); sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0])); } else { @@ -34,7 +35,7 @@ public class McremoveCommand implements CommandExecutor { } else { if (LeaderboardManager.removeFlatFileUser(args[0])) { - DatabaseManager.profileCleanup(args[0]); + Misc.profileCleanup(args[0]); sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0])); } else { diff --git a/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java index f2b146e36..cf21761a7 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java @@ -1,154 +1,36 @@ 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 { +public class AddlevelsCommand extends ExperienceCommand { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - int levels; - boolean allSkills = false; - SkillType skill = null; + protected boolean permissionsCheckSelf(CommandSender sender) { + return Permissions.addlevels(sender); + } - switch (args.length) { - case 2: - if (!Permissions.addlevels(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } + @Override + protected boolean permissionsCheckOthers(CommandSender sender) { + return Permissions.addlevelsOthers(sender); + } - if (!(sender instanceof Player)) { - return false; - } + @Override + protected void handleCommand(SkillType skill) { + profile.addLevels(skill, value); + } - if (args[0].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillUtils.isSkill(args[0])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } + @Override + protected void handlePlayerMessageAll() { + player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value)); + } - 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; - } + @Override + protected void handlePlayerMessageSkill() { + player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, SkillUtils.getSkillName(skill))); + } } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java index c965ef0bb..806a25b64 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java @@ -1,152 +1,40 @@ 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 { +public class AddxpCommand extends ExperienceCommand { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - int xp; - McMMOPlayer mcMMOPlayer; - PlayerProfile profile; - boolean allSkills = false; - SkillType skill = null; + protected boolean permissionsCheckSelf(CommandSender sender) { + return Permissions.addxp(sender); + } - switch (args.length) { - case 2: - if (!Permissions.addxp(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } + @Override + protected boolean permissionsCheckOthers(CommandSender sender) { + return Permissions.addxpOthers(sender); + } - 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; + @Override + protected void handleCommand(SkillType skill) { + if (player != null) { + mcMMOPlayer.applyXpGain(skill, value); + } + else { + profile.setSkillXpLevel(skill, value); } } + + @Override + protected void handlePlayerMessageAll() { + player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value)); + } + + @Override + protected void handlePlayerMessageSkill() { + player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, SkillUtils.getSkillName(skill))); + } } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java new file mode 100644 index 000000000..b8b22cc8c --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java @@ -0,0 +1,149 @@ +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.commands.CommandUtils; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; + + +public abstract class ExperienceCommand implements CommandExecutor { + protected McMMOPlayer mcMMOPlayer; + protected Player player; + protected PlayerProfile profile; + + protected boolean allSkills; + protected SkillType skill; + protected int value; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 2: + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + + if (!permissionsCheckSelf(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (!validateArguments(sender, args[0], args[1])) { + return true; + } + + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); + profile = mcMMOPlayer.getProfile(); + + editValues(); + return true; + + case 3: + if (!permissionsCheckOthers(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (!validateArguments(sender, args[1], args[2])) { + return true; + } + + 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 (CommandUtils.unloadedProfile(sender, profile)) { + return true; + } + + editValues(); + profile.save(); // Since this is a temporary profile, we save it here. + } + else { + profile = mcMMOPlayer.getProfile(); + editValues(); + } + + handleSenderMessage(sender, args[0]); + return true; + + default: + return false; + } + } + + protected abstract boolean permissionsCheckSelf(CommandSender sender); + protected abstract boolean permissionsCheckOthers(CommandSender sender); + protected abstract void handleCommand(SkillType skill); + protected abstract void handlePlayerMessageAll(); + protected abstract void handlePlayerMessageSkill(); + + private boolean validateArguments(CommandSender sender, String skillName, String value) { + if (isInvalidInteger(sender, value) || isInvalidSkill(sender, skillName)) { + return false; + } + + return true; + } + + private boolean isInvalidInteger(CommandSender sender, String value) { + if (CommandUtils.isInvalidInteger(sender, value)) { + return true; + } + + this.value = Integer.parseInt(value); + return false; + } + + protected boolean isInvalidSkill(CommandSender sender, String skillName) { + if (skillName.equalsIgnoreCase("all")) { + allSkills = true; + return false; + } + else if (CommandUtils.isInvalidSkill(sender, skillName)) { + return true; + } + + skill = SkillType.getSkill(skillName); + return false; + } + + protected void handleSenderMessage(CommandSender sender, String playerName) { + if (allSkills) { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName)); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), playerName)); + } + } + + protected void editValues() { + if (allSkills) { + for (SkillType skillType : SkillType.values()) { + handleCommand(skillType); + } + + if (player != null) { + handlePlayerMessageAll(); + } + } + else { + handleCommand(skill); + + if (player != null) { + handlePlayerMessageSkill(); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java index a2e878268..832475316 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java @@ -1,150 +1,35 @@ 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 { +public class MmoeditCommand extends ExperienceCommand { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - int newValue; - boolean allSkills = false; - SkillType skill = null; + protected boolean permissionsCheckSelf(CommandSender sender) { + return Permissions.mmoedit(sender); + } - switch (args.length) { - case 2: - if (!Permissions.mmoedit(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } + @Override + protected boolean permissionsCheckOthers(CommandSender sender) { + return Permissions.mmoeditOthers(sender); + } - if (!(sender instanceof Player)) { - return false; - } + @Override + protected void handleCommand(SkillType skill) { + profile.modifySkill(skill, value); + } - if (args[0].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillUtils.isSkill(args[0])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); - return true; - } + @Override + protected void handlePlayerMessageAll() { + player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value)); + } - 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; - } + @Override + protected void handlePlayerMessageSkill() { + player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), value)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java index efe3699e7..ac474e4df 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java @@ -1,76 +1,45 @@ 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.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; -public class SkillresetCommand implements CommandExecutor { +public class SkillresetCommand extends ExperienceCommand { + private CommandSender sender; + private Command command; + @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 (CommandUtils.noConsoleUsage(sender)) { + return true; + } + 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")); + if (isInvalidSkill(sender, args[0])) { return true; } - profile = UserManager.getPlayer((Player) sender).getProfile(); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); + profile = mcMMOPlayer.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)); - } + this.command = command; + this.sender = sender; + editValues(); return true; case 2: @@ -79,91 +48,68 @@ public class SkillresetCommand implements CommandExecutor { return true; } - if (args[1].equalsIgnoreCase("all")) { - allSkills = true; - } - else if (!SkillUtils.isSkill(args[1])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + if (isInvalidSkill(sender, args[1])) { 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]); + 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")); + if (CommandUtils.unloadedProfile(sender, profile)) { 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); - } + this.command = command; + this.sender = sender; + editValues(); 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])); + editValues(); } + handleSenderMessage(sender, args[0]); return true; default: return false; } } + + @Override + protected boolean permissionsCheckSelf(CommandSender sender) { + // TODO Auto-generated method stub + return false; + } + + @Override + protected boolean permissionsCheckOthers(CommandSender sender) { + // TODO Auto-generated method stub + return false; + } + + @Override + protected void handleCommand(SkillType skill) { + if ((player.equals(sender) && !Permissions.skillreset(sender, skill)) || (!player.equals(sender) && !Permissions.skillresetOthers(sender, skill))) { + sender.sendMessage(command.getPermissionMessage()); + return; + } + + profile.modifySkill(skill, 0); + } + + @Override + protected void handlePlayerMessageAll() { + player.sendMessage(LocaleLoader.getString("Commands.Reset.All")); + } + + @Override + protected void handlePlayerMessageSkill() { + player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", SkillUtils.getSkillName(skill))); + } } diff --git a/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreCommand.java b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreCommand.java index c4c07a043..ce4f53f2e 100644 --- a/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreCommand.java @@ -1,85 +1,41 @@ 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 { +public class HardcoreCommand extends HardcoreModeCommand { @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() { + protected void disable() { Config.getInstance().setHardcoreEnabled(false); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled")); } - private void enableHardcore() { + @Override + protected void enable() { Config.getInstance().setHardcoreEnabled(true); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled")); } -} + + @Override + protected boolean checkTogglePermissions() { + return Permissions.hardcoreToggle(sender); + } + + @Override + protected boolean checkModifyPermissions() { + return Permissions.hardcoreModify(sender); + } + + @Override + protected boolean checkEnabled() { + return Config.getInstance().getHardcoreEnabled(); + } + + @Override + protected void modify() { + Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent); + sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D))); + } +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java new file mode 100644 index 000000000..f0e7c024c --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java @@ -0,0 +1,94 @@ +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.util.Permissions; +import com.gmail.nossr50.util.commands.CommandUtils; + +public abstract class HardcoreModeCommand implements CommandExecutor { + protected CommandSender sender; + protected double newPercent; + protected DecimalFormat percent; + + public HardcoreModeCommand() { + percent = new DecimalFormat("##0.00%"); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 0: + this.sender = sender; + + if (!checkTogglePermissions()) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + if (checkEnabled()) { + disable(); + } + else { + enable(); + } + + return true; + + case 1: + if (CommandUtils.shouldEnableToggle(args[0])) { + if (!Permissions.hardcoreToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + enable(); + return true; + } + + if (CommandUtils.shouldDisableToggle(args[0])) { + if (!Permissions.hardcoreToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + disable(); + return true; + } + + if (isInvalidPercentage(sender, args[0])) { + return true; + } + + if (!Permissions.hardcoreModify(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + modify(); + return true; + + default: + return false; + } + } + + protected abstract boolean checkTogglePermissions(); + protected abstract boolean checkModifyPermissions(); + protected abstract boolean checkEnabled(); + protected abstract void enable(); + protected abstract void disable(); + protected abstract void modify(); + + private boolean isInvalidPercentage(CommandSender sender, String value) { + if (CommandUtils.isInvalidDouble(sender, value)) { + return true; + } + + newPercent = Double.parseDouble(value); + return false; + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/hardcore/VampirismCommand.java b/src/main/java/com/gmail/nossr50/commands/hardcore/VampirismCommand.java index 4abc8deb9..ad52f07a9 100644 --- a/src/main/java/com/gmail/nossr50/commands/hardcore/VampirismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/hardcore/VampirismCommand.java @@ -1,90 +1,41 @@ 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 { +public class VampirismCommand extends HardcoreModeCommand { @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; - } + protected boolean checkTogglePermissions() { + return Permissions.vampirismToggle(sender); } - private void disableVampirism() { + @Override + protected boolean checkModifyPermissions() { + return Permissions.vampirismModify(sender); + } + + @Override + protected boolean checkEnabled() { + return Config.getInstance().getHardcoreVampirismEnabled(); + } + + @Override + protected void enable() { + Config.getInstance().setHardcoreVampirismEnabled(true); + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled")); + } + + @Override + protected void disable() { 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")); + @Override + protected void modify() { + Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent); + sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D))); } -} +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java index 5dd85df1f..a56347230 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java @@ -11,15 +11,12 @@ 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); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + Player player = mcMMOPlayer.getPlayer(); if (!mcMMOPlayer.hasPartyInvite()) { sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java index b1a9d93d0..6099bbf56 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java @@ -3,7 +3,6 @@ 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; @@ -16,7 +15,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: - Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + Party playerParty = UserManager.getPlayer(sender.getName()).getParty(); if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) { sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java index 1e4720403..5dad435d0 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java @@ -3,29 +3,30 @@ 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 { + private Party playerParty; + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + playerParty = UserManager.getPlayer(sender.getName()).getParty(); switch (args.length) { case 1: - unprotectParty(sender, playerParty); + unprotectParty(sender); return true; case 2: if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) { - unprotectParty(sender, playerParty); + unprotectParty(sender); return true; } - protectParty(sender, playerParty, args[1]); + protectParty(sender, args[1]); return true; default: @@ -35,13 +36,13 @@ public class PartyChangePasswordCommand implements CommandExecutor { } } - private void unprotectParty(CommandSender sender, Party playerParty) { + private void unprotectParty(CommandSender sender) { playerParty.setLocked(true); playerParty.setPassword(null); sender.sendMessage(LocaleLoader.getString("Party.Password.Removed")); } - private void protectParty(CommandSender sender, Party playerParty, String password) { + private void protectParty(CommandSender sender, 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 index 48813700a..b0387941d 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -45,8 +45,8 @@ public class PartyCommand implements CommandExecutor { return true; } - player = (Player) sender; - mcMMOPlayer = UserManager.getPlayer(player); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); if (args.length < 1) { if (!mcMMOPlayer.inParty()) { @@ -121,7 +121,6 @@ public class PartyCommand implements CommandExecutor { case OWNER: return partyChangeOwnerCommand.onCommand(sender, command, label, args); case LOCK: - // Fallthrough case UNLOCK: return partyLockCommand.onCommand(sender, command, label, args); case PASSWORD: diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java index febfa694a..a44945c9d 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java @@ -12,26 +12,21 @@ 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]); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + Player player = mcMMOPlayer.getPlayer(); + // 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])); + if (PartyManager.checkPartyExistence(player, newParty, args[1])) { return true; } - player = (Player) sender; - mcMMOPlayer = UserManager.getPlayer(player); - // Changing parties if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java index 472335ddc..c278117bf 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java @@ -16,10 +16,11 @@ public class PartyDisbandCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 1: - Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + Party playerParty = UserManager.getPlayer(sender.getName()).getParty(); + String partyName = playerParty.getName(); for (Player member : playerParty.getOnlineMembers()) { - if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) { + if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) { return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyExpShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyExpShareCommand.java index c181ef643..8641bc8e3 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyExpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyExpShareCommand.java @@ -11,6 +11,7 @@ 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.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; public class PartyExpShareCommand implements CommandExecutor { @@ -25,12 +26,12 @@ public class PartyExpShareCommand implements CommandExecutor { switch (args.length) { case 2: - playerParty = UserManager.getPlayer((Player) sender).getParty(); + playerParty = UserManager.getPlayer(sender.getName()).getParty(); - if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { + if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { handleChangingShareMode(ShareMode.NONE); } - else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) { + else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) { handleChangingShareMode(ShareMode.EQUAL); } else { @@ -48,8 +49,10 @@ public class PartyExpShareCommand implements CommandExecutor { private void handleChangingShareMode(ShareHandler.ShareMode mode) { playerParty.setXpShareMode(mode); + String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); + 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())))); + member.sendMessage(changeModeMessage); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java index 23749be76..a46412d39 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java @@ -26,5 +26,4 @@ public class PartyHelpCommand implements CommandExecutor { return true; } } - } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index 06dea9f2b..ab1e30028 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -21,8 +21,8 @@ public class PartyInfoCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - player = (Player) sender; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); playerParty = mcMMOPlayer.getParty(); displayPartyHeader(); @@ -35,15 +35,19 @@ public class PartyInfoCommand implements CommandExecutor { StringBuilder memberList = new StringBuilder(); for (OfflinePlayer member : playerParty.getMembers()) { - if (playerParty.getLeader().equalsIgnoreCase(member.getName())) { - memberList.append(ChatColor.GOLD).append(member.getName()).append(" "); + String memberName = member.getName(); + + if (playerParty.getLeader().equalsIgnoreCase(memberName)) { + memberList.append(ChatColor.GOLD); } else if (member.isOnline()) { - memberList.append(ChatColor.WHITE).append(member.getName()).append(" "); + memberList.append(ChatColor.WHITE); } else { - memberList.append(ChatColor.GRAY).append(member.getName()).append(" "); + memberList.append(ChatColor.GRAY); } + + memberList.append(memberName).append(" "); } return memberList.toString(); @@ -52,7 +56,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; + boolean itemSharingActive = (playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE); if (!xpShareEnabled && !itemShareEnabled) { return; diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java index fe25cc11c..fed83d088 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -5,40 +5,27 @@ 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.commands.CommandUtils; 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])); + McMMOPlayer mcMMOTarget = UserManager.getPlayer(args[1]); + + if (CommandUtils.checkPlayerExistence(sender, args[1], mcMMOTarget)) { 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(); + Player target = mcMMOTarget.getPlayer(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + Player player = mcMMOPlayer.getPlayer(); if (player.equals(target)) { sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); @@ -50,7 +37,7 @@ public class PartyInviteCommand implements CommandExecutor { return true; } - playerParty = mcMMOPlayer.getParty(); + Party playerParty = mcMMOPlayer.getParty(); if (!PartyManager.canInvite(player, playerParty)) { player.sendMessage(LocaleLoader.getString("Party.Locked")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java index 6a6172968..016a72569 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java @@ -11,6 +11,7 @@ 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.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; public class PartyItemShareCommand implements CommandExecutor { @@ -25,9 +26,9 @@ public class PartyItemShareCommand implements CommandExecutor { switch (args.length) { case 2: - playerParty = UserManager.getPlayer((Player) sender).getParty(); + playerParty = UserManager.getPlayer(sender.getName()).getParty(); - if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { + if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { handleChangingShareMode(ShareMode.NONE); } else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) { @@ -43,15 +44,19 @@ public class PartyItemShareCommand implements CommandExecutor { return true; case 3: - playerParty = UserManager.getPlayer((Player) sender).getParty(); + playerParty = UserManager.getPlayer(sender.getName()).getParty(); boolean toggle = false; - if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("on") || args[2].equalsIgnoreCase("enabled")) { + if (CommandUtils.shouldEnableToggle(args[2])) { toggle = true; } - else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("off") || args[2].equalsIgnoreCase("disabled")) { + else if (CommandUtils.shouldDisableToggle(args[2])) { toggle = false; } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + return true; + } if (args[1].equalsIgnoreCase("loot")) { playerParty.setSharingLootDrops(toggle); @@ -69,7 +74,7 @@ public class PartyItemShareCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); } - notifyToggleItemShareCategory(args, toggle); + notifyToggleItemShareCategory(args[1], toggle); return true; default: @@ -82,20 +87,20 @@ public class PartyItemShareCommand implements CommandExecutor { private void handleChangingShareMode(ShareHandler.ShareMode mode) { playerParty.setItemShareMode(mode); + String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); + 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())))); + member.sendMessage(changeModeMessage); } } - private void notifyToggleItemShareCategory(String[] args, boolean toggle) { - String state = "disabled"; + private void notifyToggleItemShareCategory(String category, boolean toggle) { + String state = toggle ? "enabled" : "disabled"; - if (toggle) { - state = "enabled"; - } + String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(category), state); for (Player member : playerParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(args[1]), state)); + member.sendMessage(toggleMessage); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java index 34db3f510..ef77847de 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java @@ -5,11 +5,11 @@ 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.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; public class PartyJoinCommand implements CommandExecutor { @@ -25,7 +25,6 @@ public class PartyJoinCommand implements CommandExecutor { 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])) { @@ -62,16 +61,10 @@ public class PartyJoinCommand implements CommandExecutor { } 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; + if (CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { + return true; } target = mcMMOTarget.getPlayer(); @@ -81,8 +74,9 @@ public class PartyJoinCommand implements CommandExecutor { return false; } - player = (Player) sender; - mcMMOPlayer = UserManager.getPlayer(player); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); + playerParty = mcMMOPlayer.getParty(); targetParty = mcMMOTarget.getParty(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java index 77b4d9c78..d7a811de1 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java @@ -18,8 +18,7 @@ public class PartyKickCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: - Party playerParty = UserManager.getPlayer((Player) sender).getParty(); - + Party playerParty = UserManager.getPlayer(sender.getName()).getParty(); OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]); if (!playerParty.getMembers().contains(target)) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java index b29c6618f..b25dd9f5a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java @@ -3,11 +3,11 @@ 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.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; public class PartyLockCommand implements CommandExecutor { @@ -15,15 +15,15 @@ public class PartyLockCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - playerParty = UserManager.getPlayer((Player) sender).getParty(); + playerParty = UserManager.getPlayer(sender.getName()).getParty(); switch (args.length) { case 1: if (args[0].equalsIgnoreCase("lock")) { - lockParty(sender, command); + lockParty(sender, command.getPermissionMessage()); } else if (args[0].equalsIgnoreCase("unlock")) { - unlockParty(sender, command); + unlockParty(sender, command.getPermissionMessage()); } return true; @@ -34,11 +34,11 @@ public class PartyLockCommand implements CommandExecutor { return true; } - if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) { - lockParty(sender, command); + if (CommandUtils.shouldEnableToggle(args[1])) { + lockParty(sender, command.getPermissionMessage()); } - else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { - unlockParty(sender, command); + else if (CommandUtils.shouldDisableToggle(args[1])) { + unlockParty(sender, command.getPermissionMessage()); } else { sendUsageStrings(sender); @@ -55,9 +55,9 @@ public class PartyLockCommand implements CommandExecutor { /** * Handle locking a party. */ - private void lockParty(CommandSender sender, Command command) { + private void lockParty(CommandSender sender, String permissionMessage) { if (!Permissions.partySubcommand(sender, PartySubcommandType.LOCK)) { - sender.sendMessage(command.getPermissionMessage()); + sender.sendMessage(permissionMessage); return; } @@ -75,9 +75,9 @@ public class PartyLockCommand implements CommandExecutor { * * @return true if party is successfully unlocked, false otherwise. */ - private void unlockParty(CommandSender sender, Command command) { + private void unlockParty(CommandSender sender, String permissionMessage) { if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) { - sender.sendMessage(command.getPermissionMessage()); + sender.sendMessage(permissionMessage); return; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java index e63d6ff72..962a0ed88 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java @@ -12,15 +12,12 @@ 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(); + Player player = (Player) sender; + Party playerParty = UserManager.getPlayer(player).getParty(); if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { return true; @@ -31,7 +28,7 @@ public class PartyQuitCommand implements CommandExecutor { return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "[quit|q|leave]")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "quit")); 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 index 0b3ade249..85fc21764 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java @@ -6,6 +6,7 @@ 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.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.PartyManager; @@ -14,29 +15,32 @@ 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: + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + Party playerParty = mcMMOPlayer.getParty(); + + String oldPartyName = playerParty.getName(); String newPartyName = args[1]; // This is to prevent party leaders from spamming other players with the rename message - if (playerParty.getName().equalsIgnoreCase(newPartyName)) { + if (oldPartyName.equalsIgnoreCase(newPartyName)) { sender.sendMessage(LocaleLoader.getString("Party.Rename.Same")); return true; } + Player player = mcMMOPlayer.getPlayer(); 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)); + if (PartyManager.checkPartyExistence(player, newParty, newPartyName)) { return true; } + String leaderName = playerParty.getLeader(); + for (Player member : playerParty.getOnlineMembers()) { - if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) { + if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) { return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java deleted file mode 100644 index 3c75473f0..000000000 --- a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java +++ /dev/null @@ -1,218 +0,0 @@ -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.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 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); - - 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(); - long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt(); - - if ((recentlyHurt * Misc.TIME_CONVERSION_FACTOR + 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(); - mcMMOPlayer.removePtpRequest(); - - if (!canTeleport(target.getName())) { - 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.actualizeRecentlyHurt(); - return true; - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java new file mode 100644 index 000000000..d12904388 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java @@ -0,0 +1,34 @@ +package com.gmail.nossr50.commands.party.teleport; + +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.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; + +public class PtpAcceptAnyCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.partyTeleportAcceptAll(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + Player player = mcMMOPlayer.getPlayer(); + + if (mcMMOPlayer.getPtpConfirmRequired()) { + player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled")); + } + + mcMMOPlayer.togglePtpConfirmRequired(); + return true; + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java new file mode 100644 index 000000000..677e49a62 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java @@ -0,0 +1,64 @@ +package com.gmail.nossr50.commands.party.teleport; + +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.config.Config; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; + +public class PtpAcceptCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.partyTeleportAccept(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + Player player = mcMMOPlayer.getPlayer(); + + if (!mcMMOPlayer.hasPtpRequest()) { + player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests")); + return true; + } + + if ((mcMMOPlayer.getPtpTimeout() + Config.getInstance().getPTPCommandTimeout()) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) { + mcMMOPlayer.removePtpRequest(); + player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired")); + return true; + } + + Player target = mcMMOPlayer.getPtpRequest(); + mcMMOPlayer.removePtpRequest(); + + if (!PtpCommand.canTeleport(sender, player, target.getName())) { + 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; + } + } + } + + PtpCommand.handlePartyTeleportEvent(target, player); + return true; + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java new file mode 100644 index 000000000..e3703d8d2 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -0,0 +1,133 @@ +package com.gmail.nossr50.commands.party.teleport; + +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.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.commands.CommandUtils; +import com.gmail.nossr50.util.player.UserManager; + +public class PtpCommand implements CommandExecutor { + private static Player target; + private static McMMOPlayer mcMMOTarget; + + private CommandExecutor ptpToggleCommand = new PtpToggleCommand(); + private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand(); + private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand(); + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (CommandUtils.noConsoleUsage(sender)) { + return true; + } + + switch (args.length) { + case 1: + if (args[0].equalsIgnoreCase("toggle")) { + return ptpToggleCommand.onCommand(sender, command, label, args); + } + + if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { + return ptpAcceptAnyCommand.onCommand(sender, command, label, args); + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + Player player = mcMMOPlayer.getPlayer(); + + int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); + long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); + + if (((recentlyHurt * Misc.TIME_CONVERSION_FACTOR) + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR)) > System.currentTimeMillis()) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown)); + return true; + } + + if (args[0].equalsIgnoreCase("accept")) { + return ptpAcceptCommand.onCommand(sender, command, label, args); + } + + sendTeleportRequest(sender, player, args[0]); + return true; + + default: + return false; + } + } + + private void sendTeleportRequest(CommandSender sender, Player player, String targetName) { + if (!canTeleport(sender, player, targetName)) { + return; + } + + if (!mcMMOTarget.getPtpConfirmRequired()) { + handlePartyTeleportEvent(player, target); + return; + } + + mcMMOTarget.setPtpRequest(player); + mcMMOTarget.actualizePtpTimeout(); + + player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); + + target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); + target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout())); + } + + protected static boolean canTeleport(CommandSender sender, Player player, String targetName) { + mcMMOTarget = UserManager.getPlayer(targetName); + + if (CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { + 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", targetName)); + return false; + } + + if (!target.isValid()) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); + return false; + } + + return true; + } + + protected static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) { + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer); + McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName()); + + mcMMO.p.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + + teleportingPlayer.teleport(targetPlayer); + + teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName())); + targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName())); + + mcMMOPlayer.actualizeRecentlyHurt(); + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java new file mode 100644 index 000000000..81216225a --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java @@ -0,0 +1,34 @@ +package com.gmail.nossr50.commands.party.teleport; + +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.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; + +public class PtpToggleCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.partyTeleportToggle(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + Player player = mcMMOPlayer.getPlayer(); + + if (mcMMOPlayer.getPtpEnabled()) { + player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled")); + } + + mcMMOPlayer.togglePtpUse(); + 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 24f6967ce..452e7254b 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -9,7 +9,6 @@ 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.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; @@ -17,64 +16,49 @@ import com.gmail.nossr50.util.player.UserManager; public class InspectCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - switch (args.length) { 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 + PlayerProfile 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")); + if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) { 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))); + CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION); + CommandUtils.displaySkill(sender, profile, SkillType.FISHING); + CommandUtils.displaySkill(sender, profile, SkillType.HERBALISM); + CommandUtils.displaySkill(sender, profile, SkillType.MINING); + CommandUtils.displaySkill(sender, profile, 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))); + CommandUtils.displaySkill(sender, profile, SkillType.AXES); + CommandUtils.displaySkill(sender, profile, SkillType.ARCHERY); + CommandUtils.displaySkill(sender, profile, SkillType.SWORDS); + CommandUtils.displaySkill(sender, profile, SkillType.TAMING); + CommandUtils.displaySkill(sender, profile, 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))); + CommandUtils.displaySkill(sender, profile, SkillType.ACROBATICS); + CommandUtils.displaySkill(sender, profile, 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")); - return true; - } + if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) { + return true; } - profile = mcMMOPlayer.getProfile(); sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); - CommandUtils.printGatheringSkills(target, profile, sender); - CommandUtils.printCombatSkills(target, profile, sender); - CommandUtils.printMiscSkills(target, profile, sender); + CommandUtils.printGatheringSkills(target, sender); + CommandUtils.printCombatSkills(target, sender); + CommandUtils.printMiscSkills(target, sender); sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); } 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 a7fe0591b..a17639bc6 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -3,7 +3,6 @@ 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.mcMMO; import com.gmail.nossr50.config.Config; @@ -13,8 +12,8 @@ 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.commands.McrankCommandAsyncTask; -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; import com.gmail.nossr50.util.skills.SkillUtils; @@ -23,8 +22,8 @@ public class McrankCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: - if (!(sender instanceof Player)) { - return false; + if (CommandUtils.noConsoleUsage(sender)) { + return true; } if (!Permissions.mcrank(sender)) { @@ -36,7 +35,6 @@ public class McrankCommand implements CommandExecutor { sqlDisplay(sender, sender.getName()); } else { - LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date flatfileDisplay(sender, sender.getName()); } @@ -51,32 +49,18 @@ public class McrankCommand implements CommandExecutor { 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")); + if (CommandUtils.inspectOffline(sender, new PlayerProfile(args[0], false), Permissions.mcrankOffline(sender))) { 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; - } + else if (CommandUtils.tooFar(sender, mcMMOPlayer.getPlayer(), Permissions.mcrankFar(sender))) { + 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]); } @@ -88,13 +72,15 @@ public class McrankCommand implements CommandExecutor { } private void flatfileDisplay(CommandSender sender, String playerName) { + LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName)); for (SkillType skillType : SkillType.values()) { int[] rankInts = LeaderboardManager.getPlayerRank(playerName, skillType); - if ((sender instanceof Player && !Permissions.skillEnabled(sender, skillType)) || skillType.isChildSkill()) { + if (!Permissions.skillEnabled(sender, skillType) || skillType.isChildSkill()) { continue; } 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 fba5c75cf..1b83c69a3 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java @@ -7,7 +7,6 @@ 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; @@ -21,24 +20,23 @@ public class McstatsCommand implements CommandExecutor { switch (args.length) { case 0: - Player player = (Player) sender; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - PlayerProfile profile = mcMMOPlayer.getProfile(); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); + Player player = mcMMOPlayer.getPlayer(); 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); + CommandUtils.printGatheringSkills(player); + CommandUtils.printCombatSkills(player); + CommandUtils.printMiscSkills(player); int powerLevelCap = Config.getInstance().getPowerLevelCap(); if (powerLevelCap != Integer.MAX_VALUE) { - player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", mcMMOPlayer.getPowerLevel(), powerLevelCap)); + player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap)); } else { - player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); + player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); } return true; 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 e86ee2dfc..794a1934f 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -13,13 +13,16 @@ 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; +import com.gmail.nossr50.util.commands.CommandUtils; public class MctopCommand implements CommandExecutor { + private SkillType skill; + @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); @@ -28,42 +31,26 @@ public class MctopCommand implements CommandExecutor { case 1: if (StringUtils.isInt(args[0])) { display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command); - } - else if (SkillUtils.isSkill(args[0])) { - 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")); + return true; } + if (!extractSkill(sender, args[0])) { + return true; + } + + display(1, skill.toString(), sender, useMySQL, command); return true; case 2: - if (!StringUtils.isInt(args[1])) { - return false; + if (CommandUtils.isInvalidInteger(sender, args[1])) { + return true; } - if (SkillUtils.isSkill(args[0])) { - 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")); + if (!extractSkill(sender, args[0])) { + return true; } + display(Integer.parseInt(args[1]), skill.toString(), sender, useMySQL, command); return true; default: @@ -72,7 +59,7 @@ public class MctopCommand implements CommandExecutor { } private void display(int page, String skill, CommandSender sender, boolean sql, Command command) { - if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) { + if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) { sender.sendMessage(command.getPermissionMessage()); return; } @@ -93,8 +80,6 @@ public class MctopCommand implements CommandExecutor { private void flatfileDisplay(int page, String skill, CommandSender sender) { 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")); } @@ -102,21 +87,24 @@ public class MctopCommand implements CommandExecutor { 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); + int position = (page * 10) - 9; - 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++; + for (String playerStat : LeaderboardManager.retrieveInfo(skill, page)) { + if (playerStat == null) { + continue; } + + String digit = String.valueOf(position); + + if (position < 10) { + digit = "0" + digit; + } + + String[] splitStat = playerStat.split(":"); + + // Format: 1. Playername - skill value + sender.sendMessage(digit + ". " + ChatColor.GREEN + splitStat[1] + " - " + ChatColor.WHITE + splitStat[0]); + position++; } sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip")); @@ -125,4 +113,18 @@ public class MctopCommand implements CommandExecutor { private void sqlDisplay(int page, String query, CommandSender sender) { mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender)); } + + private boolean extractSkill(CommandSender sender, String skillName) { + if (CommandUtils.isInvalidSkill(sender, skillName)) { + return false; + } + + skill = SkillType.getSkill(skillName); + + if (CommandUtils.isChildSkill(sender, skill)) { + return true; + } + + return true; + } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index 481651ccb..b0d45abad 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -24,19 +24,25 @@ public class AcrobaticsCommand extends SkillCommand { @Override protected void dataCalculations() { // DODGE - String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance); - dodgeChance = dodgeStrings[0]; - dodgeChanceLucky = dodgeStrings[1]; + if (canDodge) { + 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]; + if (canRoll) { + 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]; + if (canGracefulRoll) { + String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance); + gracefulRollChance = gracefulRollStrings[0]; + gracefulRollChanceLucky = gracefulRollStrings[1]; + } } @Override @@ -76,30 +82,15 @@ public class AcrobaticsCommand extends SkillCommand { @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 })); - } + player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", rollChanceLucky) : "")); } 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 })); - } + player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", gracefulRollChanceLucky) : "")); } 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 })); - } + player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dodgeChanceLucky) : "")); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java index 9901e2708..7b52f713a 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -23,24 +23,24 @@ public class ArcheryCommand extends SkillCommand { @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); + if (canSkillShot) { + double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage; + skillShotBonus = percent.format(Math.min(bonus, Archery.skillShotMaxBonusPercentage)); } // DAZE - String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus); - dazeChance = dazeStrings[0]; - dazeChanceLucky = dazeStrings[1]; + if (canDaze) { + 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]; + if (canRetrieve) { + String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance); + retrieveChance = retrieveStrings[0]; + retrieveChanceLucky = retrieveStrings[1]; + } } @Override @@ -84,21 +84,11 @@ public class ArcheryCommand extends SkillCommand { } 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)); - } + player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky) : "")); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java index 45c341df1..75005c7b7 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -8,9 +8,8 @@ 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 float bonusDamage; + private float impactDamage; private String skullSplitterLength; private String skullSplitterLengthEndurance; @@ -27,25 +26,27 @@ public class AxesCommand extends SkillCommand { @Override protected void dataCalculations() { // IMPACT - impactDamage = String.valueOf(1 + (skillValue / Axes.impactIncreaseLevel)); - greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage); + if (canImpact) { + impactDamage = 1 + (skillValue / Axes.impactIncreaseLevel); + } // SKULL SPLITTER - String[] skullSplitterStrings = calculateLengthDisplayValues(); - skullSplitterLength = skullSplitterStrings[0]; - skullSplitterLengthEndurance = skullSplitterStrings[1]; + if (canSkullSplitter) { + String[] skullSplitterStrings = calculateLengthDisplayValues(); + skullSplitterLength = skullSplitterStrings[0]; + skullSplitterLengthEndurance = skullSplitterStrings[1]; + } // CRITICAL STRIKES - String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance); - critChance = criticalStrikeStrings[0]; - critChanceLucky = criticalStrikeStrings[1]; + if (canCritical) { + 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)); + if (canBonusDamage) { + bonusDamage = Math.min(skillValue / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus); } } @@ -104,25 +105,15 @@ public class AxesCommand extends SkillCommand { } if (canGreaterImpact) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", greaterImpactDamage))); + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", Axes.greaterImpactBonusDamage))); } 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)); - } + player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance) : "")); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index 28f20e0f4..e9cdbad60 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -18,9 +18,11 @@ public class ExcavationCommand extends SkillCommand { @Override protected void dataCalculations() { // GIGA DRILL BREAKER - String gigaDrillStrings[] = calculateLengthDisplayValues(); - gigaDrillBreakerLength = gigaDrillStrings[0]; - gigaDrillBreakerLengthEndurance = gigaDrillStrings[1]; + if (canGigaDrill) { + String gigaDrillStrings[] = calculateLengthDisplayValues(); + gigaDrillBreakerLength = gigaDrillStrings[0]; + gigaDrillBreakerLengthEndurance = gigaDrillStrings[1]; + } } @Override @@ -55,12 +57,7 @@ public class ExcavationCommand extends SkillCommand { @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)); - } + player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance) : "")); } } } 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 0c1f6c1e1..6971b53ce 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -14,7 +14,7 @@ public class FishingCommand extends SkillCommand { private String chanceRaining = ""; private String shakeChance; private String shakeChanceLucky; - private String fishermansDietRank; + private int fishermansDietRank; private boolean canTreasureHunt; private boolean canMagicHunt; @@ -27,27 +27,32 @@ public class FishingCommand extends SkillCommand { @Override protected void dataCalculations() { - lootTier = UserManager.getPlayer(player).getFishingManager().getLootTier(); - // TREASURE HUNTER - double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier(); + if (canTreasureHunt) { + lootTier = mcMMOPlayer.getFishingManager().getLootTier(); + double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier(); - if (player.getWorld().hasStorm()) { - chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining"); - enchantChance = enchantChance * 1.1D; + if (player.getWorld().hasStorm()) { + chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining"); + enchantChance *= 1.1D; + } + + String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance); + magicChance = treasureHunterStrings[0]; + magicChanceLucky = treasureHunterStrings[1]; } - String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance); - magicChance = treasureHunterStrings[0]; - magicChanceLucky = treasureHunterStrings[1]; - // SHAKE - String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability()); - shakeChance = shakeStrings[0]; - shakeChanceLucky = shakeStrings[1]; + if (canShake) { + String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability()); + shakeChance = shakeStrings[0]; + shakeChanceLucky = shakeStrings[1]; + } // FISHERMAN'S DIET - fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1); + if (canFishermansDiet) { + fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1); + } } @Override @@ -96,25 +101,17 @@ public class FishingCommand extends SkillCommand { } 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); - } + player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky) : "")); } if (canShake) { - if (skillValue < AdvancedConfig.getInstance().getShakeUnlockLevel()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", AdvancedConfig.getInstance().getShakeUnlockLevel()))); + int unlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel(); + + if (skillValue < unlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel))); } 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)); - } + player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky) : "")); } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java index 9cee01d2e..94d338a21 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java @@ -12,8 +12,8 @@ public class HerbalismCommand extends SkillCommand { private String greenTerraLengthEndurance; private String greenThumbChance; private String greenThumbChanceLucky; - private String greenThumbStage; - private String farmersDietRank; + private int greenThumbStage; + private int farmersDietRank; private String doubleDropChance; private String doubleDropChanceLucky; private String hylianLuckChance; @@ -23,12 +23,11 @@ public class HerbalismCommand extends SkillCommand { private boolean hasHylianLuck; private boolean canGreenTerra; - private boolean canGreenThumbWheat; + private boolean canGreenThumbPlants; private boolean canGreenThumbBlocks; private boolean canFarmersDiet; private boolean canDoubleDrop; private boolean canShroomThumb; - private boolean doubleDropsDisabled; public HerbalismCommand() { super(SkillType.HERBALISM); @@ -37,51 +36,62 @@ public class HerbalismCommand extends SkillCommand { @Override protected void dataCalculations() { // GREEN TERRA - String[] greenTerraStrings = calculateLengthDisplayValues(); - greenTerraLength = greenTerraStrings[0]; - greenTerraLengthEndurance = greenTerraStrings[1]; + if (canGreenTerra) { + String[] greenTerraStrings = calculateLengthDisplayValues(); + greenTerraLength = greenTerraStrings[0]; + greenTerraLengthEndurance = greenTerraStrings[1]; + } // FARMERS DIET - farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1); + if (canFarmersDiet) { + farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1); + } // GREEN THUMB - greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel); + if (canGreenThumbBlocks || canGreenThumbPlants) { + greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel); - String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance); - greenThumbChance = greenThumbStrings[0]; - greenThumbChanceLucky = greenThumbStrings[1]; + 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]; + if (canDoubleDrop) { + 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]; + if (hasHylianLuck) { + 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]; + if (canShroomThumb) { + 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)); + canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.CROPS) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.NETHER_WARTS) || Permissions.greenThumbPlant(player, Material.COCOA); + 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(); + canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled(); canShroomThumb = Permissions.shroomThumb(player); } @Override protected boolean effectsHeaderPermissions() { - return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb; + return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || canShroomThumb; } @Override @@ -92,7 +102,7 @@ public class HerbalismCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1"))); } - if (canGreenThumbWheat) { + if (canGreenThumbPlants) { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3"))); } @@ -112,37 +122,27 @@ public class HerbalismCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13"))); } - if (canDoubleDrop && !doubleDropsDisabled) { + if (canDoubleDrop) { 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; + return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || 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)); - } + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance) : "")); } - 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 (canGreenThumbBlocks || canGreenThumbPlants) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky) : "")); } - if (canGreenThumbWheat) { + if (canGreenThumbPlants) { player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage)); } @@ -151,30 +151,15 @@ public class HerbalismCommand extends SkillCommand { } 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)); - } + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky) : "")); } - 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)); - } + if (canDoubleDrop) { + player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : "")); } } } 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 096756600..fc58bb9a4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.locale.LocaleLoader; 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; @@ -26,7 +25,6 @@ public class MiningCommand extends SkillCommand { private boolean canBlast; private boolean canBiggerBombs; private boolean canDemoExpert; - private boolean doubleDropsDisabled; public MiningCommand() { super(SkillType.MINING); @@ -35,23 +33,30 @@ public class MiningCommand extends SkillCommand { @Override protected void dataCalculations() { // SUPER BREAKER - String[] superBreakerStrings = calculateLengthDisplayValues(); - superBreakerLength = superBreakerStrings[0]; - superBreakerLengthEndurance = superBreakerStrings[1]; + if (canSuperBreaker) { + String[] superBreakerStrings = calculateLengthDisplayValues(); + superBreakerLength = superBreakerStrings[0]; + superBreakerLengthEndurance = superBreakerStrings[1]; + } // DOUBLE DROPS - String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance); - doubleDropChance = doubleDropStrings[0]; - doubleDropChanceLucky = doubleDropStrings[1]; + if (canDoubleDrop) { + String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance); + doubleDropChance = doubleDropStrings[0]; + doubleDropChanceLucky = doubleDropStrings[1]; + } // BLAST MINING - 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% - debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30% - blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D); - blastRadiusIncrease = miningManager.getBlastRadiusModifier(); + if (canBlast || canDemoExpert || canBiggerBombs) { + MiningManager miningManager = mcMMOPlayer.getMiningManager(); + + 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 @@ -59,14 +64,13 @@ public class MiningCommand extends SkillCommand { canBiggerBombs = Permissions.biggerBombs(player); canBlast = Permissions.remoteDetonation(player); canDemoExpert = Permissions.demolitionsExpertise(player); - canDoubleDrop = Permissions.doubleDrops(player, skill); + canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled(); canSuperBreaker = Permissions.superBreaker(player); - doubleDropsDisabled = skill.getDoubleDropsDisabled(); } @Override protected boolean effectsHeaderPermissions() { - return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker; + return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || canSuperBreaker; } @Override @@ -77,7 +81,7 @@ public class MiningCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1"))); } - if (canDoubleDrop && !doubleDropsDisabled) { + if (canDoubleDrop) { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3"))); } @@ -96,32 +100,24 @@ public class MiningCommand extends SkillCommand { @Override protected boolean statsHeaderPermissions() { - return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker; + return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || 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 (canDoubleDrop) { + player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance) : "")); } if (canBlast) { - if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank1()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", AdvancedConfig.getInstance().getBlastMiningRank1()))); + int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank1(); + + if (skillValue < unlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel))); } else { player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); @@ -129,8 +125,10 @@ public class MiningCommand extends SkillCommand { } if (canBiggerBombs) { - if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank2()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", AdvancedConfig.getInstance().getBlastMiningRank2()))); + int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank2(); + + if (skillValue < unlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel))); } else { player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease)); @@ -138,8 +136,10 @@ public class MiningCommand extends SkillCommand { } if (canDemoExpert) { - if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank4()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", AdvancedConfig.getInstance().getBlastMiningRank4()))); + int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank4(); + + if (skillValue < unlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel))); } else { player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease)); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 6f6f56a45..084c6b391 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -6,12 +6,11 @@ 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.RepairManager; import com.gmail.nossr50.skills.repair.Repairable; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.player.UserManager; public class RepairCommand extends SkillCommand { - private int arcaneForgingRank; private String repairMasteryBonus; private String superRepairChance; private String superRepairChanceLucky; @@ -53,20 +52,16 @@ public class RepairCommand extends SkillCommand { 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); + if (canMasterRepair) { + repairMasteryBonus = percent.format(Math.min(((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * skillValue), Repair.repairMasteryMaxBonus) / 100D); } // SUPER REPAIR - String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance); - superRepairChance = superRepairStrings[0]; - superRepairChanceLucky = superRepairStrings[1]; - - // ARCANE FORGING - arcaneForgingRank = UserManager.getPlayer(player).getRepairManager().getArcaneForgingRank(); + if (canSuperRepair) { + String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance); + superRepairChance = superRepairStrings[0]; + superRepairChanceLucky = superRepairStrings[1]; + } } @Override @@ -143,23 +138,20 @@ public class RepairCommand extends SkillCommand { } 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)); - } + player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky) : "")); } if (canArcaneForge) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank)); + RepairManager repairManager = mcMMOPlayer.getRepairManager(); + + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank())); if (Repair.arcaneForgingEnchantLoss) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : UserManager.getPlayer(player).getRepairManager().getKeepEnchantChance()))); + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance()))); } if (Repair.arcaneForgingDowngrades) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : UserManager.getPlayer(player).getRepairManager().getDowngradeEnchantChance()))); + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance()))); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 2013251b4..8215956a9 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.config.AdvancedConfig; +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; @@ -22,10 +23,12 @@ import com.gmail.nossr50.util.skills.SkillUtils; public abstract class SkillCommand implements CommandExecutor { protected SkillType skill; - private String skillString; + protected String skillName; protected Player player; protected PlayerProfile profile; + protected McMMOPlayer mcMMOPlayer; + protected float skillValue; protected boolean isLucky; protected boolean hasEndurance; @@ -33,9 +36,12 @@ public abstract class SkillCommand implements CommandExecutor { protected DecimalFormat percent = new DecimalFormat("##0.00%"); protected DecimalFormat decimal = new DecimalFormat("##0.00"); + private CommandExecutor skillGuideCommand; + public SkillCommand(SkillType skill) { this.skill = skill; - this.skillString = StringUtils.getCapitalized(skill.toString()); + skillName = SkillUtils.getSkillName(skill); + skillGuideCommand = new SkillGuideCommand(skill); } @Override @@ -44,97 +50,73 @@ public abstract class SkillCommand implements CommandExecutor { return true; } - player = (Player) sender; - profile = UserManager.getPlayer(player).getProfile(); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); - if (profile == null) { - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); - return true; + switch (args.length) { + case 0: + profile = mcMMOPlayer.getProfile(); + + skillValue = profile.getSkillLevel(skill); + isLucky = Permissions.lucky(sender, skill); + hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0); + + permissionsCheck(); + dataCalculations(); + + if (!skill.isChildSkill()) { + player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); + player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); + player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill))); + } + else { + player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child"))); + player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child"))); + player.sendMessage(LocaleLoader.getString("Effects.Child", (int) skillValue)); + + player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents"))); + Set parents = FamilyTree.getParents(skill); + + for (SkillType parent : parents) { + player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent))); + } + } + + 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(); + + player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase())); + return true; + + default: + return skillGuideCommand.onCommand(sender, command, label, args); } - - skillValue = profile.getSkillLevel(skill); - isLucky = Permissions.lucky(sender, skill); - hasEndurance = (Permissions.twelveSecondActivationBoost(sender) || Permissions.eightSecondActivationBoost(sender) || Permissions.fourSecondActivationBoost(sender)); - - dataCalculations(); - permissionsCheck(); - - if (!skill.isChildSkill()) { - player.sendMessage(LocaleLoader.getString("Skills.Header", SkillUtils.getSkillName(skill))); - 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))); - } - else { - player.sendMessage(LocaleLoader.getString("Skills.Header", SkillUtils.getSkillName(skill) + " " + LocaleLoader.getString("Skills.Child"))); - player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child"))); - player.sendMessage(LocaleLoader.getString("Effects.Child", profile.getSkillLevel(skill))); - - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents"))); - Set parents = FamilyTree.getParents(skill); - - for (SkillType parent : parents) { - player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent))); - } - } - - 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 int calculateRank(int maxLevel, int rankChangeLevel) { + return Math.min((int) skillValue, maxLevel) / rankChangeLevel; } protected String[] calculateAbilityDisplayValues(double chance) { - if (isLucky) { - double luckyChance = chance * 1.3333D; + String[] displayValues = new String[2]; - if (luckyChance >= 100D) { - return new String[] { percent.format(chance / 100.0D), percent.format(1.0D) }; - } + displayValues[0] = percent.format(Math.min(chance, 100.0D) / 100.0D); + displayValues[1] = isLucky ? percent.format(Math.min(chance * 1.3333D, 100.0D) / 100.0D) : null; - return new String[] { percent.format(chance / 100.0D), percent.format(luckyChance / 100.0D) }; - } - - return new String[] { percent.format(chance / 100.0D), null }; + return displayValues; } 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 }; + return calculateAbilityDisplayValues((maxChance / Math.min(skillValue, maxBonusLevel)) * skillValue); } protected String[] calculateLengthDisplayValues() { @@ -143,9 +125,7 @@ public abstract class SkillCommand implements CommandExecutor { int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength); if (maxLength != 0) { - if (length > maxLength) { - length = maxLength; - } + length = Math.min(length, maxLength); } return new String[] { String.valueOf(length), String.valueOf(enduranceLength) }; @@ -154,7 +134,7 @@ public abstract class SkillCommand implements CommandExecutor { 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)))); + player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", skillName))); } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java index 445224f72..4205d21d7 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java @@ -2,106 +2,89 @@ package com.gmail.nossr50.commands.skills; import java.util.ArrayList; -import org.bukkit.entity.Player; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; 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 class SkillGuideCommand implements CommandExecutor { + private String header; + private String[] guide; - public static int getTotalPageNumber(String address) { - String[] addressSplit = LocaleLoader.getString(address).split("\n"); + private String invalidPage; - if (addressSplit.length <= 8) { - return 1; - } + public SkillGuideCommand(SkillType skillType) { + header = LocaleLoader.getString("Guides.Header", SkillUtils.getSkillName(skillType)); + guide = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString())).split("\n"); - return (addressSplit.length / 8) + 1; + invalidPage = LocaleLoader.getString("Guides.Page.Invalid"); } - 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; - + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { 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); - } - + sendGuide(sender, 1); return true; case 2: - int totalPages = SkillGuideCommand.getTotalPageNumber(address); + int totalPages = getTotalPageNumber(); if (!StringUtils.isInt(args[1])) { - player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid")); + sender.sendMessage(invalidPage); return true; } - if (Integer.parseInt(args[1]) > totalPages) { - player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages)); + int pageNumber = Integer.parseInt(args[1]); + + if (pageNumber > totalPages || pageNumber <= 0) { + sender.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); - } - + sendGuide(sender, pageNumber); return true; default: return false; } } + + private int getTotalPageNumber() { + return (int) Math.ceil(guide.length / 8.0); + } + + private void sendGuide(CommandSender sender, int pageNumber) { + for (String target : grabPageContents(pageNumber)) { + sender.sendMessage(target); + } + } + + private ArrayList grabPageContents(int pagenum) { + int pageIndexStart = 8 * (pagenum - 1); // Determine what string to start at + ArrayList allStrings = new ArrayList(); + + allStrings.add(header); + + // Add targeted strings + while (allStrings.size() < 9) { + if (pageIndexStart + allStrings.size() > guide.length) { + allStrings.add(""); + } + else { + allStrings.add(guide[pageIndexStart + (allStrings.size() - 1)]); + } + } + + allStrings.add("Page " + pagenum + " of " + getTotalPageNumber()); + return allStrings; + } } 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 c87298471..6bd40df2b 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; 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; @@ -14,8 +13,6 @@ public class SmeltingCommand extends SkillCommand { private String fluxMiningChance; private String fluxMiningChanceLucky; - private int vanillaXPModifier; - private boolean canFuelEfficiency; private boolean canSecondSmelt; private boolean canFluxMine; @@ -28,20 +25,23 @@ public class SmeltingCommand extends SkillCommand { @Override protected void dataCalculations() { // FUEL EFFICIENCY - burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier)); + if (canFuelEfficiency) { + burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier)); + } // SECOND SMELT - String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance); - secondSmeltChance = secondSmeltStrings[0]; - secondSmeltChanceLucky = secondSmeltStrings[1]; + if (canSecondSmelt) { + 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 = UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier(); + if (canFluxMine) { + String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance); + fluxMiningChance = fluxMiningStrings[0]; + fluxMiningChanceLucky = fluxMiningStrings[1]; + } } @Override @@ -90,20 +90,17 @@ public class SmeltingCommand extends SkillCommand { } 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)); - } + player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky) : "")); } if (canVanillaXPBoost) { - if (skillValue < AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()))); + int unlockLevel = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level(); + + if (skillValue < unlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel))); } else { - player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", vanillaXPModifier)); + player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", mcMMOPlayer.getSmeltingManager().getVanillaXpMultiplier())); } } @@ -111,11 +108,8 @@ public class SmeltingCommand extends SkillCommand { 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)); + player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky) : "")); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java index 3c16e2c7f..b2dc0a4a7 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -8,7 +8,7 @@ import com.gmail.nossr50.util.Permissions; public class SwordsCommand extends SkillCommand { private String counterAttackChance; private String counterAttackChanceLucky; - private String bleedLength; + private int bleedLength; private String bleedChance; private String bleedChanceLucky; private String serratedStrikesLength; @@ -25,26 +25,27 @@ public class SwordsCommand extends SkillCommand { @Override protected void dataCalculations() { // SERRATED STRIKES - String[] serratedStrikesStrings = calculateLengthDisplayValues(); - serratedStrikesLength = serratedStrikesStrings[0]; - serratedStrikesLengthEndurance = serratedStrikesStrings[1]; + if (canSerratedStrike) { + 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); - } + if (canBleed) { + bleedLength = (skillValue >= Swords.bleedMaxBonusLevel) ? Swords.bleedMaxTicks : Swords.bleedBaseTicks; - String[] bleedStrings = calculateAbilityDisplayValues(Swords.bleedMaxBonusLevel, Swords.bleedMaxChance); - bleedChance = bleedStrings[0]; - bleedChanceLucky = bleedStrings[1]; + 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]; + if (canCounter) { + String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance); + counterAttackChance = counterAttackStrings[0]; + counterAttackChanceLucky = counterAttackStrings[1]; + } } @Override @@ -85,33 +86,17 @@ public class SwordsCommand extends SkillCommand { @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)); - } + player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance) : "")); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java index 98d44e9d3..ffd22f509 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java @@ -26,9 +26,11 @@ public class TamingCommand extends SkillCommand { @Override protected void dataCalculations() { - String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance); - goreChance = goreStrings[0]; - goreChanceLucky = goreStrings[1]; + if (canGore) { + String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance); + goreChance = goreStrings[0]; + goreChanceLucky = goreStrings[1]; + } } @Override @@ -154,12 +156,7 @@ public class TamingCommand extends SkillCommand { } 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)); - } + player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky) : "")); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java index 5c866dd2e..c0ec2e441 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -14,7 +14,7 @@ public class UnarmedCommand extends SkillCommand { private String disarmChanceLucky; private String ironGripChance; private String ironGripChanceLucky; - private String ironArmBonus; + private int ironArmBonus; private boolean canBerserk; private boolean canDisarm; @@ -29,32 +29,37 @@ public class UnarmedCommand extends SkillCommand { @Override protected void dataCalculations() { // BERSERK - String[] berserkStrings = calculateLengthDisplayValues(); - berserkLength = berserkStrings[0]; - berserkLengthEndurance = berserkStrings[1]; + if (canBerserk) { + String[] berserkStrings = calculateLengthDisplayValues(); + berserkLength = berserkStrings[0]; + berserkLengthEndurance = berserkStrings[1]; + } // DISARM - String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance); - disarmChance = disarmStrings[0]; - disarmChanceLucky = disarmStrings[1]; + if (canDisarm) { + 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]; + if (canDeflect) { + 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)); + if (canBonusDamage) { + ironArmBonus = Math.min(3 + ((int) skillValue / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage); } // IRON GRIP - String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance); - ironGripChance = ironGripStrings[0]; - ironGripChanceLucky = ironGripStrings[1]; + if (canIronGrip) { + String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance); + ironGripChance = ironGripStrings[0]; + ironGripChanceLucky = ironGripStrings[1]; + } } @Override @@ -108,39 +113,19 @@ public class UnarmedCommand extends SkillCommand { } 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)); - } + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance) : "")); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java index d173baf61..ec34765ad 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -15,7 +15,6 @@ public class WoodcuttingCommand extends SkillCommand { private boolean canTreeFell; private boolean canLeafBlow; private boolean canDoubleDrop; - private boolean doubleDropsDisabled; public WoodcuttingCommand() { super(SkillType.WOODCUTTING); @@ -24,27 +23,30 @@ public class WoodcuttingCommand extends SkillCommand { @Override protected void dataCalculations() { // TREE FELLER - String[] treeFellerStrings = calculateLengthDisplayValues(); - treeFellerLength = treeFellerStrings[0]; - treeFellerLengthEndurance = treeFellerStrings[1]; + if (canTreeFell) { + String[] treeFellerStrings = calculateLengthDisplayValues(); + treeFellerLength = treeFellerStrings[0]; + treeFellerLengthEndurance = treeFellerStrings[1]; + } // DOUBLE DROPS - String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance); - doubleDropChance = doubleDropStrings[0]; - doubleDropChanceLucky = doubleDropStrings[1]; + if (canDoubleDrop) { + 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); + canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled(); canLeafBlow = Permissions.leafBlower(player); - doubleDropsDisabled = skill.getDoubleDropsDisabled(); } @Override protected boolean effectsHeaderPermissions() { - return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell; + return canDoubleDrop || canLeafBlow || canTreeFell; } @Override @@ -59,14 +61,14 @@ public class WoodcuttingCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3"))); } - if (canDoubleDrop && !doubleDropsDisabled) { + if (canDoubleDrop) { 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; + return canDoubleDrop || canLeafBlow || canTreeFell; } @Override @@ -82,22 +84,12 @@ public class WoodcuttingCommand extends SkillCommand { } } - 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 (canDoubleDrop) { + player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : "")); } 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)); - } + player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance) : "")); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/spout/SpoutCommand.java b/src/main/java/com/gmail/nossr50/commands/spout/SpoutCommand.java index 5fd56b7c2..5e7f8a907 100644 --- a/src/main/java/com/gmail/nossr50/commands/spout/SpoutCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/SpoutCommand.java @@ -3,7 +3,6 @@ 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; @@ -28,7 +27,7 @@ public abstract class SpoutCommand implements CommandExecutor { return true; } - playerProfile = UserManager.getPlayer((Player) sender).getProfile(); + playerProfile = UserManager.getPlayer(sender.getName()).getProfile(); spoutHud = playerProfile.getSpoutHud(); if (spoutHud == null) { 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 a6317d0ca..3daf03598 100644 --- a/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java @@ -6,6 +6,7 @@ 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.commands.CommandUtils; import com.gmail.nossr50.util.skills.SkillUtils; public class XplockCommand extends SpoutCommand { @@ -22,25 +23,23 @@ public class XplockCommand extends SpoutCommand { @Override protected boolean oneArgument(Command command, CommandSender sender, String[] args) { - if (args[0].equalsIgnoreCase("on")) { + if (CommandUtils.shouldEnableToggle(args[0])) { lockXpBar(sender, spoutHud.getLastGained()); return true; } - if (args[0].equalsIgnoreCase("off")) { + if (CommandUtils.shouldDisableToggle(args[0])) { unlockXpBar(sender); return true; } - if (!SkillUtils.isSkill(args[0])) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + if (CommandUtils.isInvalidSkill(sender, args[0])) { return true; } SkillType skill = SkillType.getSkill(args[0]); - if (skill.isChildSkill()) { - sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this + if (CommandUtils.isChildSkill(sender, skill)) { return true; } diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 138599fe5..be90bc083 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -10,17 +10,13 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; 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; +import com.gmail.nossr50.util.Misc; public final class DatabaseManager { private static String connectionString; @@ -502,7 +498,7 @@ public final class DatabaseManager { continue; } - profileCleanup(playerName); + Misc.profileCleanup(playerName); purgedUsers++; } @@ -524,36 +520,13 @@ public final class DatabaseManager { continue; } - profileCleanup(playerName); + Misc.profileCleanup(playerName); purgedUsers++; } mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database."); } - public static void profileCleanup(String playerName) { - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); - - if (mcMMOPlayer != null) { - Player player = mcMMOPlayer.getPlayer(); - McMMOHud spoutHud = mcMMOPlayer.getProfile().getSpoutHud(); - - if (spoutHud != null) { - spoutHud.removeWidgets(); - } - - UserManager.remove(playerName); - - if (player.isOnline()) { - UserManager.addUser(player); - - if (mcMMO.spoutEnabled) { - SpoutUtils.reloadSpoutPlayer(player); - } - } - } - } - /** * Check database structure for missing values. * 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 ae0b921fd..ad887efde 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -449,6 +449,10 @@ public class McMMOPlayer { * @param xp Experience amount to add */ public void applyXpGain(SkillType skillType, int xp) { + if (skillType.isChildSkill()) { + return; + } + McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp); mcMMO.p.getServer().getPluginManager().callEvent(event); 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 e8f4c14cd..f227e2de3 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -611,6 +611,10 @@ public class PlayerProfile { } public void setSkillXpLevel(SkillType skillType, int newValue) { + if (skillType.isChildSkill()) { + return; + } + skillsXp.put(skillType, newValue); } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 9770f71ed..cbe174eb9 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -24,6 +24,15 @@ public final class PartyManager { private PartyManager() {} + public static boolean checkPartyExistence(Player player, Party party, String partyName) { + if (party == null) { + return false; + } + + player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", partyName)); + return true; + } + public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, Player player, Party oldParty, String newPartyName) { if (mcMMOPlayer.inParty()) { if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) { diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index e2c71f8d7..43c8a4bca 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -6,11 +6,16 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; +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.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; +import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.spout.SpoutUtils; public final class Misc { private static Random random = new Random(); @@ -161,6 +166,29 @@ public final class Misc { newItem.setItemStack(cloned); } + public static void profileCleanup(String playerName) { + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); + + if (mcMMOPlayer != null) { + Player player = mcMMOPlayer.getPlayer(); + McMMOHud spoutHud = mcMMOPlayer.getProfile().getSpoutHud(); + + if (spoutHud != null) { + spoutHud.removeWidgets(); + } + + UserManager.remove(playerName); + + if (player.isOnline()) { + UserManager.addUser(player); + + if (mcMMO.spoutEnabled) { + SpoutUtils.reloadSpoutPlayer(player); + } + } + } + } + public static Random getRandom() { return random; } 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 324f3d179..6b72df770 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -24,7 +24,7 @@ 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.party.teleport.PtpCommand; import com.gmail.nossr50.commands.player.InspectCommand; import com.gmail.nossr50.commands.player.McrankCommand; import com.gmail.nossr50.commands.player.McstatsCommand; @@ -58,7 +58,7 @@ public final class CommandRegistrationManager { public static void registerSkillCommands() { for (SkillType skill : SkillType.values()) { String commandName = skill.toString().toLowerCase(); - String localizedName = SkillUtils.getSkillName(skill); + String localizedName = SkillUtils.getSkillName(skill).toLowerCase(); PluginCommand command; diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index e4f06887a..901ec1912 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -3,120 +3,200 @@ package com.gmail.nossr50.util.commands; 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.Misc; 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 final class CommandUtils { private CommandUtils() {} - public static boolean noConsoleUsage(CommandSender sender) { - if (!(sender instanceof Player)) { - sender.sendMessage(LocaleLoader.getString("Commands.NoConsole")); + public static boolean isChildSkill(CommandSender sender, SkillType skill) { + if (!skill.isChildSkill()) { + return false; + } + + sender.sendMessage("Child skills are not supported by this command."); // TODO: Localize this + return true; + } + + public static boolean inspectOffline(CommandSender sender, PlayerProfile profile, boolean hasPermission) { + if (unloadedProfile(sender, profile)) { + return true; + } + + if (!hasPermission) { + sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); return true; } return false; } + public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) { + if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !hasPermission) { + sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); + return true; + } + + return false; + } + + public static boolean noConsoleUsage(CommandSender sender) { + if (sender instanceof Player) { + return false; + } + + sender.sendMessage(LocaleLoader.getString("Commands.NoConsole")); + return true; + } + + public static boolean isOffline(CommandSender sender, Player player) { + if (player.isOnline()) { + return false; + } + + sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + return true; + } + + public static boolean checkPlayerExistence(CommandSender sender, String playerName, McMMOPlayer mcMMOPlayer) { + if (mcMMOPlayer != null) { + return false; + } + + PlayerProfile playerProfile = new PlayerProfile(playerName, false); + + if (unloadedProfile(sender, playerProfile)) { + return true; + } + + sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + return true; + } + + public static boolean unloadedProfile(CommandSender sender, PlayerProfile profile) { + if (profile.isLoaded()) { + return false; + } + + sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + return true; + } + + public static boolean isInvalidInteger(CommandSender sender, String value) { + if (StringUtils.isInt(value)) { + return false; + } + + sender.sendMessage("That is not a valid integer."); // TODO: Localize + return true; + } + + public static boolean isInvalidDouble(CommandSender sender, String value) { + if (StringUtils.isDouble(value)) { + return false; + } + + sender.sendMessage("That is not a valid percentage."); // TODO: Localize + return true; + } + + public static boolean isInvalidSkill(CommandSender sender, String skillName) { + if (SkillUtils.isSkill(skillName)) { + return false; + } + + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + return true; + } + + public static boolean shouldEnableToggle(String arg) { + return arg.equalsIgnoreCase("on") || arg.equalsIgnoreCase("true") || arg.equalsIgnoreCase("enabled"); + } + + public static boolean shouldDisableToggle(String arg) { + return arg.equalsIgnoreCase("off") || arg.equalsIgnoreCase("false") || arg.equalsIgnoreCase("disabled"); + } + /** * 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) { + public static void printGatheringSkills(Player inspect, CommandSender display) { if (SkillUtils.hasGatheringSkills(inspect)) { + PlayerProfile profile = UserManager.getPlayer(inspect).getProfile(); + 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))); - } + displaySkill(inspect, profile, SkillType.EXCAVATION, display); + displaySkill(inspect, profile, SkillType.FISHING, display); + displaySkill(inspect, profile, SkillType.HERBALISM, display); + displaySkill(inspect, profile, SkillType.MINING, display); + displaySkill(inspect, profile, SkillType.WOODCUTTING, display); } } - public static void printGatheringSkills(Player player, PlayerProfile profile) { - printGatheringSkills(player, profile, player); + public static void printGatheringSkills(Player player) { + printGatheringSkills(player, 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) { + public static void printCombatSkills(Player inspect, CommandSender display) { if (SkillUtils.hasCombatSkills(inspect)) { + PlayerProfile profile = UserManager.getPlayer(inspect).getProfile(); + 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))); - } + displaySkill(inspect, profile, SkillType.AXES, display); + displaySkill(inspect, profile, SkillType.ARCHERY, display); + displaySkill(inspect, profile, SkillType.SWORDS, display); + displaySkill(inspect, profile, SkillType.TAMING, display); + displaySkill(inspect, profile, SkillType.UNARMED, display); } } - public static void printCombatSkills(Player player, PlayerProfile profile) { - printCombatSkills(player, profile, player); + public static void printCombatSkills(Player player) { + printCombatSkills(player, 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) { + public static void printMiscSkills(Player inspect, CommandSender display) { if (SkillUtils.hasMiscSkills(inspect)) { + PlayerProfile profile = UserManager.getPlayer(inspect).getProfile(); + 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))); - } + displaySkill(inspect, profile, SkillType.ACROBATICS, display); + displaySkill(inspect, profile, SkillType.REPAIR, display); } } - public static void printMiscSkills(Player player, PlayerProfile profile) { - printMiscSkills(player, profile, player); + public static void printMiscSkills(Player player) { + printMiscSkills(player, player); + } + + private static void displaySkill(Player player, PlayerProfile profile, SkillType skill, CommandSender display) { + if (Permissions.skillEnabled(player, skill)) { + displaySkill(display, profile, skill); + } + } + + public static void displaySkill(CommandSender sender, PlayerProfile profile, SkillType skill) { + sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener"), profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill))); } } diff --git a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java index dadbacbcf..22d3ad6e8 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java @@ -36,8 +36,8 @@ public final class PerksUtils { ticks += 4; } - if (maxTicks != 0 && ticks > maxTicks) { - ticks = maxTicks; + if (maxTicks != 0) { + ticks = Math.min(ticks, maxTicks); } return ticks; From c14f3777c07be591c2fcd65772a8365a772d0211 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 16 Mar 2013 11:42:38 +0100 Subject: [PATCH 69/94] Fixed bug where trying to activate a Chimaera Wing would require one item too much --- 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 744fa7b5a..670a6939a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,7 @@ Key: - Removal Version 1.4.04-dev + = Fixed bug where trying to activate a Chimaera Wing would require one item too much Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 0557c8865..5a8dd1c4f 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -51,7 +51,7 @@ public final class ChimaeraWing { return; } - if (amount <= Config.getInstance().getChimaeraUseCost()) { + if (amount < Config.getInstance().getChimaeraUseCost()) { player.sendMessage(LocaleLoader.getString("Skills.NeedMore", "Chimaera Wings")); //TODO Locale! return; } From 3f56c8e690cf135a1ccc93511f780fe2c29d7092 Mon Sep 17 00:00:00 2001 From: bm01 Date: Sat, 16 Mar 2013 16:48:55 +0100 Subject: [PATCH 70/94] Fixed Treefeller trying to cut too many leaves --- Changelog.txt | 1 + .../com/gmail/nossr50/skills/woodcutting/Woodcutting.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 670a6939a..981a47eca 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -33,6 +33,7 @@ Version 1.4.03 = Fixed bug where Beast Lore wouldn't work on friendly pets = Fixed bug where Deflect was calculated based on the attacker, not the defender. (We really did this time!) = Fixed bug where Treefeller would not deal durability damage when the axe "splinters into dozens of pieces" + = Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't ! Moved the Salvage unlock level from config.yml to advanced.yml ! Changed how Chimaera Wings are acquired, you need to craft them now. (By default, use 5 feathers in a shapeless recipe) ! Changed how Chimaera Wings teleport players to the spawnpoint, will now check if the location is safe 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 b4e5c7c17..5709e5055 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -259,6 +259,9 @@ public final class Woodcutting { return; } - futureCenterBlocks.add(blockState); + // Without this check Tree Feller propagates through leaves until the threshold is hit + if (BlockUtils.isLog(blockState)) { + futureCenterBlocks.add(blockState); + } } } From 0ae5421d109620522e6c7404c2eb91c520f334fa Mon Sep 17 00:00:00 2001 From: bm01 Date: Sat, 16 Mar 2013 16:59:01 +0100 Subject: [PATCH 71/94] So apparently we're no longer on 1.4.03 --- Changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 981a47eca..f4671a197 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ Key: Version 1.4.04-dev = Fixed bug where trying to activate a Chimaera Wing would require one item too much + = Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker @@ -33,7 +34,6 @@ Version 1.4.03 = Fixed bug where Beast Lore wouldn't work on friendly pets = Fixed bug where Deflect was calculated based on the attacker, not the defender. (We really did this time!) = Fixed bug where Treefeller would not deal durability damage when the axe "splinters into dozens of pieces" - = Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't ! Moved the Salvage unlock level from config.yml to advanced.yml ! Changed how Chimaera Wings are acquired, you need to craft them now. (By default, use 5 feathers in a shapeless recipe) ! Changed how Chimaera Wings teleport players to the spawnpoint, will now check if the location is safe From 3ac5ac385d19ec23fc20188d7567369b339c1aec Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 16 Mar 2013 15:55:53 -0400 Subject: [PATCH 72/94] Fix issue with double drop display values. --- .../java/com/gmail/nossr50/commands/skills/SkillCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 8215956a9..c3661163b 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -116,7 +116,7 @@ public abstract class SkillCommand implements CommandExecutor { } protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) { - return calculateAbilityDisplayValues((maxChance / Math.min(skillValue, maxBonusLevel)) * skillValue); + return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel)); } protected String[] calculateLengthDisplayValues() { From 4cd4223ee00cc4fd14a22b38530a2c8fb9ec70f6 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 16 Mar 2013 16:13:55 -0400 Subject: [PATCH 73/94] Fixed /skillreset being broken. --- .../commands/experience/SkillresetCommand.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java index ac474e4df..f3a3a5cfb 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java @@ -14,9 +14,14 @@ import com.gmail.nossr50.util.skills.SkillUtils; public class SkillresetCommand extends ExperienceCommand { private CommandSender sender; private Command command; + private int argsLength; @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + this.command = command; + this.sender = sender; + argsLength = args.length; + switch (args.length) { case 1: if (CommandUtils.noConsoleUsage(sender)) { @@ -36,9 +41,6 @@ public class SkillresetCommand extends ExperienceCommand { player = mcMMOPlayer.getPlayer(); profile = mcMMOPlayer.getProfile(); - this.command = command; - this.sender = sender; - editValues(); return true; @@ -62,14 +64,13 @@ public class SkillresetCommand extends ExperienceCommand { return true; } - this.command = command; - this.sender = sender; - editValues(); profile.save(); // Since this is a temporary profile, we save it here. } else { profile = mcMMOPlayer.getProfile(); + player = mcMMOPlayer.getPlayer(); + editValues(); } @@ -95,7 +96,7 @@ public class SkillresetCommand extends ExperienceCommand { @Override protected void handleCommand(SkillType skill) { - if ((player.equals(sender) && !Permissions.skillreset(sender, skill)) || (!player.equals(sender) && !Permissions.skillresetOthers(sender, skill))) { + if (argsLength == 1 && !Permissions.skillreset(sender, skill) || (argsLength == 2 && !Permissions.skillresetOthers(sender, skill))) { sender.sendMessage(command.getPermissionMessage()); return; } From dafa690a0984303f412672a719a0aa038f02827d Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 16 Mar 2013 16:14:37 -0400 Subject: [PATCH 74/94] Make /mcnotify match the process of the other commands for getting the mcMMOPlayer object. --- src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java index 11a664cb4..51fe1447b 100644 --- a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java @@ -3,7 +3,6 @@ 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.locale.LocaleLoader; @@ -14,7 +13,7 @@ public class McnotifyCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: - McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); if (mcMMOPlayer.useChatNotifications()) { sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off")); From 171026ba23d943366edc15f24d754f6d149f9b01 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 00:36:40 -0400 Subject: [PATCH 75/94] Fixed bug where Mining wasn't awarding double drops --- Changelog.txt | 3 ++- .../java/com/gmail/nossr50/skills/mining/MiningManager.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index f4671a197..6ad2e1e65 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,7 +9,8 @@ Key: Version 1.4.04-dev = Fixed bug where trying to activate a Chimaera Wing would require one item too much - = Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't + = Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't + = Fixed bug where Mining wasn't awarding double drops Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker 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 b56ac5929..6e8151259 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -58,7 +58,7 @@ public class MiningManager extends SkillManager{ applyXpGain(Mining.getBlockXp(blockState)); - if (Permissions.doubleDrops(player, skill)) { + if (!Permissions.doubleDrops(player, skill)) { return; } From ed09d1b390c259a8cf9ac8402b8e34aa01941302 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 08:11:20 -0400 Subject: [PATCH 76/94] Fixed bug where Shake wouldn't damage mobs whose max health was less than 4. Fixes #845 --- Changelog.txt | 1 + .../java/com/gmail/nossr50/skills/fishing/FishingManager.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 6ad2e1e65..79d967346 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -11,6 +11,7 @@ Version 1.4.04-dev = Fixed bug where trying to activate a Chimaera Wing would require one item too much = Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't = Fixed bug where Mining wasn't awarding double drops + = Fixed bug where Shake wouldn't damage mobs whose max health was less than 4 Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker 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 3e3f6af53..2e299f089 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -189,7 +189,7 @@ public class FishingManager extends SkillManager { } Misc.dropItem(target.getLocation(), drop); - CombatUtils.dealDamage(target, target.getMaxHealth() / 4); // Make it so you can shake a mob no more than 4 times. + CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times. } } From b2cdf21de58b5ecbfb1e573feb33017ea3465db3 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 09:02:15 -0400 Subject: [PATCH 77/94] Fixed bug where the API would fail if the name of a player's current party is requested when the player isn't in one (Thanks @dualspiral!) Closes #843 --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/api/PartyAPI.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 79d967346..7fd92c861 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,6 +12,7 @@ Version 1.4.04-dev = Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't = Fixed bug where Mining wasn't awarding double drops = Fixed bug where Shake wouldn't damage mobs whose max health was less than 4 + = Fixed bug where the API would fail if the name of a player's current party is requested when the player isn't in one (Thanks @dualspiral!) Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index e0c83c36e..300972690 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -19,9 +19,13 @@ public final class PartyAPI { * 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 + * @return the name of the player's party, or null if not in a party */ public static String getPartyName(Player player) { + if (!inParty(player)) { + return null; + } + return UserManager.getPlayer(player).getParty().getName(); } From c2fea660e7a25634fec91a329102da2411e3ee25 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 10:34:46 -0400 Subject: [PATCH 78/94] Added functions to ExperienceAPI for use with offline players. Fixes #836 --- Changelog.txt | 1 + .../com/gmail/nossr50/api/ExperienceAPI.java | 243 ++++++++++++++++++ .../nossr50/api/InvalidPlayerException.java | 9 + .../nossr50/datatypes/player/McMMOPlayer.java | 9 + 4 files changed, 262 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/api/InvalidPlayerException.java diff --git a/Changelog.txt b/Changelog.txt index 7fd92c861..ce42d8b4a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,7 @@ Key: - Removal Version 1.4.04-dev + + Added functions to ExperienceAPI for use with offline players = Fixed bug where trying to activate a Chimaera Wing would require one item too much = Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't = Fixed bug where Mining wasn't awarding double drops diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index f535308f2..66a72771c 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -1,9 +1,13 @@ package com.gmail.nossr50.api; +import java.util.Set; + import org.bukkit.entity.Player; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; @@ -38,6 +42,21 @@ public final class ExperienceAPI { UserManager.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), XP); } + /** + * Adds raw XP to an offline player. + *
+ * This function is designed for API usage. + * + * @param playerName The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static void addRawXPOffline(String playerName, String skillType, int XP) { + addOfflineXP(playerName, skillType, XP); + } + /** * Adds XP to the player, calculates for XP Rate only. *
@@ -66,6 +85,51 @@ public final class ExperienceAPI { UserManager.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier())); } + /** + * Adds XP to an offline player, calculates for XP Rate only. + *
+ * This function is designed for API usage. + * + * @param playerName The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static void addMultipliedXPOffline(String playerName, String skillType, int XP) { + addOfflineXP(playerName, skillType, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier())); + } + + /** + * Adds XP to the player, calculates for XP Rate and skill modifier. + *
+ * 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 addModifiedXP(Player player, String skillType, int XP) { + SkillType skill = SkillType.getSkill(skillType); + + UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier())); + } + + /** + * Adds XP to an offline player, calculates for XP Rate and skill modifier. + *
+ * This function is designed for API usage. + * + * @param playerName The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static void addModifiedXPOffline(String playerName, String skillType, int XP) { + addOfflineXP(playerName, skillType, (int) (XP / SkillType.getSkill(skillType).getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier())); + } + /** * Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party. *
@@ -122,6 +186,20 @@ public final class ExperienceAPI { return UserManager.getPlayer(player).getProfile().getSkillXpLevel(SkillType.getSkill(skillType)); } + /** + * Get the amount of XP an offline player has in a specific skill. + *
+ * This function is designed for API usage. + * + * @param playerName The player to get XP for + * @param skillType The skill to get XP for + * @return the amount of XP in a given skill + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static int getOfflineXP(String playerName, String skillType) { + return getOfflineProfile(playerName).getSkillXpLevel(SkillType.getSkill(skillType)); + } + /** * Get the amount of XP left before leveling up. *
@@ -150,6 +228,20 @@ public final class ExperienceAPI { return UserManager.getPlayer(player).getProfile().getXpToLevel(SkillType.getSkill(skillType)); } + /** + * Get the amount of XP an offline player has left before leveling up. + *
+ * This function is designed for API usage. + * + * @param playerName The player to get XP for + * @param skillType The skill to get XP for + * @return the amount of XP in a given skill + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static int getOfflineXPToNextLevel(String playerName, String skillType) { + return getOfflineProfile(playerName).getXpToLevel(SkillType.getSkill(skillType)); + } + /** * Add levels to a skill. *
@@ -197,6 +289,37 @@ public final class ExperienceAPI { UserManager.getPlayer(player).getProfile().addLevels(SkillType.getSkill(skillType), levels); } + /** + * Add levels to a skill for an offline player. + *
+ * This function is designed for API usage. + * + * @param playerName The player to add levels to + * @param skillType Type of skill to add levels to + * @param levels Number of levels to add + * + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static void addLevelOffline(String playerName, String skillType, int levels) { + PlayerProfile profile = getOfflineProfile(playerName); + + SkillType skill = SkillType.getSkill(skillType); + + if (skill.isChildSkill()) { + Set parentSkills = FamilyTree.getParents(skill); + + for (SkillType parentSkill : parentSkills) { + profile.addLevels(parentSkill, (levels / parentSkills.size())); + } + + profile.save(); + return; + } + + profile.addLevels(skill, levels); + profile.save(); + } + /** * Get the level a player has in a specific skill. *
@@ -225,6 +348,20 @@ public final class ExperienceAPI { return UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.getSkill(skillType)); } + /** + * Get the level an offline player has in a specific skill. + *
+ * This function is designed for API usage. + * + * @param playerName The player to get the level for + * @param skillType The skill to get the level for + * @return the level of a given skill + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static int getLevelOffline(String playerName, String skillType) { + return getOfflineProfile(playerName).getSkillLevel(SkillType.getSkill(skillType)); + } + /** * Gets the power level of a player. *
@@ -237,6 +374,30 @@ public final class ExperienceAPI { return UserManager.getPlayer(player).getPowerLevel(); } + /** + * Gets the power level of an offline player. + *
+ * This function is designed for API usage. + * + * @param playerName The player to get the power level for + * @return the power level of the player + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static int getPowerLevelOffline(String playerName) { + int powerLevel = 0; + PlayerProfile profile = getOfflineProfile(playerName); + + for (SkillType type : SkillType.values()) { + if (type.isChildSkill()) { + continue; + } + + powerLevel += profile.getSkillLevel(type); + } + + return powerLevel; + } + /** * Get the level cap of a specific skill. *
@@ -288,6 +449,21 @@ public final class ExperienceAPI { UserManager.getPlayer(player).getProfile().modifySkill(SkillType.getSkill(skillType), skillLevel); } + /** + * Sets the level of an offline player in a specific skill type. + *
+ * This function is designed for API usage. + * + * @param playerName 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 + * + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static void setLevelOffline(String playerName, String skillType, int skillLevel) { + getOfflineProfile(playerName).modifySkill(SkillType.getSkill(skillType), skillLevel); + } + /** * Sets the XP of a player in a specific skill type. *
@@ -316,6 +492,21 @@ public final class ExperienceAPI { UserManager.getPlayer(player).getProfile().setSkillXpLevel(SkillType.getSkill(skillType), newValue); } + /** + * Sets the XP of an offline player in a specific skill type. + *
+ * This function is designed for API usage. + * + * @param playerName 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 + * + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static void setXPOffline(String playerName, String skillType, int newValue) { + getOfflineProfile(playerName).setSkillXpLevel(SkillType.getSkill(skillType), newValue); + } + /** * Removes XP from a player in a specific skill type. *
@@ -344,6 +535,21 @@ public final class ExperienceAPI { UserManager.getPlayer(player).getProfile().removeXp(SkillType.getSkill(skillType), xp); } + /** + * Removes XP from an offline player in a specific skill type. + *
+ * This function is designed for API usage. + * + * @param playerName The player to change the XP of + * @param skillType The skill to change the XP for + * @param xp The amount of XP to remove + * + * @throws InvalidPlayerException if the given player does not exist in the database + */ + public static void removeXPOffline(String playerName, String skillType, int xp) { + getOfflineProfile(playerName).removeXp(SkillType.getSkill(skillType), xp); + } + /** * Check the XP of a player. This should be called after giving XP to process level-ups. * @@ -355,4 +561,41 @@ public final class ExperienceAPI { private static void checkXP(Player player, SkillType skillType) { SkillUtils.xpCheckSkill(skillType, player, UserManager.getProfile(player)); } + + /** + * Add XP to an offline player. + * + * @param playerName The player to check + * @param skillType The skill to check + * @param XP The amount of XP to award. + */ + private static void addOfflineXP(String playerName, String skillType, int XP) { + PlayerProfile profile = getOfflineProfile(playerName); + + SkillType skill = SkillType.getSkill(skillType); + + if (skill.isChildSkill()) { + Set parentSkills = FamilyTree.getParents(skill); + + for (SkillType parentSkill : parentSkills) { + profile.setSkillXpLevel(parentSkill, profile.getSkillLevel(parentSkill) + (XP / parentSkills.size())); + } + + profile.save(); + return; + } + + profile.setSkillXpLevel(skill, profile.getSkillXpLevel(skill) + XP); + profile.save(); + } + + private static PlayerProfile getOfflineProfile(String playerName) { + PlayerProfile profile = new PlayerProfile(playerName, false); + + if (!profile.isLoaded()) { + throw new InvalidPlayerException(); + } + + return profile; + } } diff --git a/src/main/java/com/gmail/nossr50/api/InvalidPlayerException.java b/src/main/java/com/gmail/nossr50/api/InvalidPlayerException.java new file mode 100644 index 000000000..6d9b31f82 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/api/InvalidPlayerException.java @@ -0,0 +1,9 @@ +package com.gmail.nossr50.api; + +public class InvalidPlayerException extends RuntimeException { + private static final long serialVersionUID = 907213002618581385L; + + public InvalidPlayerException() { + super("That player does not exist in the database."); + } +} 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 ad887efde..2385ccd12 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -450,9 +450,18 @@ public class McMMOPlayer { */ public void applyXpGain(SkillType skillType, int xp) { if (skillType.isChildSkill()) { + Set parentSkills = FamilyTree.getParents(skillType); + + for (SkillType parentSkill : parentSkills) { + if (Permissions.skillEnabled(player, parentSkill)) { + applyXpGain(parentSkill, xp / parentSkills.size()); + } + } + return; } + McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp); mcMMO.p.getServer().getPluginManager().callEvent(event); From 050f97e08832caf139e6ef2dae2754fc38a09dac Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 10:38:43 -0400 Subject: [PATCH 79/94] Remove deprecated functions from ExperienceAPI --- Changelog.txt | 1 + .../com/gmail/nossr50/api/ExperienceAPI.java | 182 ------------------ 2 files changed, 1 insertion(+), 182 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index ce42d8b4a..3ebc5ff0f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,6 +14,7 @@ Version 1.4.04-dev = Fixed bug where Mining wasn't awarding double drops = Fixed bug where Shake wouldn't damage mobs whose max health was less than 4 = Fixed bug where the API would fail if the name of a player's current party is requested when the player isn't in one (Thanks @dualspiral!) + - Removed deprecated functions from ExperienceAPI Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index 66a72771c..710d7b698 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -9,26 +9,10 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.skills.child.FamilyTree; 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. *
@@ -57,21 +41,6 @@ public final class ExperienceAPI { addOfflineXP(playerName, 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. *
@@ -130,21 +99,6 @@ public final class ExperienceAPI { addOfflineXP(playerName, skillType, (int) (XP / SkillType.getSkill(skillType).getXpModifier() * 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. *
@@ -158,21 +112,6 @@ public final class ExperienceAPI { 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. *
@@ -200,21 +139,6 @@ public final class ExperienceAPI { return getOfflineProfile(playerName).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. *
@@ -242,40 +166,6 @@ public final class ExperienceAPI { return getOfflineProfile(playerName).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. *
@@ -320,21 +210,6 @@ public final class ExperienceAPI { profile.save(); } - /** - * 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. *
@@ -421,21 +296,6 @@ public final class ExperienceAPI { return Config.getInstance().getPowerLevelCap(); } - /** - * 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. *
@@ -464,21 +324,6 @@ public final class ExperienceAPI { getOfflineProfile(playerName).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. *
@@ -507,21 +352,6 @@ public final class ExperienceAPI { getOfflineProfile(playerName).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. *
@@ -550,18 +380,6 @@ public final class ExperienceAPI { getOfflineProfile(playerName).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)); - } - /** * Add XP to an offline player. * From d196710a879db353df100788717585759cf60639 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 10:40:32 -0400 Subject: [PATCH 80/94] Removed deprecated methods from ChatAPI --- .../java/com/gmail/nossr50/api/ChatAPI.java | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/api/ChatAPI.java b/src/main/java/com/gmail/nossr50/api/ChatAPI.java index 61662c312..d1bdb3b5c 100644 --- a/src/main/java/com/gmail/nossr50/api/ChatAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ChatAPI.java @@ -39,22 +39,6 @@ public final class ChatAPI { ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, sender, message); } - /** - * Send a message to all members of a party - *
- * This function is designed for API usage. - * - * @deprecated Replaced by sendPartyChat(Plugin, String, String, String) - * - * @param sender The name of the sender to display in the chat - * @param party The name of the party to send to - * @param message The message to send - */ - @Deprecated - public static void sendPartyChat(String sender, String party, String message) { - sendPartyChat(null, party, sender, sender, message); - } - /** * Send a message to administrators *
@@ -82,21 +66,6 @@ public final class ChatAPI { ChatManager.handleAdminChat(plugin, sender, sender, message); } - /** - * Send a message to administrators - *
- * This function is designed for API usage. - * - * @deprecated Replaced by sendAdminChat(Plugin, String, String) - * - * @param sender The name of the sender to display in the chat - * @param message The message to send - */ - @Deprecated - public static void sendAdminChat(String sender, String message) { - sendAdminChat(null, sender, sender, message); - } - /** * Check if a player is currently talking in party chat. * From 685f901e09debb56043045efd10091496ff76ccc Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 10:41:34 -0400 Subject: [PATCH 81/94] Removed deprecated functions from PartyAPI --- .../java/com/gmail/nossr50/api/PartyAPI.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index 300972690..cc6ef26f9 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -120,26 +120,6 @@ public final class PartyAPI { 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. *
From c4504de1da33e7a3fe1ec16f2bbc9b627cd54c45 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 10:41:53 -0400 Subject: [PATCH 82/94] Update changelog. --- Changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 3ebc5ff0f..4b78d2ce2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,7 +14,7 @@ Version 1.4.04-dev = Fixed bug where Mining wasn't awarding double drops = Fixed bug where Shake wouldn't damage mobs whose max health was less than 4 = Fixed bug where the API would fail if the name of a player's current party is requested when the player isn't in one (Thanks @dualspiral!) - - Removed deprecated functions from ExperienceAPI + - Removed deprecated functions from API classes. Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker From 70e8e534fe271f22cb758225b2e37a40c38d71d2 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 10:46:29 -0400 Subject: [PATCH 83/94] Fixed bug with retrieving a player's party members --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/party/PartyManager.java | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 4b78d2ce2..bbccda6b8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,6 +14,7 @@ Version 1.4.04-dev = Fixed bug where Mining wasn't awarding double drops = Fixed bug where Shake wouldn't damage mobs whose max health was less than 4 = Fixed bug where the API would fail if the name of a player's current party is requested when the player isn't in one (Thanks @dualspiral!) + = Fixed bug with retrieving a player's party members - Removed deprecated functions from API classes. Version 1.4.03 diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index cbe174eb9..28a1782f6 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -131,7 +131,13 @@ public final class PartyManager { * @return all online players in this party */ public static List getOnlineMembers(Player player) { - return getOnlineMembers(player.getName()); + Party party = getPlayerParty(player.getName()); + + if (party == null) { + return null; + } + + return getOnlineMembers(party.getName()); } /** From c14ceab24d5e27aa7a6cebd35b76e70541a459d3 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 11:01:30 -0400 Subject: [PATCH 84/94] Remove unused import. --- src/main/java/com/gmail/nossr50/api/PartyAPI.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index cc6ef26f9..c3cd324b8 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.api; -import java.util.ArrayList; import java.util.List; import org.bukkit.OfflinePlayer; From e7ee23b8716f25a782624aa82f69502c904d8f92 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 17 Mar 2013 21:47:45 -0400 Subject: [PATCH 85/94] Fixes NPE with FurnaceExtractEvent. Fixes #847 --- .../java/com/gmail/nossr50/listeners/InventoryListener.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 4f8b7ecf7..e30072f5e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -142,6 +142,10 @@ public class InventoryListener implements Listener { // We can make this assumption because we (should) be the only ones using this exact metadata Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString()); + if (Misc.isNPCEntity(player)) { + return; + } + SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager(); if (smeltingManager.canUseVanillaXpBoost()) { From 814ffbe8004e29488005d024d9663612050b72e2 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 16 Mar 2013 11:41:16 -0400 Subject: [PATCH 86/94] Fixed by Bukkit in CB #2654 --- .../java/com/gmail/nossr50/listeners/InventoryListener.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index e30072f5e..b0c4fa62b 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -157,8 +157,6 @@ public class InventoryListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryClickEvent(InventoryClickEvent event) { - if (event.getSlot() >= 0) { - SkillUtils.removeAbilityBuff(event.getCurrentItem()); - } + SkillUtils.removeAbilityBuff(event.getCurrentItem()); } } From b0d609e9a319fccef8ad22e9c40865098aa55b81 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 16 Mar 2013 12:15:16 -0400 Subject: [PATCH 87/94] Add Quartz Ore to Mining. --- src/main/java/com/gmail/nossr50/util/BlockUtils.java | 3 +++ src/main/resources/config.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 3edd77b6a..af76d0bc2 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -39,6 +39,7 @@ public final class BlockUtils { case NETHERRACK: case OBSIDIAN: case PUMPKIN: + case QUARTZ_ORE: case RED_MUSHROOM: case RED_ROSE: case REDSTONE_ORE: @@ -123,6 +124,7 @@ public final class BlockUtils { case GOLD_ORE: case IRON_ORE: case LAPIS_ORE: + case QUARTZ_ORE: case REDSTONE_ORE: case EMERALD_ORE: return true; @@ -208,6 +210,7 @@ public final class BlockUtils { case MOSSY_COBBLESTONE: case NETHERRACK: case OBSIDIAN: + case QUARTZ_ORE: case REDSTONE_ORE: case SANDSTONE: case STONE: diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c6326227a..f0361cafc 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -220,6 +220,7 @@ Double_Drops: Mossy_Cobblestone: true Netherrack: true Obsidian: true + Quartz_Ore: true Redstone_Ore: true Sandstone: true Stone: true @@ -301,6 +302,7 @@ Experience: Mossy_Cobblestone: 30 Netherrack: 30 Obsidian: 150 + Quartz_Ore: 250 Redstone_Ore: 150 Sandstone: 30 Stone: 30 @@ -311,6 +313,7 @@ Experience: Gold_Ore: 35 Iron_Ore: 25 Lapis_Ore: 40 + Quartz_Ore: 25 Redstone_Ore: 15 Taming: Animal_Taming: From 42bc5065df81cf705bc45d22824c4fec32dbb978 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 16 Mar 2013 12:22:22 -0400 Subject: [PATCH 88/94] Add support for new 1.5 inventory blocks. --- src/main/java/com/gmail/nossr50/util/BlockUtils.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index af76d0bc2..715042da7 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -93,6 +93,9 @@ public final class BlockUtils { case WORKBENCH: case BEACON: case ANVIL: + case DROPPER: + case HOPPER: + case TRAPPED_CHEST: return false; default: From 5453b0511df0e022c58771edaf16a34ce53e65a7 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 18 Mar 2013 00:09:22 -0400 Subject: [PATCH 89/94] Update changelog. --- Changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index bbccda6b8..bbac537ed 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,8 @@ Key: Version 1.4.04-dev + Added functions to ExperienceAPI for use with offline players + + Added Nether Quartz Ore to Mining + + Added Dropper, Hopper, and Trapped Chest to blocks that shouldn't activate abilities = Fixed bug where trying to activate a Chimaera Wing would require one item too much = Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't = Fixed bug where Mining wasn't awarding double drops From d0043618360d2ed0a11dc72600908c1e335595a1 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 18 Mar 2013 11:34:11 -0400 Subject: [PATCH 90/94] Removed functions for getting the PlayerProfile - using API classes is preferred, but if not the McMMOPlayer should be used instead --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/mcMMO.java | 39 ------------------- .../nossr50/util/player/UserManager.java | 25 ------------ 3 files changed, 1 insertion(+), 64 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index bbac537ed..dfd251352 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -18,6 +18,7 @@ Version 1.4.04-dev = Fixed bug where the API would fail if the name of a player's current party is requested when the player isn't in one (Thanks @dualspiral!) = Fixed bug with retrieving a player's party members - Removed deprecated functions from API classes. + - Removed functions for getting the PlayerProfile - using API classes is preferred, but if not the McMMOPlayer should be used instead Version 1.4.03 + Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index f0bc48c31..b0b45defc 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -8,7 +8,6 @@ import java.util.List; import net.shatteredlands.shatt.backup.ZipLibrary; -import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.metadata.FixedMetadataValue; @@ -27,7 +26,6 @@ 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; @@ -197,43 +195,6 @@ public class mcMMO extends JavaPlugin { 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. * diff --git a/src/main/java/com/gmail/nossr50/util/player/UserManager.java b/src/main/java/com/gmail/nossr50/util/player/UserManager.java index bd380486a..06f4da6bb 100644 --- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -10,7 +10,6 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.player.PlayerProfile; public final class UserManager { private static Map players = new HashMap(); @@ -81,30 +80,6 @@ public final class UserManager { return players; } - /** - * Get the profile of a player. - * - * @param player The player whose profile to retrieve - * @return the player's profile - */ - @Deprecated - public static PlayerProfile getProfile(OfflinePlayer player) { - return getProfile(player.getName()); - } - - /** - * Get the profile of a player by name. - * - * @param playerName The name of the player whose profile to retrieve - * @return the player's profile - */ - @Deprecated - public static PlayerProfile getProfile(String playerName) { - McMMOPlayer mcmmoPlayer = players.get(playerName); - - return (mcmmoPlayer != null) ? mcmmoPlayer.getProfile() : null; - } - /** * Get the McMMOPlayer of a player by name. * From 255dece55073eb9962c41dea565a83fb1204f132 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 18 Mar 2013 14:01:52 -0400 Subject: [PATCH 91/94] Move Arcane Forging to it's own class to match the structure we used with Blast Mining. --- .../commands/skills/RepairCommand.java | 5 ++- .../nossr50/skills/repair/ArcaneForging.java | 42 +++++++++++++++++++ .../gmail/nossr50/skills/repair/Repair.java | 37 ---------------- .../nossr50/skills/repair/RepairManager.java | 6 +-- 4 files changed, 48 insertions(+), 42 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 084c6b391..f6856fd71 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -5,6 +5,7 @@ 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.ArcaneForging; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.Repairable; @@ -146,11 +147,11 @@ public class RepairCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank())); - if (Repair.arcaneForgingEnchantLoss) { + if (ArcaneForging.arcaneForgingEnchantLoss) { player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance()))); } - if (Repair.arcaneForgingDowngrades) { + if (ArcaneForging.arcaneForgingDowngrades) { player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance()))); } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java b/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java new file mode 100644 index 000000000..b16a20bd4 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java @@ -0,0 +1,42 @@ +package com.gmail.nossr50.skills.repair; + +import com.gmail.nossr50.config.AdvancedConfig; + +public class ArcaneForging { + // The order of the values is extremely important, a few methods depend on it to work properly + protected enum Tier { + FOUR(4) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels4(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}, + THREE(3) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels3(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); }}, + TWO(2) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels2(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); }}, + ONE(1) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels1(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); }}; + + int numerical; + + private Tier(int numerical) { + this.numerical = numerical; + } + + public int toNumerical() { + return numerical; + } + + abstract protected int getLevel(); + abstract protected int getKeepEnchantChance(); + abstract protected int getDowngradeEnchantChance(); + } + + public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled(); + public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled(); +} 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 7e33c9914..5a7caa9bf 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -10,49 +10,12 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.ItemUtils; public class Repair { - // The order of the values is extremely important, a few methods depend on it to work properly - protected enum Tier { - FOUR(4) { - @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels4(); } - @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}, - THREE(3) { - @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels3(); } - @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); }}, - TWO(2) { - @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels2(); } - @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); }}, - ONE(1) { - @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels1(); } - @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); }}; - - int numerical; - - private Tier(int numerical) { - this.numerical = numerical; - } - - public int toNumerical() { - return numerical; - } - - abstract protected int getLevel(); - abstract protected int getKeepEnchantChance(); - abstract protected int getDowngradeEnchantChance(); - } - public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel(); public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus(); public static int superRepairMaxBonusLevel = AdvancedConfig.getInstance().getSuperRepairMaxLevel(); public static double superRepairMaxChance = AdvancedConfig.getInstance().getSuperRepairChanceMax(); - public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled(); - public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled(); - public static int salvageUnlockLevel = AdvancedConfig.getInstance().getSalvageUnlockLevel(); public static int salvageAnvilId = Config.getInstance().getSalvageAnvilId(); 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 979ce59e1..06faeed2e 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -20,7 +20,7 @@ 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.SkillManager; -import com.gmail.nossr50.skills.repair.Repair.Tier; +import com.gmail.nossr50.skills.repair.ArcaneForging.Tier; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; @@ -155,7 +155,7 @@ public class RepairManager extends SkillManager { } // Handle the enchants - if (Repair.arcaneForgingEnchantLoss) { + if (ArcaneForging.arcaneForgingEnchantLoss) { addEnchants(item); } @@ -325,7 +325,7 @@ public class RepairManager extends SkillManager { if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) { int enchantLevel = enchant.getValue(); - if (Repair.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) { + if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) { item.addEnchantment(enchantment, enchantLevel - 1); downgraded = true; } From db2bf9ee518005663e4671d158d08d2a371c041d Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 18 Mar 2013 14:28:04 -0400 Subject: [PATCH 92/94] Updated localization files. --- Changelog.txt | 1 + .../resources/locale/locale_cs_CZ.properties | 1 + .../resources/locale/locale_it.properties | 2 +- .../resources/locale/locale_ko.properties | 287 +++++++++++++++++- .../resources/locale/locale_nl.properties | 1 - .../resources/locale/locale_ru.properties | 2 +- .../resources/locale/locale_zh_TW.properties | 1 - 7 files changed, 276 insertions(+), 19 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index dfd251352..6d6632179 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -17,6 +17,7 @@ Version 1.4.04-dev = Fixed bug where Shake wouldn't damage mobs whose max health was less than 4 = Fixed bug where the API would fail if the name of a player's current party is requested when the player isn't in one (Thanks @dualspiral!) = Fixed bug with retrieving a player's party members + ! Updated localization files - Removed deprecated functions from API classes. - Removed functions for getting the PlayerProfile - using API classes is preferred, but if not the McMMOPlayer should be used instead diff --git a/src/main/resources/locale/locale_cs_CZ.properties b/src/main/resources/locale/locale_cs_CZ.properties index e94de5483..c26cab69e 100644 --- a/src/main/resources/locale/locale_cs_CZ.properties +++ b/src/main/resources/locale/locale_cs_CZ.properties @@ -142,6 +142,7 @@ Mining.Blast.Rank=[[RED]]V\u00fdbu\u0161n\u00e9 t\u011b\u017een\u00ed [[YELLOW]] Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] pou\u017eil [[RED]]V\u00fdbu\u0161n\u00e9 T\u011b\u017een\u00ed! Mining.Blast.Refresh=[[GREEN]]Dovednost [[YELLOW]]Dolovani vybuchem [[GREEN]]je nyni obnovena! Repair.AnvilPlaced.Spout1=[mcMMO] Kovadlina umistena +Repair.AnvilPlaced.Spout2=Prav\u00e9 kliknut\u00ed pro opravu! Repair.Effect.0=Opravovani Repair.Effect.1=Oprava zbroje a n\u00e1stroj\u016f Repair.Effect.10=Oprava zlata ({0}+ SKILL) diff --git a/src/main/resources/locale/locale_it.properties b/src/main/resources/locale/locale_it.properties index e6e874947..f31e98663 100644 --- a/src/main/resources/locale/locale_it.properties +++ b/src/main/resources/locale/locale_it.properties @@ -407,7 +407,6 @@ 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 Commands.Party.Members.Header=[[RED]]-----[][[GREEN]]MEMBRI[[RED]][]----- -Commands.Party.Members={0} Commands.Party.None=[[RED]]Non sei nella compagnia. Commands.Party.Quit=[[RED]]- Abbandona la tua attuale compagnia Commands.Party.Teleport= [[RED]]- Teletrasportati verso un membro della compagnia @@ -483,6 +482,7 @@ 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. diff --git a/src/main/resources/locale/locale_ko.properties b/src/main/resources/locale/locale_ko.properties index 81cd1e3b4..e7169ec57 100644 --- a/src/main/resources/locale/locale_ko.properties +++ b/src/main/resources/locale/locale_ko.properties @@ -1,100 +1,357 @@ -Acrobatics.Combat.Proc=[[green]]**Dodge** +Acrobatics.Ability.Proc=[[GREEN]]**\uc6b0\uc544\ud55c \ucc29\uc9c0** +Acrobatics.Combat.Proc=[[GREEN]]**\ud68c\ud53c** +Acrobatics.DodgeChance=[[RED]]\ud68c\ud53c \ud655\ub960: [[YELLOW]]{0} +Acrobatics.Effect.0=\ucc29\uc9c0 +Acrobatics.Effect.1=\ucd94\ub77d \ub370\ubbf8\uc9c0 \uac10\uc18c \ub610\ub294 \ubb34\uc2dc +Acrobatics.Effect.2=\uc6b0\uc544\ud55c \ucc29\uc9c0 +Acrobatics.Effect.3=\uc77c\ubc18 \ucc29\uc9c0\uc5d0 \ube44\ud574 2\ubc30 \ub354 \ud6a8\uc728\uc801\uc784 +Acrobatics.Effect.4=\ud68c\ud53c +Acrobatics.Effect.5=\uacf5\uaca9 \ub370\ubbf8\uc9c0 \ubc18\uc73c\ub85c \uac10\uc18c Acrobatics.Listener=\uace1\uc608: +Acrobatics.Roll.Chance=[[RED]]\ucc29\uc9c0 \ud655\ub960: [[YELLOW]]{0} +Acrobatics.Roll.GraceChance=[[RED]]\uc6b0\uc544\ud55c \ucc29\uc9c0 \ud655\ub960: [[YELLOW]]{0} Acrobatics.SkillName=\uc7ac\uc8fc \ub118\uae30 Acrobatics.Skillup=[[\ub178\ub780\uc0c9]] \uace1\uc608 \uae30\uc220\uc740 {0} \uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) +Archery.Effect.1=\ud65c\uc774 \uc8fc\ub294 \ud53c\ud574 \uc99d\uac00 +Archery.Effect.5=\uc2dc\uccb4\ub85c \ubd80\ud130 \ud654\uc0b4\uc744 \ud68c\uc218\ud560 \ud655\ub960 Archery.Listener=\uad81\uc220: Archery.Skillup=[[\ub178\ub780\uc0c9]] {0} \uc99d\uac00 \uc591\uad81 \uae30\uc220. \ucd1d ({1}) Axes.Ability.Bonus.0=\ub3c4\ub07c \ub9c8\uc2a4\ud130\ub9ac +Axes.Ability.Bonus.1=\ubcf4\ub108\uc2a4 {0} \ub370\ubbf8\uc9c0 +Axes.Ability.Lower=[[GRAY]]**\ub3c4\ub07c \uc900\ube44\ud574\uc81c** +Axes.Ability.Ready=[[GREEN]]**\ub3c4\ub07c\uac00 \uc900\ube44\ub428** +Axes.Combat.CritStruck=[[DARK_RED]]\uce58\uba85\uc0c1\uc744 \uc785\uc74c! +Axes.Combat.CritChance=[[RED]]critically strike \ud655\ub960: [[YELLOW]]{0} Axes.Combat.GI.Struck=[[RED]]**\uce58\uba85\uc0c1\uc744 \uc785\uc5c8\ub2e4** Axes.Effect.2=\uacb0\uc815\uc801\uc778 \uacf5\uaca9 Axes.Effect.3=\uc774\uc911 \ub370\ubbf8\uc9c0 +Axes.Effect.4=\ub3c4\ub07c \ub9c8\uc2a4\ud130\ub9ac +Axes.Effect.7=\ubc29\uc5b4\uad6c\ub97c \ud30c\uad34\ud558\uae30 \uc704\ud574 \ucda9\ubd84\ud55c \ud798\uc73c\ub85c \ud0c0\uaca9\ud558\uc2ed\uc2dc\uc624 +Axes.Effect.9=\ube44\ubb34\uc7a5\uc0c1\ud0dc\uc758 \uc801\uc5d0\uac8c \ucd94\uac00 \ub370\ubbf8\uc9c0 +Axes.Skills.SS.Off=[[RED]]**Skull Splitter \uc758 \ud6a8\uacfc\uac00 \ub05d\ub0a8** Axes.Skills.SS.On=[[\ub179\uc0c9]] ** \uc2a4\uceec \uc2a4\ud50c\ub9ac\ud130 \ud65c\uc131\ud654 ** Axes.Skills.SS.Refresh=[[\ub179\uc0c9]] \ub2f9\uc2e0\uc758 [[\ub178\ub780\uc0c9]] \uc2a4\uceec \uc2a4\ud50c\ub9ac\ud130 [[\ub179\uc0c9]] \ub2a5\ub825\uc774 \uc0c8\ub85c \uace0\uccd0\uc9d1\ub2c8\ub2e4! Axes.Skills.SS.Other.On=[[\ub179\uc0c9]] {0} [[\uc5b4\ub450\uc6b4 \ub179\uc0c9]] \uc0ac\uc6a9\ud55c [[\ub808\ub4dc]] \uc2a4\uceec \uc2a4\ud50c\ub9ac\ud130! Axes.Skillup=[[YELLOW]]\ub3c4\ub07c \uae30\uc220\uc774 {0} \uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) +Excavation.Ability.Lower=[[GRAY]]**\uc0bd \uc900\ube44\ud574\uc81c** +Excavation.Ability.Ready=[[GREEN]]**\uc0bd\uc774 \uc900\ube44\ub428** +Excavation.Effect.0=Giga Drill Breaker (\ub2a5\ub825) +Excavation.Effect.1=3x \ub4dc\ub86d\ub960, 3x \uacbd\ud5d8\uce58, +\uc18d\ub3c4 +Excavation.Effect.2=\ubcf4\ubb3c \uc0ac\ub0e5\uafbc +Excavation.Effect.3=\ubcf4\ubb3c\uc744 \uc704\ud574 \ub545\uc744 \ud30c\ub294 \ub2a5\ub825 +Excavation.Effect.Length=[[RED]]Giga Drill Breaker \uc9c0\uc18d\uc2dc\uac04: [[YELLOW]]{0}s +Excavation.Listener=\ubc1c\uad74: Excavation.SkillName=\ubc1c\uad74 +Excavation.Skills.GigaDrillBreaker.Off=[[RED]]**Giga Drill Breaker \uc758 \ud6a8\uacfc\uac00 \ub05d\ub0a8** +Excavation.Skills.GigaDrillBreaker.On=[[GREEN]]**GIGA DRILL BREAKER \ud65c\uc131\ud654\ub428** +Excavation.Skills.GigaDrillBreaker.Refresh=[[YELLOW]]Giga Drill Breaker [[GREEN]]\ub2a5\ub825\uc744 \ub2e4\uc2dc \uc0ac\uc6a9\ud560 \uc218 \uc788\uc74c! +Excavation.Skills.GigaDrillBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \uac00[[RED]]Giga Drill Breaker\ub97c \uc0ac\uc6a9\ud568! +Excavation.Skillup=[[YELLOW]]\ubc1c\uad74 \uae30\uc220\uc774 {0}\uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) +Fishing.Ability.Locked.0=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (SHAKE) +Fishing.Ability.FD=[[RED]]\uc5b4\ubd80\uc758 \uc2dd\ub2e8: [[YELLOW]]Rank {0} +Fishing.Effect.3=\uc778\uccb8\ud2b8\ub41c \uc544\uc774\ud0ec\uc744 \ucc3e\uc74c +Fishing.Effect.6=\uc5b4\ubd80\uc758 \uc2dd\ub2e8 +Fishing.Effect.7=\uc0dd\uc120\uc744 \ud1b5\ud55c \ud5c8\uae30 \ud68c\ubcf5\ub7c9 \uc99d\uac00 Fishing.ItemFound=[[GRAY]]\ubcf4\ubb3c\uc744 \ubc1c\uacac\ud588\uc2b5\ub2c8\ub2e4! +Fishing.Listener=\ub09a\uc2dc: +Fishing.SkillName=\ub09a\uc2dc +Fishing.Skillup=[[YELLOW]]\ub09a\uc2dc \uae30\uc220\uc774 {0}\uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) +Herbalism.Ability.DoubleDropChance=[[RED]]2\ubc30 \ub4dc\ub78d \ud655\ub960: [[YELLOW]]{0} +Herbalism.Ability.GTe.Length=[[RED]]Green Terra \uc9c0\uc18d\uc2dc\uac04: [[YELLOW]]{0}s Herbalism.Ability.GTh=[[GREEN]]**\ucc98\uc138\uc220** +Herbalism.Ability.Lower=[[GRAY]]**\uad2d\uc774 \uc900\ube44\ud574\uc81c** +Herbalism.Ability.Ready=[[GREEN]]**\uad2d\uc774\uac00 \uc900\ube44\ub428** +Herbalism.Effect.6=\ub18d\ubd80\uc758 \uc2dd\ub2e8 +Herbalism.Effect.7=\ub18d\uc791\ubb3c\uc744 \ud1b5\ud55c \ud5c8\uae30 \ud68c\ubcf5\ub7c9 \uc99d\uac00 +Herbalism.Effect.11=\ud76c\uae14\ud55c \uc544\uc774\ud0ec\uc744 \ucc3e\uc744 \ud655\ub960 \uc18c\ud3ed \uc99d\uac00 Herbalism.Listener=\uc57d\ucd08\ud559 : +Herbalism.SkillName=\uc57d\ucd08\ud559 +Herbalism.Skills.GTe.On=[[GREEN]]**GREEN TERRA \ud65c\uc131\ud654\ub428** 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.** +Herbalism.Skillup=[[YELLOW]]\uc57d\ucd08\ud559 \uae30\uc220\uc774 {0}\uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) +Mining.Ability.Length=[[RED]]Super Breaker \uc9c0\uc18d\uc2dc\uac04: [[YELLOW]]{0}s +Mining.Ability.Locked.0=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (BLAST MINING) +Mining.Ability.Locked.1=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (BIGGER BOMBS) +Mining.Ability.Locked.2=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (DEMOLITIONS EXPERTISE) +Mining.Ability.Lower=[[GRAY]]**\uace1\uad2d\uc774 \uc900\ube44\ud574\uc81c** +Mining.Ability.Ready=[[GREEN]]**\uace1\uad2d\uc774\uac00 \uc900\ube44\ub428** +Mining.Effect.0=Super Breaker (\ub2a5\ub825) +Mining.Effect.1=\uc18d\ub3c4+, \ub4dc\ub78d\ub960 3\ubc30 +Mining.Effect.2=\ub4dc\ub78d\ub960 2\ubc30 +Mining.Effect.9=TNT \ud3ed\ubc1c\uc73c\ub85c \uc778\ud55c \ud53c\ud574 \uac10\uc18c +Mining.Effect.DropChance=[[RED]]2\ubc30 \ub4dc\ub78d \ud655\ub960: [[YELLOW]]{0} Mining.Listener=\uad11\uc5c5: +Mining.Skills.SuperBreaker.Off=[[RED]]**Super Breaker \uc758 \ud6a8\uacfc\uac00 \ub05d\ub0a8** +Mining.Skills.SuperBreaker.On=[[GREEN]]**SUPER BREAKER \ud65c\uc131\ud654\ub428** 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! -Mining.Skillup=[[\ub178\ub780\uc0c9]] \ub9c8\uc774\ub2dd \uae30\uc220 {0} \uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) +Mining.Skillup=[[YELLOW]]\ucc44\uad11 \uae30\uc220\uc774 {0}\uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) Mining.Blast.Radius.Increase=[[RED]]\ud3ed\ubc1c \ubc94\uc704 \uc99d\uac00\ub7c9: [[YELLOW]]+{0} -Mining.Blast.Refresh=[[GREEN]]\ub2f9\uc2e0\uc758 [[YELLOW]]\ubc1c\ud30c [[GREEN]]\ub2a5\ub825\uc774 \uc6d0\uc0c1\ubcf5\uadc0 \ub418\uc5c8\uc2b5\ub2c8\ub2e4! +Mining.Blast.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \uac00[[RED]]Blast Mining\ub97c \uc0ac\uc6a9\ud568! +Mining.Blast.Refresh=[[YELLOW]]Blast Mining [[GREEN]] \ub2a5\ub825\uc744 \ub2e4\uc2dc \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4! +Repair.AnvilPlaced.Spout1=[mcMMO] \ubaa8\ub8e8 \uc124\uce58\ub428 +Repair.AnvilPlaced.Spout2=\uc6b0\ud074\ub9ad\uc73c\ub85c \uc218\ub9ac! Repair.Effect.0=\uc218\ub9ac +Repair.Effect.1=\ub3c4\uad6c & \uc7a5\ube44 \uc218\ub9ac +Repair.Effect.11=\uae08 \ub3c4\uad6c& \uc7a5\ube44 \uc218\ub9ac +Repair.Effect.13=\ucca0 \ub3c4\uad6c&\uc7a5\ube44 \uc218\ub9ac +Repair.Effect.15=\ub3cc \ub3c4\uad6c \uc218\ub9ac Repair.Effect.2=\uc218\ub9ac \ub9c8\uc2a4\ud130\ub9ac +Repair.Effect.3=\uc218\ub9ac \uc591 \uc99d\uac00 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.Anvil=[[DARK_RED]]\ub2f9\uc2e0\uc740 \ubaa8\ub8e8\ub97c \uc124\uce58\ud588\uc2b5\ub2c8\ub2e4, \ubaa8\ub8e8\ub294 \ub3c4\uad6c\uc640 \uac11\uc637\uc744 \uc218\ub9ac\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. Repair.Listener=\ubcf5\uad6c : Repair.SkillName=REPAIR Repair.Skills.AdeptDiamond=[[\uac80 \ubd89\uc740]] \ub2f9\uc2e0\uc740 \ub2e4\uc774\uc544\ubaac\ub4dc\ub97c \ubcf5\uad6c \ud560 \uc218\uc788\uc744\ub9cc\ud07c \uc219\ub828 \ub41c \uc544\ub2c8\uc5d0\uc694. Repair.Skills.AdeptGold=[[DARK_RED]]\ub2f9\uc2e0\uc740 \uae08\uc744 \ubcf5\uad6c\ud560 \uc218 \uc788\uc744\ub9cc\ud07c \uc219\ub828\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4. +Repair.Skills.AdeptIron=[[DARK_RED]]\ub2f9\uc2e0\uc740 \ucca0\uc744 \uc218\ub9ac\ud560 \uc218 \uc788\uc744\ub9cc\ud07c \uc219\ub828\ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4. Repair.Skills.AdeptStone=[[\uac80 \ubd89\uc740]] \ub2f9\uc2e0\uc740 \ub3cc\uc744 \ubcf5\uad6c \ud560 \uc218\uc788\uc744\ub9cc\ud07c \uc219\ub828 \ub41c \uc544\ub2c8\uc5d0\uc694. +Repair.Skills.FeltEasy=[[GRAY]]\uadf8\uac83\uc740 \uc27d\uac8c \ub290\uaef4\uc9d1\ub2c8\ub2e4. +Repair.Skills.FullDurability=[[GRAY]]\ucd5c\uace0 \ub0b4\uad6c\ub3c4 \uc0c1\ud0dc\uc784 +Repair.Skills.StackedItems=[[DARK_RED]] \ubb49\uccd0\ub193\uc740 \uc544\uc774\ud0ec\uc744 \uc218\ub9ac\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. Repair.Skillup=[[\ub178\ub780\uc0c9]] \uc218\ub9ac \uae30\uc220 {0} \uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) Repair.Arcane.Chance.Success=[[\ud68c\uc0c9]] AF \uc131\uacf5 \uc18d\ub3c4 : [[\ub178\ub780\uc0c9]] {0} % Repair.Arcane.Fail=[[\ub808\ub4dc]] \ub9c8\ubc95 \uc804\uc6d0\uc774 \uc601\uad6c\uc801\uc73c\ub85c \ud56d\ubaa9\uc744 \ub0a8\uacbc\uc2b5\ub2c8\ub2e4. -Swords.Ability.Ready=[[\ub179\uc0c9]] ** \uc900\ube44 \ub410\uc5b4 \uac80\uc744 ** +Repair.Arcane.Lost=[[RED]]\uacc4\uc18d \uc778\uccb8\ud2b8\ub97c \ud558\uae30\uc5d4 \ub2f9\uc2e0\uc758 \uc219\ub828\ub3c4\uac00 \ubd80\uc871\ud569\ub2c8\ub2e4. +Swords.Ability.Lower=[[GRAY]]**\uac80 \uc900\ube44\ud574\uc81c** +Swords.Ability.Ready=[[GREEN]]**\uac80\uc774 \uc900\ube44\ub428** +Swords.Combat.Bleed.Chance=[[RED]]\ucd9c\ud608(Bleed) \ud655\ub960: [[YELLOW]]{0} +Swords.Combat.Bleed.Length=[[RED]]Bleed \uc9c0\uc18d\uc2dc\uac04: [[YELLOW]]{0} \ud2f1 +Swords.Combat.Bleed.Note=[[GRAY]]NOTE: [[YELLOW]]2\ucd08\ub2f9 1\ud2f1(Tick) +Swords.Combat.Bleeding.Started=[[DARK_RED]] \ub2f9\uc2e0\uc740 \ucd9c\ud608\uc911\uc785\ub2c8\ub2e4! Swords.Combat.Bleeding.Stopped=[[\ud68c\uc0c9]] \ucd9c\ud608\uc774 \uac00\uc9c4 [[\ub179\uc0c9]] \uc911\uc9c0 [[\ud68c\uc0c9]]! Swords.Combat.Bleeding=[[\ub179\uc0c9]] ** \uc801 \ucd9c\ud608 ** +Swords.Combat.Counter.Chance=[[RED]]\uce74\uc6b4\ud130 \uc5b4\ud0dd \ud655\ub960: [[YELLOW]]{0} Swords.Combat.Countered=[[GREEN]]**\uce74\uc6b4\ud130-\uacf5\uaca9** +Swords.Effect.0=\uce74\uc6b4\ud130 \uc5b4\ud0dd Swords.Listener=\uac80: +Swords.Skills.SS.Off=[[RED]]**Serrated Strikes \uc758 \ud6a8\uacfc\uac00 \ub05d\ub0a8** Swords.Skills.SS.On=[[\ub179\uc0c9]] ** \ud1b1\ub2c8 \ubaa8\uc591\uc758 \ud30c\uc5c5\uc774 \ud65c\uc131\ud654 ** Swords.Skills.SS.Other.Off=[[\ub808\ub4dc]] \ud1b1\ub2c8 \ubaa8\uc591\uc758 \uacbd\uace0 [[GREEN]]\uc5d0 \ub300\ud55c \ud6a8\ub825\uc774 [[\ub178\ub780\uc0c9]] {0} 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.1=\ub291\ub300\uac00 \uc704\ud5d8\uc744 \ud68c\ud53c\ud568 Taming.Ability.Bonus.2=\ub450\uaebc\uc6b4 \ubaa8\ud53c +Taming.Ability.Bonus.3=1/{0} \ub370\ubbf8\uc9c0, \ud654\uc5fc\uc800\ud56d +Taming.Ability.Locked.0=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (ENVIRONMENTALLY AWARE) +Taming.Ability.Locked.1=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (THICK FUR) +Taming.Ability.Locked.2=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (SHOCK PROOF) +Taming.Ability.Locked.3=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (SHARPENED CLAWS) +Taming.Ability.Locked.4=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (FAST FOOD SERVICE) +Taming.Ability.Locked.5=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (HOLY HOUND) +Taming.Combat.Chance.Gore=[[RED]]Gore \ud655\ub960: [[YELLOW]]{0} +Taming.Effect.11=\ud3ed\ubc1c \ud53c\ud574 \uac10\uc18c +Taming.Effect.14=[[GRAY]]COTW (Ocelot): {0} \uc0dd\uc120\uc744 \uc190\uc5d0 \ub4e4\uace0 \uc6c5\ud06c\ub9b0 \uc0c1\ud0dc(shift)\ub85c \uc88c\ud074\ub9ad +Taming.Effect.15=[[GRAY]]COTW (Wolf): {0} \ubf08\ub97c \uc190\uc5d0\ub4e4\uace0 \uc6c5\ud06c\ub9b0 \uc0c1\ud0dc(shift)\ub85c \uc88c\ud074\ub9ad +Taming.Effect.5=\ub370\ubbf8\uc9c0 \ubcf4\ub108\uc2a4 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}) +Taming.Summon.Fail.Ocelot=[[RED]]\uc8fc\ubcc0\uc5d0 \uc774\ubbf8 \uc624\uc140\ub86f\uc774 \ub108\ubb34 \ub9ce\uc544\uc11c \ub354\uc774\uc0c1 \ubd80\ub97c\uc218 \uc5c6\uc2b5\ub2c8\ub2e4. +Taming.Summon.Fail.Wolf=[[RED]]\uc8fc\ubcc0\uc5d0 \uc774\ubbf8 \ub291\ub300\uac00 \ub108\ubb34 \ub9ce\uc544\uc11c \ub354\uc774\uc0c1 \ubd80\ub97c\uc218 \uc5c6\uc2b5\ub2c8\ub2e4. +Unarmed.Ability.Berserk.Length=[[RED]]Berserk \uc9c0\uc18d\uc2dc\uac04: [[YELLOW]]{0}s +Unarmed.Ability.Chance.ArrowDeflect=[[RED]]\ud654\uc0b4 \ud68c\ud53c \ud655\ub960: [[YELLOW]]{0} +Unarmed.Ability.Chance.Disarm=[[RED]]\ubb34\uc7a5\ud574\uc81c \ud655\ub960: [[YELLOW]]{0} +Unarmed.Ability.Lower=[[GRAY]]**\uc8fc\uba39\uc744 \ub0b4\ub9bc** +Unarmed.Ability.Ready=[[GREEN]]**\uc8fc\uba39\uc744 \ub4ec** +Unarmed.Effect.0=Berserk (\ub2a5\ub825) +Unarmed.Effect.2=\ubb34\uc7a5\ud574\uc81c (Players) Unarmed.Listener=\ubb34\uae30 : Unarmed.SkillName=\ube44\ubb34\uc7a5 Unarmed.Skills.Berserk.Off=[[RED]]**\ubc84\uc11c\ud06c \ud574\uc81c** +Unarmed.Skills.Berserk.On=[[GREEN]]**BERSERK \ud65c\uc131\ud654\ub428** Unarmed.Skills.Berserk.Other.Off=[[\ub808\ub4dc]] \uad11\ud3ec \ud55c [[\ub179\uc0c9]]\uc5d0 \ub300\ud55c \ud6a8\ub825\uc774 [[\ub178\ub780\uc0c9]] {0} Unarmed.Skills.Berserk.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \ub294(\uc740) [[RED]]\ubc84\uc11c\ud06c[[DARK_GREEN]]\ub97c \uc0ac\uc6a9\ud588\ub2e4! +Unarmed.Skills.Berserk.Refresh=[[YELLOW]]Berserk [[GREEN]] \ub2a5\ub825\uc744 \ub2e4\uc2dc \uc0ac\uc6a9\ud560 \uc218 \uc788\uc74c! +Unarmed.Skillup=[[YELLOW]]\ube44\ubb34\uc7a5 \uae30\uc220\uc774 {0} \uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) Woodcutting.Ability.0=\ub098\ubb47\uc78e \uc1a1\ud48d Woodcutting.Ability.1=\uc78e\uc744 \ub0a0\ub824 +Woodcutting.Ability.Chance.DDrop=[[RED]]2\ubc30 \ub4dc\ub78d \ud655\ub960: [[YELLOW]]{0} +Woodcutting.Ability.Locked.0=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (LEAF BLOWER) +Woodcutting.Effect.1=\ub098\ubb34\uac00 \ud3ed\ubc1c\ud558\uac8c \ud568 +Woodcutting.Effect.4=\ub4dc\ub78d\ub960 2\ubc30 +Woodcutting.Listener=\ubc8c\ubaa9: Woodcutting.SkillName=\ubc8c\ubaa9 +Woodcutting.Skills.TreeFeller.On=[[GREEN]]**TREE FELLER \ud65c\uc131\ud654** +Woodcutting.Skills.TreeFeller.Refresh=[[YELLOW]]Tree Feller [[GREEN]]\uae30\uc220\uc744 \ub2e4\uc2dc \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4! Woodcutting.Skills.TreeFeller.Other.Off=[[\ub808\ub4dc]] \ud2b8\ub9ac \ud3a0\ub7ec [[\ub179\uc0c9]]\uc5d0 \ub300\ud55c \ud6a8\ub825\uc774 [[\ub178\ub780\uc0c9]] {0} Woodcutting.Skills.TreeFeller.Splinter=[[\ub808\ub4dc]] \ub2f9\uc2e0\uc758 \ub3c4\ub07c \uc870\uac01 \uc870\uac01 \uc218\uc2ed\uc73c\ub85c! +Woodcutting.Skills.TreeFellerThreshold=[[RED]]\uadf8 \ub098\ubb34\ub294 \ub108\ubb34 \ud07d\ub2c8\ub2e4! +Woodcutting.Skillup=[[YELLOW]]\ubc8c\ubaa9 \uae30\uc220\uc774 {0} \uc99d\uac00\ud588\uc2b5\ub2c8\ub2e4. \ucd1d ({1}) +Ability.Generic.Refresh=[[GREEN]]**\ub2a5\ub825\uc744 \ub2e4\uc2dc \uc0ac\uc6a9\ud560 \uc218 \uc788\uc74c!** Ability.Generic.Template.Lock=[[\ud68c\uc0c9]] {0} Ability.Generic.Template=[[\ubd89\uc740]]{0}: [[\ud669\uc0c9]]{1} Combat.BeastLore=[[GREEN]]**\uc9d0\uc2b9 \uc9c0\uc2dd** Combat.BeastLoreHealth=[[\uc5b4\ub450\uc6b4 \uc544\ucfe0\uc544]] \uac74\uac15 ([[\ub179\uc0c9]] {0} [[\uc5b4\ub450\uc6b4 \uc544\ucfe0\uc544]] / {1}) Combat.TouchedFuzzy=[[\uc5b4\ub450\uc6b4_\ubd89\uc740 \uc0c9]] \ud37c\uc9c0 \uc5b8\uae09\ud588\ub2e4. \ub514\uc9c0\uc744 \ub290\uaf08\ub2e4. +Commands.addlevels.AwardAll.2=[[RED]]\ubaa8\ub4e0 \uc2a4\ud0ac\uc774 {0}\uc73c\ub85c \uc218\uc815\ub428. Commands.Ability.Off=\ub2a5\ub825 \uc0ac\uc6a9 [[RED]]\ub054 +Commands.Ability.On=\ub2a5\ub825 \uc0ac\uc6a9 [[GREEN]] \ud0b4 Commands.AdminChat.Off=\uad00\ub9ac\uc790\ub9cc \ub300\ud654 \uae30\ub2a5 [[RED]]\ub054 Commands.AdminToggle=[[\ub808\ub4dc]] - \uc804\ud658 \uad00\ub9ac\uc790 \ucc44\ud305 +Commands.Chat.Console=*\ucf58\uc194* Commands.Disabled=[[\ub808\ub4dc]]\uc774 \uba85\ub839\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. Commands.DoesNotExist=[[RED]]\uc0ac\uc6a9\uc790\uac00 DB\uc5d0 \uc874\uc7ac\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4! Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode \ube44\ud65c\uc131\ud654 +Commands.GodMode.Enabled=[[YELLOW]]mcMMO Godmode \ud65c\uc131\ud654\ub428 +Commands.GodMode.Forbidden=[mcMMO] God Mode \ub294 \uc774 \uc6d4\ub4dc\uc5d0\uc11c \ud5c8\uc6a9\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4 (\ud37c\ubbf8\uc158 \ucc38\uace0) Commands.Invite.Accepted=[[\ub179\uc0c9]] \uc811\uc218 \ucd08\ub300\ud569\ub2c8\ub2e4. \ub2f9\uc2e0\uc740 \ud30c\ud2f0\uc5d0 \uc744 (\ub97c) \uac00\uc785 {0} +Commands.Invite.Success=[[GREEN]]\uc131\uacf5\uc801\uc73c\ub85c \ucd08\ub300\uac00 \ubc1c\uc1a1\ub428. +Commands.Leaderboards= [[RED]]- \uc21c\uc704\ud45c +Commands.mcc.Header=[[RED]]---[][[YELLOW]]mcMMO \uba85\ub839\uc5b4[[RED]][]--- +Commands.mcgod=[[RED]]- \uc2e0\ubaa8\ub4dc(GodMode) \ud1a0\uae00 +Commands.mchud.Invalid=[[RED]] \uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 HUD \ud0c0\uc785 +Commands.mcrank.Heading=[[GOLD]]-=\uac1c\uc778 \uc21c\uc704=- +Commands.mcremove.Success=[[GREEN]]{0} \ub294 \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0\uc11c \uc131\uacf5\uc801\uc73c\ub85c \uc81c\uac70\ub418\uc5c8\uc2b5\ub2c8\ub2e4! +Commands.mctop.Tip=[[GOLD]]Tip: [[RED]]/mcrank[[GOLD]] \ub97c \uc785\ub825\ud574\uc11c \ub2f9\uc2e0\uc758 \ub7ad\ud0b9\uc744 \ud655\uc778\ud558\uc138\uc694! Commands.mmoedit=[\ud50c\ub808\uc774\uc5b4] [[RED]] - \ubaa9\ud45c\ub97c \uc218\uc815 +Commands.mmoedit.AllSkills.1=[[GREEN]]\ub2f9\uc2e0\uc758 \ubaa8\ub4e0 \uc2a4\ud0ac\ub808\ubca8\uc774 {0} \uc73c\ub85c \uc124\uc815\ub418\uc5c8\uc2b5\ub2c8\ub2e4! +Commands.mmoedit.Modified.1=[[GREEN]]\ub2f9\uc2e0\uc758 {0}\ub808\ubca8\uc774 {1}\uc73c\ub85c \uc124\uc815\ub428! +Commands.mmoedit.Modified.2=[[RED]]{0} \uac00 {1} \ub85c \uc218\uc815\ub428. +Commands.ModDescription=[[RED]]- \uac04\ub7b5\ud55c \ubaa8\ub4dc \uc124\uba85 \uc77d\uae30 +Commands.NoConsole=\uc774 \uba85\ub839\uc5b4\ub294 \ucf58\uc194\uc5d0\uc11c \uc0ac\uc6a9\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. +Commands.Notifications.On=\ub2a5\ub825 \uc54c\ub9bc \ud1a0\uae00 [[GREEN]]on +Commands.Offline=[[RED]]\uc774 \uba85\ub839\uc5b4\ub294 \uc624\ud504\ub77c\uc778 \ud50c\ub808\uc774\uc5b4\uc5d0\uac8c \uc791\ub3d9\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. +Commands.Other=[[GREEN]]--\uae30\ud0c0 \uba85\ub839\uc5b4-- +Commands.Party.Status=[[DARK_GRAY]]\uc774\ub984: [[WHITE]]{0} {1} Commands.Party.Accept=[[RED]]- \ud30c\ud2f0 \ucd08\ub300 \uc218\ub77d +Commands.Party.Commands=[[GREEN]]--\ud30c\ud2f0 \uba85\ub839\uc5b4-- 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.Invite=[[RED]]- \ud30c\ud2f0 \ucd08\ub300 \ubcf4\ub0b4\uae30 +Commands.Party.Join=[[GRAY]]\uac00\uc785\uc911\uc778 \ud30c\ud2f0: {0} +Commands.Party.Create=[[GRAY]]\ub9cc\ub4e4\uc5b4\uc9c4 \ud30c\ud2f0: {0} +Commands.Party.Rename=[[GRAY]]\ud30c\ud2f0\uba85\uc774 \ub2e4\uc74c\uc73c\ub85c \ubcc0\uacbd\ub428: [[WHITE]]{0} +Commands.Party.AlreadyExists=[[DARK_RED]]\ud30c\ud2f0 {0} \uac00 \uc774\ubbf8 \uc874\uc7ac\ud569\ub2c8\ub2e4! +Commands.Party.Kick=[[RED]]\ub2f9\uc2e0\uc740 {0}\ud30c\ud2f0\uc5d0\uc11c \ud1f4\uc7a5\ub2f9\ud588\uc2b5\ub2c8\ub2e4! Commands.Party.Leave=[[\ub808\ub4dc]] \ub2f9\uc2e0\uc774 \ub0a8\uaca8 \ub450\uc5c8\ub358 \uadf8 \ub2f9\uc0ac\uc790 Commands.Party.None=[[RED]]\ud30c\ud2f0\uc5d0 \ub4e4\uc5b4\uac00 \uc788\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. +Commands.Party.Quit=\ud604\uc7ac \ud30c\ud2f0\ub97c \ub5a0\ub0a9\ub2c8\ub2e4. +Commands.Party.Teleport= [[RED]]- \ud30c\ud2f0 \uba64\ubc84\uc5d0\uac8c \ud154\ub808\ud3ec\ud2b8 +Commands.Party.Toggle=[[RED]]- \ud30c\ud2f0 \uccb4\ud305 \ud1a0\uae00 +Commands.Party1=[[RED]]- \uc0c8\ub85c\uc6b4 \ud30c\ud2f0 \uc0dd\uc131 +Commands.Party2=[[RED]]- \ud50c\ub808\uc774\uc5b4\uc758 \ud30c\ud2f0 \uac00\uc785 Commands.PowerLevel.Leaderboard=[[\ub178\ub780\uc0c9]] - mcMMO [[\ube14\ub8e8]] \ud30c\uc6cc \ub808\ubca8 [[\ub178\ub780\uc0c9]] \ub9ac\ub354 - +Commands.PowerLevel.Capped=[[DARK_RED]]\ud30c\uc6cc \ub808\ubca8: [[GREEN]]{0} [[DARK_RED]]\ucd5c\uace0 \ub808\ubca8: [[YELLOW]]{1} Commands.PowerLevel=[[DARK_RED]]\ud798 \ub808\ubca8: [[GREEN]]{0} +Commands.Reset.All=[[GREEN]]\ub2f9\uc2e0\uc758 \ubaa8\ub4e0 \uc2a4\ud0ac\ub808\ubca8\uc774 \uc131\uacf5\uc801\uc73c\ub85c \ub9ac\uc14b\ub418\uc5c8\uc2b5\ub2c8\ub2e4. +Commands.Reset.Single=[[GREEN]]\ub2f9\uc2e0\uc758 {0} \uc2a4\ud0ac \ub808\ubca8\uc774 \uc131\uacf5\uc801\uc73c\ub85c \ub9ac\uc14b\ub418\uc5c8\uc2b5\ub2c8\ub2e4. +Commands.Reset=[[RED]]\uc2a4\ud0ac\ub808\ubca8 0\uc73c\ub85c \ub9ac\uc14b +Commands.Skill.Invalid=[[RED]]\uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 \uc2a4\ud0ac \uc774\ub984! +Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] \uc21c\uc704\ud45c-- +Commands.SkillInfo=/ [[RED]]- \uc2a4\ud0ac \uc138\ubd80\uc124\uba85 \ubcf4\uae30 +Commands.Stats.Self=\ub2f9\uc2e0\uc758 \uc2a4\ud15f +Commands.Stats=[[RED]]- mcMMO \uc2a4\ud15f \ubcf4\uae30 +Commands.ToggleAbility=[[RED]]- \'\ub9c8\uc6b0\uc2a4 \uc6b0\ud074\ub9ad\uc73c\ub85c \ub2a5\ub825 \ud65c\uc131\ud654\' \ud1a0\uae00 +Commands.Usage.0=[[RED]]\uc62c\ubc14\ub978 \uc0ac\uc6a9\ubc95 /{0} +Commands.Usage.1=[[RED]]\uc62c\ubc14\ub978 \uc0ac\uc6a9\ubc95 /{0} {1} +Commands.Usage.2=[[RED]]\uc62c\ubc14\ub978 \uc0ac\uc6a9\ubc95 /{0} {1} {2} +Commands.Usage.3=[[RED]]\uc62c\ubc14\ub978 \uc0ac\uc6a9\ubc95 /{0} {1} {2} {3} +Commands.Usage.Message=\uba54\uc2dc\uc9c0 +Commands.Usage.Page=\ud398\uc774\uc9c0 +Commands.Usage.PartyName=\uc774\ub984 +mcMMO.NoPermission=[[DARK_RED]]\ubd80\uc801\ud569\ud55c \ud37c\ubbf8\uc158 +mcMMO.NoSkillNote=[[DARK_GRAY]]\uc811\uadfc \uad8c\ud55c\uc774 \uc5c6\ub294 \uc2a4\ud0ac\uc740 \ud45c\uc2dc\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. +Party.Forbidden=[mcMMO] \ud30c\ud2f0\ub294 \uc774 \uc6d4\ub4dc\uc5d0\uc11c \ud5c8\uc6a9\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4 (\ud37c\ubbf8\uc158 \ucc38\uace0) +Party.Help.0=[[RED]]\uc62c\ubc14\ub978 \uc0ac\uc6a9\ubc95 [[DARK_AQUA]]{0} [password]. +Party.Help.1=[[RED]]\ud30c\ud2f0 \uc0dd\uc131 \uba85\ub839\uc5b4 [[DARK_AQUA]]{0} [password]. +Party.Help.4=[[RED]]\ub2f9\uc2e0\uc758 \ud30c\ud2f0\ub97c \uc7a0\uadf8\uac70\ub098 \uc7a0\uae08\ud574\uc81c\ud558\uae30 \uc704\ud574 [[DARK_AQUA]]{0} \ub97c \uc0ac\uc6a9 +Party.Help.6=[[RED]]\ud50c\ub808\uc774\uc5b4\ub97c \ud30c\ud2f0\uc5d0\uc11c \ucd94\ubc29\ud558\uae30 \uc704\ud574, [[DARK_AQUA]]{0} \ub97c \uc785\ub825 +Party.InformedOnJoin={0} [[GREEN]]\uac00 \ub2f9\uc2e0\uc758 \ud30c\ud2f0\uc5d0 \uac00\uc785\ud588\uc2b5\ub2c8\ub2e4. +Party.InformedOnQuit={0} [[GREEN]]\uac00 \ub2f9\uc2e0\uc758 \ud30c\ud2f0\ub97c \ub5a0\ub0ac\uc2b5\ub2c8\ub2e4. +Party.InformedOnNameChange=[[GOLD]]{0} [[GREEN]]\uac00 \ud30c\ud2f0\uba85\uc744 [[WHITE]]{1}\uc73c\ub85c \uc124\uc815\ud588\uc2b5\ub2c8\ub2e4. +Party.InvalidName=[[DARK_RED]]\uc720\ud6a8\ud55c \ud30c\ud2f0\uba85\uc774 \uc544\ub2d9\ub2c8\ub2e4. +Party.Invite.Self=[[RED]]\uc790\uae30 \uc790\uc2e0\uc744 \ucd08\ub300\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4! +Party.IsLocked=[[RED]]\uc774 \ud30c\ud2f0\ub294 \uc774\ubbf8 \uc7a0\uaca8\uc788\uc2b5\ub2c8\ub2e4! +Party.IsntLocked=[[RED]]\uc774 \ud30c\ud2f0\ub294 \uc7a0\uaca8\uc788\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4! +Party.Locked=[[RED]]\ud30c\ud2f0\uac00 \uc7a0\uaca8\uc788\uc2b5\ub2c8\ub2e4, \ud30c\ud2f0\ub9ac\ub354\ub9cc\uc774 \ucd08\ub300\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. +Party.NotInYourParty=[[DARK_RED]]{0} \ub294 \ub2f9\uc2e0\uc758 \ud30c\ud2f0\uc5d0 \uc788\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. +Party.NotOwner=[[DARK_RED]]\ub2f9\uc2e0\uc740 \ud30c\ud2f0 \ub9ac\ub354\uac00 \uc544\ub2d9\ub2c8\ub2e4. +Party.Owner.New=[[GREEN]]{0} \ub294 \uc0c8\ub85c\uc6b4 \ud30c\ud2f0 \ub9ac\ub354\uc785\ub2c8\ub2e4. +Party.Owner.NotLeader=[[DARK_RED]]\ub2f9\uc2e0\uc740 \ub354\uc774\uc0c1 \ud30c\ud2f0 \ub9ac\ub354\uac00 \uc544\ub2d9\ub2c8\ub2e4. +Party.Owner.Player=[[GREEN]]\ub2f9\uc2e0\uc740 \uc774\uc81c \ud30c\ud2f0 \ub9ac\ub354\uc785\ub2c8\ub2e4 +Party.Password.Incorrect=[[RED]]\ud30c\ud2f0 \ud398\uc2a4\uc6cc\ub4dc \ud2c0\ub9bc Party.Password.Set={0}\uc5d0 [[\ub179\uc0c9]] \uc790 \uc554\ud638\uac00 \uc124\uc815 +Party.Password.Removed=[[GREEN]]\ud30c\ud2f0 \ube44\ubc00\ubc88\ud638 \uc81c\uac70\ub428 Party.Player.Invalid=[[\ub808\ub4dc]] \uadf8\uac74 \uc62c\ubc14\ub978 \ud50c\ub808\uc774\uc5b4\uac00 \uc544\ub2d9\ub2c8\ub2e4. +Party.NotOnline=[[DARK_RED]]{0} \ub294 \uc628\ub77c\uc778 \uc0c1\ud0dc\uac00 \uc544\ub2d9\ub2c8\ub2e4! +Party.Player.InSameParty=[[RED]]{0} \ub294 \uc774\ubbf8 \ub2f9\uc2e0\uc758 \ud30c\ud2f0\uc6d0\uc785\ub2c8\ub2e4. +Party.PlayerNotInParty=[[DARK_RED]]{0} \ub294 \ud30c\ud2f0\uc5d0 \uc18d\ud574\uc788\uc9c0 \uc54a\uc74c +Party.Specify=[[RED]]\ub2f9\uc2e0\uc740 \ud30c\ud2f0\ub97c \uc9c0\uc815\ud574\uc57c\ub9cc \ud569\ub2c8\ub2e4. Party.Teleport.Dead=[[RED]]\uc0ac\ub9dd\ud55c \ud50c\ub808\uc774\uc5b4\uc5d0\uac8c \ud154\ub808\ud3ec\ud2b8 \ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. +Party.Teleport.Hurt=[[RED]]\ub2f9\uc2e0\uc740 {0} \ucd08\uc804\uc5d0 \ubd80\uc0c1\uc744 \uc785\uc5c8\uc73c\uba70 \ud154\ub808\ud3ec\ud2b8 \ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. +Party.Teleport.Player=[[GREEN]]\ub2f9\uc2e0\uc740 {0}\uc73c\ub85c \ud154\ub808\ud3ec\ud2b8 \ud588\uc2b5\ub2c8\ub2e4. +Party.Teleport.Self=[[RED]]\ub2f9\uc2e0\uc5d0\uac8c \ud154\ub808\ud3ec\ud2b8 \ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4! Party.Teleport.Target=[[\ub179\uc0c9]] {0} \ub2f9\uc2e0\uc5d0\uac8c \uc21c\uac04 \uc774\ub3d9\ud588\uc2b5\ub2c8\ub2e4. -Party.Unlocked=[[\ud68c\uc0c9]] \ud30c\ud2f0\ub294 \uc7a0\uae08 \ud574\uc81c +Party.Rename.Same=[[RED]]\ud604\uc7ac \ud30c\ud2f0\uba85\uacfc \ub3d9\uc77c\ud569\ub2c8\ub2e4! +Party.Join.Self=[[RED]]\ub2f9\uc2e0 \uc2a4\uc2a4\ub85c \uac00\uc785\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4! +Party.Unlocked=[[GRAY]]\ud30c\ud2f0\uac00 \uc7a0\uae08 \ud574\uc81c\ub428 +Party.Disband=[[GRAY]]\ud30c\ud2f0\uac00 \ud574\uc0b0\ub42c\uc2b5\ub2c8\ub2e4. +Party.ExpShare.Disabled=[[RED]]\ud30c\ud2f0 \uacbd\ud5d8\uce58 \uacf5\uc720 \ube44\ud65c\uc131\ud654 +Party.ItemShare.Disabled=[[RED]]\ud30c\ud2f0 \uc544\uc774\ud0ec \uacf5\uc720 \ube44\ud65c\uc131\ud654 Commands.XPGain.Excavation=\ubcf4\ubb3c\uc744 \ubc1c\uad74\ud558\uace0 \ucc3e\ub294 -Commands.XPGain.Herbalism=\uc218\ud655 \ud5c8\ube0c -Commands.XPGain.Mining=\uad11\uc5c5 \uc11d\uc7ac \ubc0f \uad11\uc11d +Commands.XPGain.Fishing=\ub09a\uc2dc (\uc54c\uc544\ubcf4\uc138\uc694!) +Commands.XPGain.Herbalism=\ud5c8\ube0c \uc218\ud655 +Commands.XPGain.Mining=\ub3cc\uc774\ub098 \uad11\ubb3c\uc744 \ucc44\uad11 +Commands.XPGain.Repair=\uc218\ub9ac Commands.XPGain.Swords=\uacf5\uaca9 \ubaac\uc2a4\ud130 Commands.XPGain.Taming=\ub3d9\ubb3c \uae38\ub4e4\uc774\uae30, \ub610\ub294 \uc804\ud22c w / \uadc0\ud558\uc758 \ub291\ub300 -Commands.XPGain=[[\uc5b4\ub450\uc6b4 \ud68c\uc0c9]] XP \uac8c\uc778 : [[\ud770\uc0c9]] {0} +Commands.XPGain=[[DARK_GRAY]]XP \ud68d\ub4dd: [[WHITE]]{0} +Commands.xplock.locked=[[GOLD]]\ub2f9\uc2e0\uc758 \uacbd\ud5d8\uce58 \ubc14\uac00 {0}\uc73c\ub85c \uace0\uc815\ub42c\uc2b5\ub2c8\ub2e4! +Commands.xplock.unlocked=[[GOLD]]\ub2f9\uc2e0\uc758 \uacbd\ud5d8\uce58 \ubc14\uac00 [[GREEN]]\uc7a0\uae08 \ud574\uc81c\ub428[[GOLD]]! +Commands.xprate.modified=[[RED]]\uacbd\ud5d8\uce58\ub960\uc774 {0}\uc73c\ub85c \uc218\uc815\ub428 +Commands.xprate.over=[[RED]]mcMMO XP Rate \uc774\ubca4\ud2b8\uac00 \ub05d\ub0ac\uc2b5\ub2c8\ub2e4!! +Commands.xprate.proper.0=[[RED]]\uacbd\ud5d8\uce58\ub960 \ubcc0\uacbd\uc758 \uc62c\ubc14\ub978 \uc0ac\uc6a9\ubc95 /xprate +Commands.xprate.proper.1=[[RED]]\'\uacbd\ud5d8\uce58\ub960 \uae30\ubcf8\uac12\uc73c\ub85c \ubcf5\uad6c\' \uba85\ub839\uc5b4\uc758 \uc62c\ubc14\ub978 \uc0ac\uc6a9\ubc95: /xprate reset +Commands.xprate.started.0=[[GOLD]]XP EVENT \uac00 \uc2dc\uc791\ub428! +Commands.xprate.started.1=[[GOLD]]mcMMO \uacbd\ud5d8\uce58\ub960\uc740 \uc774\uc81c {0}x \uc784! XPRate.Event=[[GOLD]]mcMMO \ub294 \ud604\uc7ac {0}\ubc30 \uacbd\ud5d8\uce58 \uc774\ubca4\ud2b8 \uc911\uc785\ub2c8\ub2e4! Effects.Effects=\ud6a8\uacfc -Guides.Excavation=[[\uc5b4\ub450\uc6b4 \uc544\ucfe0\uc544]] \ubc1c\uad74 \uc18c\uac1c :\n[[\ub178\ub780\uc0c9]] \ubc1c\uad74\uc774 \ubcf4\ubb3c\uc744 \ucc3e\uae30 \uc704\ud574 \ud759\uc744 \ud30c\uace0 \ud589\uc704\uc785\ub2c8\ub2e4.\n[[\ub178\ub780\uc0c9]] \ub2f9\uc2e0\uc774 \ubcf4\ubb3c\uc744 \ubc1c\uacac \ud560 \uac83\uc774\ub2e4 \ub545\uc744 \ubc1c\uad74\ud558\uc5ec.\n[[YELLOW]] \ub354 \ub2f9\uc2e0\uc774 \ub2f9\uc2e0\uc774 \ucc3e\uc744 \uc218\uc788\ub294 \ub354 \ub9ce\uc740 \ubcf4\ubb3c\uc744.\n\n[[\uc5b4\ub450\uc6b4 \uc544\ucfe0\uc544]] XP\uc758 \uac8c\uc778 :\n[[\ub178\ub780\uc0c9]] \ub2f9\uc2e0\uc774 \uc190\uc5d0 \uc0bd\uc73c\ub85c \ud30c \ub9cc\uc774\uc774 \uae30\uc220\uc5d0 XP\ub97c \uc5bb\uc744 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n[[\ub178\ub780\uc0c9]] \ub9cc \ud2b9\uc815 \ubb3c\uc9c8\uc774 \ubcf4\ubb3c\uacfc XP\uc5d0 \ud30c \ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n[[\uc5b4\ub450\uc6b4 \uc544\ucfe0\uc544]] \ud638\ud658 \uac00\ub2a5 \uc790\ub8cc :\n[[\ub178\ub780\uc0c9]] \uc794\ub514, \ud759, \ubaa8\ub798, \uc810\ud1a0, \uc790\uac08, \uade0\uc0ac\uccb4, \uc601\ud63c\uc758 \ubaa8\ub798\n\n[[\uc5b4\ub450\uc6b4 \uc544\ucfe0\uc544]] \uc5b4\ub5bb\uac8c \uae30\uac00 \ud6c8\ub828 \ucc28\ub2e8\uae30\ub97c \uc0ac\uc6a9\ud558\ub824\uba74 \ub2e4\uc74c \ub2e8\uacc4\ub97c \ub530\ub974\uc2ed\uc2dc\uc624\n[[\ub178\ub780\uc0c9]] \uc190\uc5d0 \uc0bd\uc73c\ub85c \ubc14\ub85c \uc900\ube44\ud558\uc5ec \ub3c4\uad6c\ub97c \ud074\ub9ad\ud569\ub2c8\ub2e4.\n[[\ub178\ub780\uc0c9]] \uc77c\ub2e8\uc774 \uc0c1\ud0dc\uc5d0\uc11c \ub2f9\uc2e0\uc740 \ud560\uc5d0 \ub300\ud55c \uc0ac\ucd08\uc774\n\uc774 \uc758\uc9c0 [[\ub178\ub780\uc0c9]] \ubc1c\uad74\uacfc \uc811\ucd09 \ud638\ud658 \uc790\ub8cc\n[[\ub178\ub780\uc0c9]] \ud65c\uc131\ud654 \uae30\uac00 \ud6c8\ub828 \ucc28\ub2e8\uae30.\n[[\uc5b4\ub450\uc6b4 \uc544\ucfe0\uc544]] \uae30\uac00 \ud6c8\ub828 \ucc28\ub2e8\uae30\ub294 \ubb34\uc5c7\uc785\ub2c8\uae4c?\n[[\ub178\ub780\uc0c9]] \uae30\uac00 \ub4dc\ub9b4 \ube0c\ub808\uc774\ud06c\ub294 \uc7ac\uc0ac\uc6a9 \ub300\uae30 \uc2dc\uac04\uc774\uc788\ub294 \uae30\ub2a5\uc785\ub2c8\ub2e4\n[[\ub178\ub780\uc0c9]] \ubc1c\uad74 \uae30\uc220\uc5d0 \ubb36\uc5ec. \uc774 \ud2b8\ub9ac\ud50c \uae30\ud68c\ub97c\n[[\ub178\ub780\uc0c9]] \ubcf4\ubb3c\uc744 \ucc3e\ub294\uacfc \uc778\uc2a4\ud134\ud2b8 \ud734\uc2dd\uc744 \uac00\ub2a5\ud558\uac8c\n[[\ub178\ub780\uc0c9]] \ubc1c\uad74 \uc790\ub8cc\uc5d0.\n\n[[\uc5b4\ub450\uc6b4 \uc544\ucfe0\uc544]] \uc5b4\ub5bb\uac8c \ubcf4\ubb3c \uc0ac\ub0e5\uafbc \uc791\ub3d9\ud569\ub2c8\uae4c?\n[[\ub178\ub780\uc0c9]] \ubc1c\uad74\uc5d0 \ub300\ud55c \ubaa8\ub4e0 \uac00\ub2a5\ud55c \ubcf4\ubb3c \uc790\uccb4\uac00\n[[\ub178\ub780\uc0c9]] \uacb0\uacfc\ub85c \ub5a8\uc5b4\ud558\uae30\uc704\ud55c \uae30\uc220 \uc218\uc900 \uc694\uad6c, \uadf8\uac74\n[[\ub178\ub780\uc0c9]] \ub2f9\uc2e0\uc744 \ub3d5\ub294 \uc5bc\ub9c8\ub098 \ub9ce\uc740 \ub9d0\uc744 \uc5b4\ub835\ub2e4.\n[[\ub178\ub780\uc0c9]] \ub9c8\uc74c\uc744 \ub450\ub294 \uac83\uc774 \ub192\uc744 \ubc1c\uad74 \uae30\uc220\n[[\ub178\ub780\uc0c9]]\uc774\uba70, \ucc3e\uc744 \uc218\uc788\ub294 \ub354 \ub9ce\uc740 \ubcf4\ubb3c.\n[[\ub178\ub780\uc0c9]] \ub610\ud55c \uc5fc\ub450\uc5d0 \ub450\uc5b4\uc57c \uadf8 \ubc1c\uad74\uc758 \uac01 \uc720\ud615\n[[\ub178\ub780\uc0c9]] \ud638\ud658 \uc18c\uc7ac \ubcf4\ubb3c \uace0\uc720 \ubaa9\ub85d\uc774 \uc788\uc2b5\ub2c8\ub2e4.\n[[\ub178\ub780\uc0c9]] \uc989 \ub2f9\uc2e0\uc740 \uba3c\uc9c0\uc5d0 \ub2e4\ub978 \ubcf4\ubb3c\uc744 \ucc3e\uc744 \uc218 \uc788\uc2b5\ub2c8\ub2e4\n[[\ub178\ub780\uc0c9]] \ub2f9\uc2e0\uc740 \uc790\uac08\uc5d0\uc11c\uc640\ubcf4\ub2e4.\n[[\uc5b4\ub450\uc6b4 \uc544\ucfe0\uc544]] \ubc1c\uad74\uc5d0 \ub300\ud55c \ucc38\uace0 \uc0ac\ud56d :\n[[\ub178\ub780\uc0c9]] \ubc1c\uad74 \ubc29\uc6b8 \uc644\uc804\ud788 \uc0ac\uc6a9\uc790 \uc815\uc758 \uc544\ub974\n[[\ub178\ub780\uc0c9]] \uc9c0\uae08 \uacb0\uacfc\uac00 \uc11c\ubc84\uc5d0 \uc11c\ubc84\ub97c \ub2e4\ub97c \uc218 \uc788\uc2b5\ub2c8\ub2e4. -Skills.Disarmed=[[DARK_RED]]\ud604\uc7ac \ubb34\uc7a5\ud574\uc81c \ub410\uc2b5\ub2c8\ub2e4! +Effects.Level=[[DARK_GRAY]]\ub808\ubca8: [[GREEN]]{0} [[DARK_AQUA]]\uacbd\ud5d8\uce58[[YELLOW]]([[GOLD]]{1}[[YELLOW]]/[[GOLD]]{2}[[YELLOW]]) +Effects.Template=[[DARK_AQUA]]{0}: [[GREEN]]{1} +Guides.Mining=[[DARK_AQUA]]\ucc44\uad11(Mining)\uc5d0 \ub300\ud574:\n[[YELLOW]]\ub3cc\ub9f9\uc774\uc640 \uad11\ubb3c\uc744 \uce90\ub294 \uac83\uc774\ub2e4.\n[[YELLOW]]\ucc44\uad11\uc73c\ub85c \uc5bb\ub294 \uc544\uc774\ud0ec\uc758 \uc591\uc5d0 \ubcf4\ub108\uc2a4\uac00 \uc788\ub2e4.\n[[DARK_AQUA]]\uacbd\ud5d8\uce58 \ud68d\ub4dd:\n[[YELLOW]]\ucc44\uad11 \uae30\uc220\uc758 \uacbd\ud5d8\uce58 \ud68d\ub4dd\uc744 \uc704\ud574, \uace1\uad2d\uc774\ub97c \ub4e4\uace0 \uc788\uc5b4\uc57c \ud55c\ub2e4\n[[YELLOW]]\ud2b9\uc815 \ube14\ub7ed\ub9cc\uc774 \uacbd\ud5d8\uce58\ub97c \uc900\ub2e4\n[[DARK_AQUA]]\uc778\uc815\ub418\ub294 \ube14\ub7ed:\n[[YELLOW]]\ub3cc, \uc11d\ud0c4\uad11\uc11d, \ucca0 \uad11\uc11d, \uae08 \uad11\uc11d, \ub2e4\uc774\uc544 \uad11\uc11d, \ub808\ub4dc\uc2a4\ud1a4 \uad11\uc11d,\n[[YELLOW]]\uccad\uae08\uc11d \uad11\uc11d, \uc635\uc2dc\ub514\uc5b8, \uc774\ub07c\ub080 \ucf54\ube14\uc2a4\ud1a4, \uc5d4\ub354\uc2a4\ud1a4,\n[[YELLOW]]\ubc1c\uad11\uc11d, and \ub124\ub354\ub809.\n[[DARK_AQUA]]Super Breaker \uc0ac\uc6a9\ubc95:\n[[YELLOW]]\uace1\uad2d\uc774\ub97c \ub4e4\uace0, \ub9c8\uc6b0\uc2a4 \uc6b0\ud074\ub9ad\uc73c\ub85c \uc900\ube44\ud55c\ub2e4.\n[[YELLOW]]\uc774 \uc0c1\ud0dc\uc5d0\uc11c, \uc57d 4\ucd08\uc548\uc5d0 \uad11\ubb3c\uc744 \ud074\ub9ad\ud558\uba74,\n[[YELLOW]]Super Breaker \ub97c \uc0ac\uc6a9\ud558\uac8c \ub41c\ub2e4.\n[[DARK_AQUA]]Super Breaker\ub780?\n[[YELLOW]]\ucfe8\ub2e4\uc6b4 \uc2dc\uac04\uc744 \uac00\uc9c4 \ucc44\uad11 \uae30\uc220\uc774\ub2e4\n[[YELLOW]]\uc544\uc774\ud0ec \ub4dc\ub78d\ub960\uc744 3\ubc30\ub85c \uc62c\ub824\uc8fc\uace0 \uad11\ubb3c\uc744 \uc989\uc2dc \ubd80\uc21c\ub2e4.\n[[DARK_AQUA]]Blast Mining \uc0ac\uc6a9\ubc95:\n[[YELLOW]]\uae30\ubcf8\uc801\uc73c\ub85c \ubd80\uc2ef\ub3cc& \ucca0 \uc778 detonator\ub97c \uc190\uc5d0 \ub4e4\uace0\n[[YELLOW]]\uc6d0\uac70\ub9ac\uc5d0\uc11c \uc6c5\ud06c\ub9b0\uc0c1\ud0dc\ub85c TNT\ub97c \uc6b0\ud074\ub9ad\ud55c\ub2e4.\n[[YELLOW]]\uc774\uac83\uc740 TNT\uac00 \uc989\uc2dc \ud3ed\ubc1c\ud558\uac8c \ud55c\ub2e4\n[[DARK_AQUA]]Blast Mining \uc758 \uc791\ub3d9\ubc29\uc2dd\n[[YELLOW]]Blast Mining \uc740 \ucfe8\ub2e4\uc6b4 \uc2dc\uac04\uc744 \uac00\uc9c4 \ucc44\uad11 \uae30\uc220\uc774\ub2e4\n[[YELLOW]]TNT\ub85c \ucc44\uad11\ud560\ub54c \ubcf4\ub108\uc2a4\ub97c \uc8fc\uace0 TNT\ub97c \uc6d0\uac70\ub9ac\uc5d0\uc11c\n[[YELLOW]]\uc791\ub3d9\uc2dc\ud0ac\uc218 \uc788\uac8c \ud55c\ub2e4. Blast Mining\uc5d0\ub294 \uc138\uac00\uc9c0\uac00 \uc788\ub2e4.\n[[YELLOW]]\uccab\ubc88\uc9f8\ub294 Bigger Bombs\uc73c\ub85c \ud3ed\ud30c \ubc18\uacbd\uc744 \ub113\ud600\uc900\ub2e4.\n[[YELLOW]]\ub450\ubc88\uc9f8\ub294 Demolitions Expert \uc73c\ub85c TNT\ub85c \uc785\ub294 \ud53c\ud574\ub97c\n[[YELLOW]]\uc904\uc5ec\uc900\ub2e4. \uc138\ubc88\uc9f8\ub294 \ub2e8\uc21c\ud788 TNT\ud3ed\ubc1c\ub85c \uc5bb\ub294 \uad11\ubb3c\uc758 \uc591\uc744\n[[YELLOW]]\ub298\ub9ac\uace0 \uc794\ud574\uc758 \uc591\uc740 \uc904\uc5ec\uc900\ub2e4. +Guides.Page.Invalid=\uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 \ud398\uc774\uc9c0 \uc22b\uc790! +Guides.Usage=[[RED]] \uc0ac\uc6a9\ubc95 /{0} ? [\ud398\uc774\uc9c0] +Inspect.Offline=[[RED]]\ub2f9\uc2e0\uc740 \uc624\ud504\ub77c\uc778 \ud50c\ub808\uc774\uc5b4\ub97c \uc870\uc0ac\ud560 \uad8c\ud55c\uc774 \uc5c6\uc2b5\ub2c8\ub2e4! +Inspect.OfflineStats=\uc624\ud504\ub77c\uc778 \ud50c\ub808\uc774\uc5b4\uc758 mcMMO \uc2a4\ud15f [[YELLOW]]{0} +Inspect.TooFar=[[RED]]\uadf8 \ud50c\ub808\uc774\uc5b4\ub97c \uc870\uc0ac\ud558\uae30\uc5d4 \ub108\ubb34 \uba40\ub9ac \ub5a8\uc5b4\uc838 \uc788\uc2b5\ub2c8\ub2e4! +Item.Injured.Wait=\ub2f9\uc2e0\uc740 \ucd5c\uadfc\uc5d0 \ubd80\uc0c1\uc744 \uc785\uc5c8\uace0, \uc774\uac83\uc744 \ub2e4\uc2dc \uc774\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 \uae30\ub2e4\ub824\uc57c \ud569\ub2c8\ub2e4. [[YELLOW]]({0}s) +Skills.Disarmed=[[DARK_RED]]\ub2f9\uc2e0\uc740 \ubb34\uc7a5 \ud574\uc81c\ub42c\uc2b5\ub2c8\ub2e4! +Skills.NeedMore=[[DARK_RED]]\ub2f9\uc2e0\uc740 [[GRAY]]{0}\uc774 \ub354 \ud544\uc694\ud569\ub2c8\ub2e4. +Skills.Stats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] \uacbd\ud5d8\uce58([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]]) +Skills.TooTired=[[RED]]\ub2f9\uc2e0\uc740 \uadf8 \ub2a5\ub825\uc744 \ub2e4\uc2dc \uc0ac\uc6a9\ud558\uae30\uc5d4 \ub108\ubb34 \uc9c0\ucce4\uc2b5\ub2c8\ub2e4 [[YELLOW]]({0}s) Stats.Header.Combat=[[\uae08]] - = \uc804\ud22c \uc2a4\ud0ac = - -Stats.Header.Gathering=[[GOLD]]-=\uae30\uc220 \uc218\uc9d1=- +Stats.Header.Gathering=[[GOLD]]-=\uc218\uc9d1 \uae30\uc220\ub4e4=- +Stats.Header.Misc=[[GOLD]]-=\uae30\ud0c0 \uae30\uc220=- Stats.Own.Stats=[[GREEN]][mcMMO] \uc0c1\ud0dc +Perks.xp.name=\uacbd\ud5d8\uce58 +Perks.xp.desc={0}x \uacbd\ud5d8\uce58 \ud68d\ub4dd +Perks.lucky.name=\ud589\uc6b4 +Perks.cooldowns.name=\ube60\ub978 \ud68c\ubcf5 +Hardcore.Disabled=[[GOLD]][mcMMO] \ud558\ub4dc\ucf54\uc5b4 \ube44\ud65c\uc131\ud654 +Hardcore.Enabled=[[GOLD]][mcMMO] \ud558\ub4dc\ucf54\uc5b4 \ud65c\uc131\ud654 +Spout.Donate=[[YELLOW]][mcMMO] \uae30\ubd80! +Spout.Menu.HudButton.1=HUD \ud0c0\uc785: {0} +Spout.Menu.HudButton.2=HUD \uc2a4\ud0c0\uc77c \ubcc0\uacbd! +Spout.Menu.Title=[[GOLD]]~mcMMO \uba54\ub274~ +MOTD.Donate=[[DARK_AQUA]]\uae30\ubd80 \uc815\ubcf4: +MOTD.Hardcore.Stats=[[GOLD]][mcMMO] [[DARK_AQUA]]\uc0ac\ub9dd\uc2dc \uc2a4\ud0ac \ud398\ub110\ud2f0: [[DARK_RED]]{0}% +MOTD.Hardcore.VampireOn=[[GOLD]][mcMMO] [[DARK_RED]]\ud558\ub4dc\ucf54\uc5b4 \ud65c\uc131\ud654\ub428 +Smelting.Ability.Locked.0=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (VANILLA XP BOOST) +Smelting.Ability.Locked.1=\uc7a0\uae40. \uc694\uad6c\uc870\uac74: {0}+ SKILL (FLUX MINING) +Smelting.Ability.SecondSmelt=[[RED]]Second Smelt \ud655\ub960: [[YELLOW]]{0} +Smelting.Effect.1=\uc81c\ub828\uc2dc \uc5f0\ub8cc\uac00 \ud0c0\ub294 \uc2dc\uac04 2\ubc30 +Smelting.Effect.3=\uc81c\ub828\uc73c\ub85c \uc5bb\ub294 \uc790\uc6d0 2\ubc30 +Commands.Description.addlevels=\uc720\uc800\uc5d0\uac8c mcMMO \ub808\ubca8 \ucd94\uac00 +Commands.Description.hardcore=\ud558\ub4dc\ucf54\uc5b4 \ube44\uc728 \uc218\uc815 \ub610\ub294 \ud558\ub4dc\ucf54\uc5b4 on/off \uc124\uc815 +Commands.Description.inspect=\ub2e4\ub978 \ud50c\ub808\uc774\uc5b4\uc758 \uc138\ubd80 mcMMO \uc815\ubcf4 \ubcf4\uae30 +Commands.Description.mchud=\ub2f9\uc2e0\uc758 mcMMO HUD \uc2a4\ud0c0\uc77c \ubcc0\uacbd +Commands.Description.mcmmo=mcMMO\uc5d0 \ub300\ud55c \uac04\ub7b5\ud55c \uc124\uba85 \ubcf4\uae30 +Commands.Description.mcremove=mcMMO \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0\uc11c \uc720\uc800 \uc0ad\uc81c +Commands.Description.mcstats=\ub2f9\uc2e0\uc758 mcMMO \ub808\ubca8\uacfc \uacbd\ud5d8\uce58 \ubcf4\uae30 +Commands.Description.mctop=mcMMO \uc21c\uc704\ud45c \ubcf4\uc774\uae30 +Commands.Description.mmoedit=\uc720\uc800\uc758 mcMMO \ub808\ubca8 \uc218\uc815 +Commands.Description.mmoupdate=mcMMO \ub370\uc774\ud130\ubca0\uc774\uc2a4\ub97c Flatfile \uc5d0\uc11c MySQL \uc73c\ub85c \ubcc0\ud658 +Commands.Description.ptp=mcMMO \ud30c\ud2f0\uba64\ubc84\uc5d0\uac8c \ud154\ub808\ud3ec\ud2b8 +Commands.Description.skillreset=\uc720\uc800\uc758 mcMMO \ub808\ubca8 \ub9ac\uc14b +UpdateChecker.outdated=\ub2f9\uc2e0\uc740 \uad6c\ubc84\uc804\uc758 mcMMO\ub97c \uc0ac\uc6a9\uc911\uc785\ub2c8\ub2e4! +UpdateChecker.newavailable=BukkitDev \uc5d0 \uc2e0\ubc84\uc804\uc774 \uc874\uc7ac\ud569\ub2c8\ub2e4. diff --git a/src/main/resources/locale/locale_nl.properties b/src/main/resources/locale/locale_nl.properties index cdf129908..1ff3461d6 100644 --- a/src/main/resources/locale/locale_nl.properties +++ b/src/main/resources/locale/locale_nl.properties @@ -145,7 +145,6 @@ 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 diff --git a/src/main/resources/locale/locale_ru.properties b/src/main/resources/locale/locale_ru.properties index c5442e453..5d70fe6ae 100644 --- a/src/main/resources/locale/locale_ru.properties +++ b/src/main/resources/locale/locale_ru.properties @@ -401,7 +401,6 @@ Commands.Party.AlreadyExists=[[DARK_RED]]\u0413\u0440\u0443\u043f\u043f\u0430 {0 Commands.Party.Kick=[[RED]]\u0412\u044b \u0432\u044b\u0433\u043d\u0430\u043d\u044b \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b {0}! Commands.Party.Leave=[[RED]]\u0412\u044b \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 Commands.Party.Members.Header=[[RED]]-----[][[GREEN]]\u0423\u0427\u0410\u0421\u0422\u041d\u0418\u041a\u0418[[RED]][]----- -Commands.Party.Members={0} Commands.Party.None=[[RED]]\u0412\u044b \u043d\u0435 \u0432 \u0433\u0440\u0443\u043f\u043f\u0435. Commands.Party.Quit=[[RED]]- \u041f\u043e\u043a\u0438\u043d\u0443\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0443 Commands.Party.Teleport= [[RED]]- \u0422\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a \u0447\u043b\u0435\u043d\u0443 \u0433\u0440\u0443\u043f\u043f\u044b @@ -606,6 +605,7 @@ Commands.Description.mctop=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u04 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.ptp=\u0422\u0435\u043b\u0435\u043f\u043e\u0440\u0442 \u043a mcMMO \u0447\u043b\u0435\u043d\u0430\u043c \u0433\u0440\u0443\u043f\u043f\u044b 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 diff --git a/src/main/resources/locale/locale_zh_TW.properties b/src/main/resources/locale/locale_zh_TW.properties index 36b0f1c4a..e9dc11cf7 100644 --- a/src/main/resources/locale/locale_zh_TW.properties +++ b/src/main/resources/locale/locale_zh_TW.properties @@ -384,7 +384,6 @@ Commands.Party.SetSharing=[[GRAY]]\u968a\u4f0d {0} \u5206\u4eab\u8a2d\u5b9a\u70b 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 Commands.Party.Teleport= [[RED]]- \u50b3\u9001\u5230\u968a\u4f0d\u6210\u54e1\u65c1 From c3a69c8c55dc114c97be9e80922b0c74e8f638d3 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 20 Mar 2013 02:15:15 -0400 Subject: [PATCH 93/94] Change to the newer, shorter scheduler methods. --- .../gmail/nossr50/database/DatabaseManager.java | 2 +- .../gmail/nossr50/listeners/BlockListener.java | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 16 ++++++++-------- .../gmail/nossr50/runnables/SaveTimerTask.java | 2 +- .../commands/McrankCommandAsyncTask.java | 2 +- .../commands/MctopCommandAsyncTask.java | 2 +- .../nossr50/skills/archery/TrackedEntity.java | 2 +- .../com/gmail/nossr50/util/HolidayManager.java | 2 +- .../conversion/BlockStoreConversionMain.java | 2 +- .../BlockStoreConversionXDirectory.java | 2 +- .../BlockStoreConversionZDirectory.java | 2 +- .../gmail/nossr50/util/skills/CombatUtils.java | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index be90bc083..45cba591a 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -336,7 +336,7 @@ public final class DatabaseManager { 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 SQLReconnectTask(), 5); + mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new SQLReconnectTask(), 5); } nextReconnectTimestamp = 0; reconnectAttempt = 0; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 1aacc2dfb..0998b3cb1 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -88,7 +88,7 @@ public class BlockListener implements Listener { 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 StickyPistonTrackerTask(event), 2); + plugin.getServer().getScheduler().runTaskLater(plugin, new StickyPistonTrackerTask(event), 2); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index b0b45defc..9381d9c73 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -405,39 +405,39 @@ public class mcMMO extends JavaPlugin { 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); + scheduler.runTaskLater(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); + scheduler.runTaskTimer(this, new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks); // Regen & Cooldown timer (Runs every second) - scheduler.scheduleSyncRepeatingTask(this, new SkillMonitorTask(), 20, 20); + scheduler.runTaskTimer(this, new SkillMonitorTask(), 20, 20); // Bleed timer (Runs every two seconds) - scheduler.scheduleSyncRepeatingTask(this, new BleedTimerTask(), 40, 40); + scheduler.runTaskTimer(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. + scheduler.runTaskLater(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); + scheduler.runTaskTimer(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. + scheduler.runTaskLater(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); + scheduler.runTaskTimer(this, new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java index 8a1af3760..1b1aaaf79 100644 --- a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java @@ -16,7 +16,7 @@ public class SaveTimerTask implements Runnable { BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler(); for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) { - bukkitScheduler.scheduleSyncDelayedTask(mcMMO.p, new PlayerProfileSaveTask(mcMMOPlayer), count); + bukkitScheduler.runTaskLater(mcMMO.p, new PlayerProfileSaveTask(mcMMOPlayer), count); count++; } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java index 27ad089bb..eb7338320 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -25,7 +25,7 @@ public class McrankCommandAsyncTask implements Runnable { public void run() { final Map skills = DatabaseManager.readSQLRank(playerName); - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() { @Override public void run() { sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java index 085974058..1d35f68ab 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java @@ -28,7 +28,7 @@ public class MctopCommandAsyncTask implements Runnable { public void run() { String tablePrefix = Config.getInstance().getMySQLTablePrefix(); 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"); - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() { @Override public void run() { if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { 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 267f80ba9..c6faab97e 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java @@ -18,7 +18,7 @@ public class TrackedEntity implements Runnable { this.livingEntity = livingEntity; this.id = livingEntity.getUniqueId(); this.scheduler = mcMMO.p.getServer().getScheduler(); - this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000); + this.taskId = scheduler.runTaskTimer(mcMMO.p, this, 12000, 12000).getTaskId(); } @Override diff --git a/src/main/java/com/gmail/nossr50/util/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java index c0ddfd63a..61eda995f 100644 --- a/src/main/java/com/gmail/nossr50/util/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java @@ -97,7 +97,7 @@ public final class HolidayManager { final int firework_amount = 10; for (int i = 0; i < firework_amount; i++) { int delay = (int) (Math.random() * 3) + 4; - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() { @Override public void run() { spawnFireworks((Player) sender); 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 e1ddd4b2f..599f25477 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 @@ -28,7 +28,7 @@ public class BlockStoreConversionMain implements Runnable { return; } - this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); + this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); 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 89465df4d..0f705d286 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 @@ -29,7 +29,7 @@ public class BlockStoreConversionXDirectory implements Runnable { return; } - this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); + this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); return; } 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 5b183b6dc..34a9245f8 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 @@ -42,7 +42,7 @@ public class BlockStoreConversionZDirectory implements Runnable { return; } - this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); + this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); return; } 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 8e44e9774..cba499eb4 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -486,7 +486,7 @@ public final class CombatUtils { } if (baseXP != 0) { - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target), 0); + mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target), 0); } } From 399bf8e3b99fd909f906a9e2c27b7bbb503474a6 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 20 Mar 2013 03:11:16 -0400 Subject: [PATCH 94/94] Use BukkitRunnable. --- .../commands/database/MmoupdateCommand.java | 2 +- .../commands/player/McrankCommand.java | 2 +- .../nossr50/commands/player/MctopCommand.java | 2 +- .../nossr50/database/DatabaseManager.java | 2 +- .../nossr50/listeners/BlockListener.java | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 23 +++++---- .../nossr50/runnables/SaveTimerTask.java | 7 ++- .../runnables/StickyPistonTrackerTask.java | 3 +- .../commands/McrankCommandAsyncTask.java | 39 ++------------- .../commands/McrankCommandDisplayTask.java | 50 +++++++++++++++++++ .../commands/MctopCommandAsyncTask.java | 30 ++--------- .../commands/MctopCommandDisplayTask.java | 48 ++++++++++++++++++ .../runnables/database/SQLConversionTask.java | 4 +- .../runnables/database/SQLReconnectTask.java | 3 +- .../runnables/database/UserPurgeTask.java | 4 +- .../runnables/party/PartyAutoKickTask.java | 3 +- .../runnables/party/PartyLoaderTask.java | 4 +- .../player/PlayerProfileSaveTask.java | 4 +- .../runnables/skills/AwardCombatXpTask.java | 3 +- .../runnables/skills/BleedTimerTask.java | 3 +- .../skills/HerbalismBlockUpdaterTask.java | 3 +- .../runnables/skills/SkillMonitorTask.java | 4 +- .../nossr50/skills/archery/TrackedEntity.java | 12 ++--- .../skills/herbalism/HerbalismManager.java | 2 +- .../nossr50/util/skills/CombatUtils.java | 2 +- 25 files changed, 159 insertions(+), 102 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java create mode 100644 src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java diff --git a/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java b/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java index 6c819920a..8492ac34e 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java @@ -46,6 +46,6 @@ public class MmoupdateCommand implements CommandExecutor { return; } - mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1); + new SQLConversionTask().runTaskLaterAsynchronously(mcMMO.p, 1); } } 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 a17639bc6..760afc788 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -104,6 +104,6 @@ public class McrankCommand implements CommandExecutor { } private void sqlDisplay(CommandSender sender, String playerName) { - mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new McrankCommandAsyncTask(playerName, sender)); + new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p); } } 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 794a1934f..4d9b63f22 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -111,7 +111,7 @@ public class MctopCommand implements CommandExecutor { } private void sqlDisplay(int page, String query, CommandSender sender) { - mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender)); + new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p); } private boolean extractSkill(CommandSender sender, String skillName) { diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 45cba591a..89c630285 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -336,7 +336,7 @@ public final class DatabaseManager { if (connection != null && !connection.isClosed()) { // Schedule a database save if we really had an outage if (reconnectAttempt > 1) { - mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new SQLReconnectTask(), 5); + new SQLReconnectTask().runTaskLater(mcMMO.p, 5); } nextReconnectTimestamp = 0; reconnectAttempt = 0; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 0998b3cb1..46b859b7f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -88,7 +88,7 @@ public class BlockListener implements Listener { public void onBlockPistonRetract(BlockPistonRetractEvent event) { if (event.isSticky()) { // Needed only because under some circumstances Minecraft doesn't move the block - plugin.getServer().getScheduler().runTaskLater(plugin, new StickyPistonTrackerTask(event), 2); + new StickyPistonTrackerTask(event).runTaskLater(plugin, 2); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 9381d9c73..0af3fe9f4 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -13,7 +13,6 @@ 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; @@ -402,42 +401,44 @@ public class mcMMO extends JavaPlugin { } private void scheduleTasks() { - BukkitScheduler scheduler = getServer().getScheduler(); - // Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException - scheduler.runTaskLater(this, new PartyLoaderTask(), 0); + new PartyLoaderTask().runTaskLater(this, 0); // Periodic save timer (Saves every 10 minutes by default) long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200; - scheduler.runTaskTimer(this, new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks); + new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks); + // Regen & Cooldown timer (Runs every second) - scheduler.runTaskTimer(this, new SkillMonitorTask(), 20, 20); + new SkillMonitorTask().runTaskTimer(this, 20, 20); + // Bleed timer (Runs every two seconds) - scheduler.runTaskTimer(this, new BleedTimerTask(), 40, 40); + new BleedTimerTask().runTaskTimer(this, 40, 40); // Old & Powerless User remover int purgeInterval = Config.getInstance().getPurgeInterval(); + UserPurgeTask userPurgeTask = new UserPurgeTask(); if (purgeInterval == 0) { - scheduler.runTaskLater(this, new UserPurgeTask(), 40); // Start 2 seconds after startup. + userPurgeTask.runTaskLater(this, 40); } else if (purgeInterval > 0) { long purgeIntervalTicks = purgeInterval * 60 * 60 * 20; - scheduler.runTaskTimer(this, new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks); + userPurgeTask.runTaskTimer(this, purgeIntervalTicks, purgeIntervalTicks); } // Automatically remove old members from parties long kickInterval = Config.getInstance().getAutoPartyKickInterval(); + PartyAutoKickTask partyAutoKickTask = new PartyAutoKickTask(); if (kickInterval == 0) { - scheduler.runTaskLater(this, new PartyAutoKickTask(), 40); // Start 2 seconds after startup. + partyAutoKickTask.runTaskLater(this, 40); // Start 2 seconds after startup. } else if (kickInterval > 0) { long kickIntervalTicks = kickInterval * 60 * 60 * 20; - scheduler.runTaskTimer(this, new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks); + partyAutoKickTask.runTaskTimer(this, kickIntervalTicks, kickIntervalTicks); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java index 1b1aaaf79..a1652250d 100644 --- a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.runnables; -import org.bukkit.scheduler.BukkitScheduler; +import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.player.McMMOPlayer; @@ -8,15 +8,14 @@ import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask; import com.gmail.nossr50.util.player.UserManager; -public class SaveTimerTask implements Runnable { +public class SaveTimerTask extends BukkitRunnable { @Override public void run() { // All player data will be saved periodically through this int count = 1; - BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler(); for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) { - bukkitScheduler.runTaskLater(mcMMO.p, new PlayerProfileSaveTask(mcMMOPlayer), count); + new PlayerProfileSaveTask(mcMMOPlayer).runTaskLater(mcMMO.p, count); count++; } diff --git a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java index fcdda3c43..76a5716a3 100644 --- a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java @@ -3,10 +3,11 @@ package com.gmail.nossr50.runnables; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; -public class StickyPistonTrackerTask implements Runnable { +public class StickyPistonTrackerTask extends BukkitRunnable { BlockPistonRetractEvent event; public StickyPistonTrackerTask(BlockPistonRetractEvent event) { diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java index eb7338320..6010e5a4e 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -3,16 +3,12 @@ package com.gmail.nossr50.runnables.commands; import java.util.Map; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.database.DatabaseManager; -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 McrankCommandAsyncTask implements Runnable { +public class McrankCommandAsyncTask extends BukkitRunnable { private final String playerName; private final CommandSender sender; @@ -23,35 +19,8 @@ public class McrankCommandAsyncTask implements Runnable { @Override public void run() { - final Map skills = DatabaseManager.readSQLRank(playerName); + Map skills = DatabaseManager.readSQLRank(playerName); - mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() { - @Override - public void run() { - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName)); - - for (SkillType skillType : SkillType.values()) { - if ((sender instanceof Player && !Permissions.skillEnabled(sender, skillType)) || skillType.isChildSkill()) { - continue; - } - - if (skills.get(skillType.name()) == null) { - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), skills.get(skillType.name()))); - } - } - - if (skills.get("ALL") == null) { - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked"))); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", skills.get("ALL"))); - } - } - - }, 1L); + new McrankCommandDisplayTask(skills, sender, playerName).runTaskLater(mcMMO.p, 1); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java new file mode 100644 index 000000000..5b18d86d4 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java @@ -0,0 +1,50 @@ +package com.gmail.nossr50.runnables.commands; + +import java.util.Map; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +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 McrankCommandDisplayTask extends BukkitRunnable { + private final Map skills; + private final CommandSender sender; + private final String playerName; + + public McrankCommandDisplayTask(Map skills, CommandSender sender, String playerName) { + this.skills = skills; + this.sender = sender; + this.playerName = playerName; + } + + @Override + public void run() { + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName)); + + for (SkillType skillType : SkillType.values()) { + if ((sender instanceof Player && !Permissions.skillEnabled(sender, skillType)) || skillType.isChildSkill()) { + continue; + } + + if (skills.get(skillType.name()) == null) { + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), skills.get(skillType.name()))); + } + } + + if (skills.get("ALL") == null) { + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked"))); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", skills.get("ALL"))); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java index 1d35f68ab..3865896a1 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java @@ -3,16 +3,14 @@ package com.gmail.nossr50.runnables.commands; import java.util.ArrayList; import java.util.HashMap; -import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; +import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.DatabaseManager; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.StringUtils; -public class MctopCommandAsyncTask implements Runnable { +public class MctopCommandAsyncTask extends BukkitRunnable { private CommandSender sender; private String query; @@ -28,30 +26,8 @@ public class MctopCommandAsyncTask implements Runnable { public void run() { String tablePrefix = Config.getInstance().getMySQLTablePrefix(); 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"); - mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() { - @Override - public void run() { - if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { - sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query))); - } - int place = (page * 10) - 9; - for (int i = 1; i <= 10; i++) { - if (userslist.get(i) == null) { - break; - } - - // Format: 1. Playername - skill value - sender.sendMessage(place + ". " + ChatColor.GREEN + userslist.get(i).get(1) + " - " + ChatColor.WHITE + userslist.get(i).get(0)); - place++; - } - - sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip")); - } - }, 1L); + new MctopCommandDisplayTask(userslist, page, tablePrefix, sender).runTaskLater(mcMMO.p, 1); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java new file mode 100644 index 000000000..6fd9e1ef2 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java @@ -0,0 +1,48 @@ +package com.gmail.nossr50.runnables.commands; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.scheduler.BukkitRunnable; + +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.StringUtils; + +public class MctopCommandDisplayTask extends BukkitRunnable { + private HashMap> userslist; + private CommandSender sender; + private String query; + private int page; + + public MctopCommandDisplayTask(HashMap> userslist, int page, String query, CommandSender sender) { + this.userslist = userslist; + this.page = page; + this.query = query; + this.sender = sender; + } + + @Override + public void run() { + if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { + sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query))); + } + + int place = (page * 10) - 9; + for (int i = 1; i <= 10; i++) { + if (userslist.get(i) == null) { + break; + } + + // Format: 1. Playername - skill value + sender.sendMessage(place + ". " + ChatColor.GREEN + userslist.get(i).get(1) + " - " + ChatColor.WHITE + userslist.get(i).get(0)); + place++; + } + + sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip")); + } +} diff --git a/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java index e2a840519..c1f34aac6 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/SQLConversionTask.java @@ -3,13 +3,15 @@ package com.gmail.nossr50.runnables.database; import java.io.BufferedReader; import java.io.FileReader; +import org.bukkit.scheduler.BukkitRunnable; + 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 { +public class SQLConversionTask extends BukkitRunnable { private String tablePrefix = Config.getInstance().getMySQLTablePrefix(); @Override diff --git a/src/main/java/com/gmail/nossr50/runnables/database/SQLReconnectTask.java b/src/main/java/com/gmail/nossr50/runnables/database/SQLReconnectTask.java index e4896a3c4..56904c1b4 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/SQLReconnectTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/SQLReconnectTask.java @@ -1,12 +1,13 @@ package com.gmail.nossr50.runnables.database; import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.util.player.UserManager; -public class SQLReconnectTask implements Runnable { +public class SQLReconnectTask extends BukkitRunnable { @Override public void run() { if (DatabaseManager.checkConnected()) { diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java index d0d1dc261..0206c054f 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java @@ -1,10 +1,12 @@ package com.gmail.nossr50.runnables.database; +import org.bukkit.scheduler.BukkitRunnable; + import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.database.LeaderboardManager; -public class UserPurgeTask implements Runnable { +public class UserPurgeTask extends BukkitRunnable { @Override public void run() { if (Config.getInstance().getUseMySQL()) { diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java index 5a78978c5..432615862 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java @@ -3,12 +3,13 @@ package com.gmail.nossr50.runnables.party; import java.util.Iterator; import org.bukkit.OfflinePlayer; +import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.party.PartyManager; -public class PartyAutoKickTask implements Runnable { +public class PartyAutoKickTask extends BukkitRunnable { @Override public void run() { updatePartyMembers(); diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyLoaderTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyLoaderTask.java index 2f8986d27..4a7a2ee41 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyLoaderTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyLoaderTask.java @@ -1,8 +1,10 @@ package com.gmail.nossr50.runnables.party; +import org.bukkit.scheduler.BukkitRunnable; + import com.gmail.nossr50.party.PartyManager; -public class PartyLoaderTask implements Runnable { +public class PartyLoaderTask extends BukkitRunnable { @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 index 6ed2f1c91..76b0ea4a2 100644 --- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java @@ -1,10 +1,12 @@ package com.gmail.nossr50.runnables.player; +import org.bukkit.scheduler.BukkitRunnable; + 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 { +public class PlayerProfileSaveTask extends BukkitRunnable { private McMMOPlayer mcMMOPlayer; private PlayerProfile playerProfile; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java index 645193c9b..883f1e890 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java @@ -1,11 +1,12 @@ package com.gmail.nossr50.runnables.skills; import org.bukkit.entity.LivingEntity; +import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SkillType; -public class AwardCombatXpTask implements Runnable { +public class AwardCombatXpTask extends BukkitRunnable { private McMMOPlayer mcMMOPlayer; private double baseXp; private SkillType skillType; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index 768ec5d8b..4ac8c2c00 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -7,12 +7,13 @@ import java.util.Map.Entry; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; -public class BleedTimerTask implements Runnable { +public class BleedTimerTask extends BukkitRunnable { private final static int MAX_BLEED_TICKS = 10; private static Map bleedList = new HashMap(); diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java index 5674273a3..38f5eb84d 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java @@ -1,8 +1,9 @@ package com.gmail.nossr50.runnables.skills; import org.bukkit.block.BlockState; +import org.bukkit.scheduler.BukkitRunnable; -public class HerbalismBlockUpdaterTask implements Runnable { +public class HerbalismBlockUpdaterTask extends BukkitRunnable { private BlockState blockState; public HerbalismBlockUpdaterTask(BlockState blockState) { 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 4dbc73a52..916499f74 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java @@ -1,12 +1,14 @@ package com.gmail.nossr50.runnables.skills; +import org.bukkit.scheduler.BukkitRunnable; + 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.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; -public class SkillMonitorTask implements Runnable { +public class SkillMonitorTask extends BukkitRunnable { @Override public void run() { long curTime = System.currentTimeMillis(); 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 c6faab97e..ef7e7993c 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java @@ -3,29 +3,27 @@ package com.gmail.nossr50.skills.archery; import java.util.UUID; import org.bukkit.entity.LivingEntity; -import org.bukkit.scheduler.BukkitScheduler; +import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; -public class TrackedEntity implements Runnable { +public class TrackedEntity extends BukkitRunnable { 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.runTaskTimer(mcMMO.p, this, 12000, 12000).getTaskId(); + + this.runTaskTimer(mcMMO.p, 12000, 12000); } @Override public void run() { if (!livingEntity.isValid()) { Archery.removeFromTracker(this); - scheduler.cancelTask(taskId); + this.cancel(); } } 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 27b4e33ee..4479e9661 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -289,7 +289,7 @@ public class HerbalismManager extends SkillManager { playerInventory.removeItem(seed); player.updateInventory(); // Needed until replacement available - mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new HerbalismBlockUpdaterTask(blockState), 0); + new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0); } private boolean handleBlockState(BlockState blockState, boolean greenTerra) { 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 cba499eb4..8c6d95b02 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -486,7 +486,7 @@ public final class CombatUtils { } if (baseXP != 0) { - mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target), 0); + new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target).runTaskLater(mcMMO.p, 0); } }