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/.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/Changelog.txt b/Changelog.txt index 69f728fa5..6d6632179 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,8 +7,48 @@ Key: ! Change - Removal -Version 1.4.03-dev +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 + = 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 + +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 + = 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 + = 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 + = 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 + = 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!) + = 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 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. Version 1.4.02 + Added API to get the skill and power level caps. diff --git a/pom.xml b/pom.xml index 9e7f242c9..dab7f3382 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.04-dev1 mcMMO https://github.com/mcMMO-Dev/mcMMO 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 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. * diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index f535308f2..710d7b698 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -1,30 +1,18 @@ 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; 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. *
@@ -39,18 +27,18 @@ public final class ExperienceAPI { } /** - * Adds XP to the player, calculates for XP Rate only. + * Adds raw XP to an offline player. *
* This function is designed for API usage. * - * @param player The player to add XP to + * @param playerName 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 + * + * @throws InvalidPlayerException if the given player does not exist in the database */ - @Deprecated - public static void addMultipliedXP(Player player, SkillType skillType, int XP) { - UserManager.getPlayer(player).applyXpGain(skillType, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier())); + public static void addRawXPOffline(String playerName, String skillType, int XP) { + addOfflineXP(playerName, skillType, XP); } /** @@ -67,18 +55,48 @@ public final class ExperienceAPI { } /** - * Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party. + * 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 - * @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); + 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())); } /** @@ -94,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. *
@@ -123,18 +126,17 @@ public final class ExperienceAPI { } /** - * Get the amount of XP left before leveling up. + * Get the amount of XP an offline player has in a specific skill. *
* 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 + * @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 */ - @Deprecated - public static int getXPToNextLevel(Player player, SkillType skillType) { - return UserManager.getPlayer(player).getProfile().getXpToLevel(skillType); + public static int getOfflineXP(String playerName, String skillType) { + return getOfflineProfile(playerName).getSkillXpLevel(SkillType.getSkill(skillType)); } /** @@ -151,37 +153,17 @@ public final class ExperienceAPI { } /** - * Add levels to a skill. + * Get the amount of XP an offline player has left before leveling up. *
* 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 + * @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 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); + public static int getOfflineXPToNextLevel(String playerName, String skillType) { + return getOfflineProfile(playerName).getXpToLevel(SkillType.getSkill(skillType)); } /** @@ -198,18 +180,34 @@ public final class ExperienceAPI { } /** - * Get the level a player has in a specific skill. + * Add levels to a skill for an offline player. *
* 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 + * @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 */ - @Deprecated - public static int getLevel(Player player, SkillType skillType) { - return UserManager.getPlayer(player).getProfile().getSkillLevel(skillType); + 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(); } /** @@ -225,6 +223,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 +249,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. *
@@ -260,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. *
@@ -289,18 +310,18 @@ public final class ExperienceAPI { } /** - * Sets the XP of a player in a specific skill type. + * Sets the level of an offline 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 + * @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 */ - @Deprecated - public static void setXP(Player player, SkillType skillType, int newValue) { - UserManager.getPlayer(player).getProfile().setSkillXpLevel(skillType, newValue); + public static void setLevelOffline(String playerName, String skillType, int skillLevel) { + getOfflineProfile(playerName).modifySkill(SkillType.getSkill(skillType), skillLevel); } /** @@ -317,18 +338,18 @@ public final class ExperienceAPI { } /** - * Removes XP from a player in a specific skill type. + * Sets the XP of an offline 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 + * @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 */ - @Deprecated - public static void removeXP(Player player, SkillType skillType, int xp) { - UserManager.getPlayer(player).getProfile().removeXp(skillType, xp); + public static void setXPOffline(String playerName, String skillType, int newValue) { + getOfflineProfile(playerName).setSkillXpLevel(SkillType.getSkill(skillType), newValue); } /** @@ -345,14 +366,54 @@ public final class ExperienceAPI { } /** - * Check the XP of a player. This should be called after giving XP to process level-ups. + * Removes XP from an offline player in a specific skill type. + *
+ * This function is designed for API usage. * - * @param player The player to check - * @param skillType The skill to check - * @deprecated Calling this function is no longer needed and should be avoided + * @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 */ - @Deprecated - private static void checkXP(Player player, SkillType skillType) { - SkillUtils.xpCheckSkill(skillType, player, UserManager.getProfile(player)); + public static void removeXPOffline(String playerName, String skillType, int xp) { + getOfflineProfile(playerName).removeXp(SkillType.getSkill(skillType), xp); + } + + /** + * 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/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index e0c83c36e..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; @@ -19,9 +18,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(); } @@ -116,26 +119,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. *
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/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")); 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 89372157e..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,15 +3,16 @@ package com.gmail.nossr50.commands.chat; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import com.gmail.nossr50.chat.ChatMode; import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +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; @@ -21,11 +22,11 @@ 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); + mcMMOPlayer = UserManager.getPlayer(sender.getName()); if (chatMode.isEnabled(mcMMOPlayer)) { disableChatMode(sender); @@ -37,20 +38,24 @@ public abstract class ChatCommand implements CommandExecutor { return true; case 1: - if (args[0].equalsIgnoreCase("on")) { - if (!(sender instanceof Player)) { - return false; + if (CommandUtils.shouldEnableToggle(args[0])) { + if (CommandUtils.noConsoleUsage(sender)) { + return true; } + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + enableChatMode(sender); return true; } - if (args[0].equalsIgnoreCase("off")) { - if (!(sender instanceof Player)) { - return false; + if (CommandUtils.shouldDisableToggle(args[0])) { + if (CommandUtils.noConsoleUsage(sender)) { + return true; } + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + disableChatMode(sender); return true; } @@ -78,11 +83,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()); } 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/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/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..f3a3a5cfb 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,47 @@ 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; + private int argsLength; + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - PlayerProfile profile; - boolean allSkills = false; - SkillType skill = null; - String skillName = ""; + this.command = command; + this.sender = sender; + argsLength = args.length; 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(); - - 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)); - } + mcMMOPlayer = UserManager.getPlayer(sender.getName()); + player = mcMMOPlayer.getPlayer(); + profile = mcMMOPlayer.getProfile(); + editValues(); return true; case 2: @@ -79,91 +50,67 @@ 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); - } - + editValues(); profile.save(); // Since this is a temporary profile, we save it here. } else { profile = mcMMOPlayer.getProfile(); + player = mcMMOPlayer.getPlayer(); - 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 (argsLength == 1 && !Permissions.skillreset(sender, skill) || (argsLength == 2 && !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 8f765dc0f..b0387941d 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) { @@ -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()) { @@ -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; } @@ -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 d079b5426..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().equals(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; @@ -97,6 +101,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/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 0072863cd..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,33 +15,36 @@ 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; } - 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/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 5e0e60cad..760afc788 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -1,10 +1,8 @@ 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; -import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; @@ -14,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; @@ -24,20 +22,19 @@ public class McrankCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: - if (!Permissions.mcrank(sender)) { - sender.sendMessage(command.getPermissionMessage()); + if (CommandUtils.noConsoleUsage(sender)) { return true; } - if (!(sender instanceof Player)) { - return false; + if (!Permissions.mcrank(sender)) { + sender.sendMessage(command.getPermissionMessage()); + return true; } if (Config.getInstance().getUseMySQL()) { sqlDisplay(sender, sender.getName()); } else { - LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date flatfileDisplay(sender, sender.getName()); } @@ -52,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]); } @@ -89,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 (skillType.isChildSkill()) { + if (!Permissions.skillEnabled(sender, skillType) || skillType.isChildSkill()) { continue; } @@ -119,6 +104,6 @@ public class McrankCommand implements CommandExecutor { } private void sqlDisplay(CommandSender sender, String playerName) { - Bukkit.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/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 d0fcea9e5..4d9b63f22 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; @@ -14,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); @@ -29,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: @@ -73,28 +59,26 @@ public class MctopCommand implements CommandExecutor { } private void display(int page, String skill, CommandSender sender, boolean sql, Command command) { - if (sql) { - if (skill.equalsIgnoreCase("all")) { - sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command); - } - else { - sqlDisplay(page, skill, sender, command); - } - } - else { - flatfileDisplay(page, skill, sender, command); - } - } - - private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) { - if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) { + if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) { sender.sendMessage(command.getPermissionMessage()); return; } - LeaderboardManager.updateLeaderboards(); // Make sure we have the latest information + if (sql) { + if (skill.equalsIgnoreCase("all")) { + sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender); + } + else { + sqlDisplay(page, skill, sender); + } + } + else { + flatfileDisplay(page, skill, sender); + } + } - String[] info = LeaderboardManager.retrieveInfo(skill, page); + private void flatfileDisplay(int page, String skill, CommandSender sender) { + LeaderboardManager.updateLeaderboards(); // Make sure we have the latest information if (skill.equalsIgnoreCase("all")) { sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); @@ -103,27 +87,44 @@ 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")); } - private void sqlDisplay(int page, String query, CommandSender sender, Command command) { - Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command)); + private void sqlDisplay(int page, String query, CommandSender sender) { + new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p); + } + + 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 a05c16527..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,13 +5,13 @@ 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; -import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.util.Permissions; public class RepairCommand extends SkillCommand { - private int arcaneForgingRank; private String repairMasteryBonus; private String superRepairChance; private String superRepairChanceLucky; @@ -41,10 +41,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(); @@ -53,20 +53,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 = Repair.getArcaneForgingRank(profile); + if (canSuperRepair) { + String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance); + superRepairChance = superRepairStrings[0]; + superRepairChanceLucky = superRepairStrings[1]; + } } @Override @@ -122,8 +118,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) { @@ -143,23 +139,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(); - if (Repair.arcaneForgingEnchantLoss) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank)))); + player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank())); + + if (ArcaneForging.arcaneForgingEnchantLoss) { + 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 : Repair.getDowngradeChance(arcaneForgingRank)))); + if (ArcaneForging.arcaneForgingDowngrades) { + 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 1c7ee9654..c3661163b 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; @@ -8,9 +9,11 @@ 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; +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; @@ -20,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; @@ -31,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 @@ -42,86 +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(); - - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString(skillString + ".SkillName"))); - - if (!skill.isChildSkill()) { - player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + skillString))); - player.sendMessage(LocaleLoader.getString("Effects.Level", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill))); - } - - if (effectsHeaderPermissions()) { - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); - } - - effectsDisplay(); - - if (statsHeaderPermissions()) { - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self"))); - } - - statsDisplay(); - - return SkillGuideCommand.grabGuidePageForSkill(skill, player, args); } - protected String calculateRank(int maxLevel, int rankChangeLevel) { - if (skillValue >= maxLevel) { - return String.valueOf(maxLevel / rankChangeLevel); - } - - return String.valueOf((int) (skillValue / rankChangeLevel)); + protected 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 / maxBonusLevel) * Math.min(skillValue, maxBonusLevel)); } protected String[] calculateLengthDisplayValues() { @@ -130,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) }; @@ -141,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/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index d1c3cdec4..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); } @@ -178,6 +179,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 86d6ee56b..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); } @@ -183,9 +186,7 @@ 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); } public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); } @@ -199,8 +200,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/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 138599fe5..89c630285 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; @@ -340,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); + new SQLReconnectTask().runTaskLater(mcMMO.p, 5); } nextReconnectTimestamp = 0; reconnectAttempt = 0; @@ -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/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) { 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..2385ccd12 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -28,10 +28,13 @@ 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.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; @@ -65,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; @@ -76,6 +79,7 @@ public class McMMOPlayer { private Map toolATS = new HashMap(); private int recentlyHurt; + private int chimaeraWing; private int respawnATS; public McMMOPlayer(Player player) { @@ -92,12 +96,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) { @@ -144,6 +143,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); } @@ -160,6 +163,10 @@ public class McMMOPlayer { return (UnarmedManager) skillManagers.get(SkillType.UNARMED); } + public WoodcuttingManager getWoodcuttingManager() { + return (WoodcuttingManager) skillManagers.get(SkillType.WOODCUTTING); + } + /* * Abilities */ @@ -292,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 */ @@ -308,24 +332,26 @@ public class McMMOPlayer { * Repair Anvil Placement */ - public void togglePlacedAnvil() { - placedAnvil = !placedAnvil; + public boolean getPlacedAnvil(int anvilId) { + if (anvilId == Repair.repairAnvilId) { + return placedRepairAnvil; + } + + if (anvilId == Repair.salvageAnvilId) { + return placedSalvageAnvil; + } + + return true; } - public Boolean getPlacedAnvil() { - return placedAnvil; - } + public void togglePlacedAnvil(int anvilId) { + if (anvilId == Repair.repairAnvilId) { + placedRepairAnvil = !placedRepairAnvil; + } - /* - * Salvage Anvil Placement - */ - - public void togglePlacedSalvageAnvil() { - placedSalvageAnvil = !placedSalvageAnvil; - } - - public Boolean getPlacedSalvageAnvil() { - return placedSalvageAnvil; + if (anvilId == Repair.salvageAnvilId) { + placedSalvageAnvil = !placedSalvageAnvil; + } } /* @@ -423,6 +449,19 @@ public class McMMOPlayer { * @param xp Experience amount to add */ 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); 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..f227e2de3 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 { @@ -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/datatypes/skills/SkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java index 565ee66de..9a2146aca 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java @@ -11,10 +11,12 @@ 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; import com.gmail.nossr50.skills.unarmed.UnarmedManager; +import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.StringUtils; public enum SkillType { @@ -25,12 +27,12 @@ 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), 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 930a6dbc0..46b859b7f 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; @@ -35,10 +33,9 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; -import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.smelting.SmeltingManager; -import com.gmail.nossr50.skills.unarmed.Unarmed; -import com.gmail.nossr50.skills.woodcutting.Woodcutting; +import com.gmail.nossr50.skills.unarmed.UnarmedManager; +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; @@ -91,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); + new StickyPistonTrackerTask(event).runTaskLater(plugin, 2); } } @@ -109,21 +106,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) { - int blockID = blockState.getTypeId(); - - if (blockID == Repair.anvilID) { - Repair.placedAnvilCheck(player, blockID); - } - else if (blockID == Salvage.anvilID) { - Salvage.placedAnvilCheck(player, blockID); - } + if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) { + UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId); } } @@ -146,12 +137,11 @@ public class BlockListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); BlockState blockState = event.getBlock().getState(); - ItemStack heldItem = player.getItemInHand(); /* HERBALISM */ if (BlockUtils.affectedByGreenTerra(blockState)) { - HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager(); + HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); /* Green Terra */ if (herbalismManager.canActivateAbility()) { @@ -163,47 +153,31 @@ 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); - } } } /* 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)) { - miningManager.miningBlockCheck(blockState); - } } /* 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); } } /* 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)) { @@ -368,24 +342,18 @@ 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(); } } } - 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 (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); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 88f293b9a..b0c4fa62b 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) { - ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); + if (furnaceState instanceof Furnace) { + ItemStack smelting = ((Furnace) furnaceState).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) { - ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting(); + if (furnaceState instanceof Furnace) { + ItemStack smelting = ((Furnace) furnaceState).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; @@ -123,13 +132,19 @@ public class InventoryListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFurnaceExtractEvent(FurnaceExtractEvent event) { - BlockState furnaceBlock = event.getBlock().getState(); + Block furnaceBlock = event.getBlock(); + BlockState furnaceState = furnaceBlock.getState(); - if (furnaceBlock instanceof Furnace) { - ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult(); + if (furnaceState instanceof Furnace) { + ItemStack result = ((Furnace) furnaceState).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()); + + if (Misc.isNPCEntity(player)) { + return; + } SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager(); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 76760c682..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,14 +284,14 @@ 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.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)) { - Salvage.handleSalvage(player, block.getLocation(), 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/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 17b43990c..0af3fe9f4 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -8,15 +8,11 @@ import java.util.List; import net.shatteredlands.shatt.backup.ZipLibrary; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitScheduler; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; @@ -29,7 +25,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; @@ -45,10 +40,11 @@ import com.gmail.nossr50.runnables.party.PartyLoaderTask; import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.runnables.skills.SkillMonitorTask; import com.gmail.nossr50.skills.child.ChildConfig; -import com.gmail.nossr50.skills.repair.RepairManager; -import com.gmail.nossr50.skills.repair.RepairManagerFactory; import com.gmail.nossr50.skills.repair.Repairable; +import com.gmail.nossr50.skills.repair.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; @@ -66,12 +62,11 @@ 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; public static ChunkManager placeStore; - public static RepairManager repairManager; + public static RepairableManager repairableManager; // Jar Stuff public static File mcmmo; @@ -95,6 +90,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. @@ -115,6 +111,7 @@ public class mcMMO extends JavaPlugin { } registerEvents(); + registerCustomRecipes(); // Setup the leader boards if (Config.getInstance().getUseMySQL()) { @@ -155,7 +152,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); } } @@ -197,43 +194,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. * @@ -273,22 +233,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; } @@ -377,8 +321,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()) { @@ -450,43 +394,51 @@ public class mcMMO extends JavaPlugin { CommandRegistrationManager.registerMchudCommand(); } - private void scheduleTasks() { - BukkitScheduler scheduler = getServer().getScheduler(); + private void registerCustomRecipes() { + if (Config.getInstance().getChimaeraEnabled()) { + getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe()); + } + } + private void scheduleTasks() { // Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException - scheduler.scheduleSyncDelayedTask(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.scheduleSyncRepeatingTask(this, new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks); + new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks); + // Regen & Cooldown timer (Runs every second) - scheduler.scheduleSyncRepeatingTask(this, new SkillMonitorTask(), 20, 20); + new SkillMonitorTask().runTaskTimer(this, 20, 20); + // Bleed timer (Runs every two seconds) - scheduler.scheduleSyncRepeatingTask(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.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); // Start 2 seconds after startup. + userPurgeTask.runTaskLater(this, 40); } else if (purgeInterval > 0) { long purgeIntervalTicks = purgeInterval * 60 * 60 * 20; - scheduler.scheduleSyncRepeatingTask(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.scheduleSyncDelayedTask(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.scheduleSyncRepeatingTask(this, new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks); + partyAutoKickTask.runTaskTimer(this, kickIntervalTicks, kickIntervalTicks); } } } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 28f1acd07..28a1782f6 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)) { @@ -75,7 +84,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); } } @@ -122,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()); } /** @@ -150,7 +165,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 +199,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 +389,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 +411,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; } @@ -488,13 +503,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(); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java index 8a1af3760..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.scheduleSyncDelayedTask(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 85ff65364..6010e5a4e 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -2,16 +2,13 @@ package com.gmail.nossr50.runnables.commands; import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +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.skills.SkillUtils; -public class McrankCommandAsyncTask implements Runnable { +public class McrankCommandAsyncTask extends BukkitRunnable { private final String playerName; private final CommandSender sender; @@ -22,35 +19,8 @@ public class McrankCommandAsyncTask implements Runnable { @Override public void run() { - final Map skills = DatabaseManager.readSQLRank(playerName); + Map skills = DatabaseManager.readSQLRank(playerName); - Bukkit.getScheduler().scheduleSyncDelayedTask(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 (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 9d04d98c6..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,67 +3,31 @@ 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; +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.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 { +public class MctopCommandAsyncTask extends BukkitRunnable { 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"); - Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { - @Override - public void run() { - if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { - sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); - } - else { - 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 8297772f7..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 @@ -55,7 +57,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/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 new file mode 100644 index 000000000..38f5eb84d --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java @@ -0,0 +1,17 @@ +package com.gmail.nossr50.runnables.skills; + +import org.bukkit.block.BlockState; +import org.bukkit.scheduler.BukkitRunnable; + +public class HerbalismBlockUpdaterTask extends BukkitRunnable { + 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/SkillMonitorTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/SkillMonitorTask.java index dffbba9ca..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,27 +1,19 @@ package com.gmail.nossr50.runnables.skills; -import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; -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; -public class SkillMonitorTask implements Runnable { +public class SkillMonitorTask extends BukkitRunnable { @Override 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 */ 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/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/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java index 267f80ba9..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.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000); + + 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/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index a985c37d2..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. } } @@ -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; } 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..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,24 +63,20 @@ 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 = 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++) { 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)) { + 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 f1546ab0b..4479e9661 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; @@ -76,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); } /** @@ -107,65 +108,63 @@ 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(); + Material material = blockState.getType(); + boolean oneBlockPlant = (material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK) ? false : true; - HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType); - CustomBlock customBlock = null; + if (oneBlockPlant && mcMMO.placeStore.isTrue(blockState)) { + return; + } + HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(material); + ItemStack drop = null; + int amount = 1; int xp = 0; - int dropAmount = 1; - ItemStack dropItem = null; + boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility()); 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 (!oneBlockPlant) { + 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 +268,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 + new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 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(skill), Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4); } } 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..f9d463dc3 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: @@ -76,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; } @@ -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..6e8151259 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,31 @@ 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); - } + applyXpGain(Mining.getBlockXp(blockState)); + + if (!Permissions.doubleDrops(player, skill)) { + return; } - applyXpGain(xp); + Material material = blockState.getType(); + + if (material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) { + return; + } + + 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 (silkTouch) { + Mining.handleSilkTouchDrops(blockState); + } + else { + Mining.handleMiningDrops(blockState); + } + } + } } /** @@ -128,11 +142,10 @@ 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++) { - xp += Mining.getBlockXp(blockState); Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items } } @@ -142,7 +155,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)); } } } @@ -160,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)); } /** 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 b8e658c93..5a7caa9bf 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -1,27 +1,13 @@ 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; +import com.gmail.nossr50.util.ItemUtils; public class Repair { public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel(); @@ -30,251 +16,164 @@ public class Repair { 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 anvilID = Config.getInstance().getRepairAnvilId(); + public static int salvageAnvilId = Config.getInstance().getSalvageAnvilId(); + public static int repairAnvilId = Config.getInstance().getRepairAnvilId(); public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled(); /** - * Get current Arcane Forging rank. + * Checks if the item is salvageable. * - * @param profile The PlayerProfile of the player to get the rank for - * @return The player's current Arcane Forging rank + * @param item Item to check + * @return true if the item is salvageable, false otherwise */ - public static int getArcaneForgingRank(PlayerProfile profile) { - int skillLevel = profile.getSkillLevel(SkillType.REPAIR); - - if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels4()) { - return 4; + public static boolean isSalvageable(ItemStack item) { + if (Config.getInstance().getSalvageTools() && (ItemUtils.isMinecraftTool(item) || ItemUtils.isStringTool(item) || item.getType() == Material.BUCKET)) { + return true; } - else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels3()) { + + if (Config.getInstance().getSalvageArmor() && ItemUtils.isMinecraftArmor(item)) { + return true; + } + + return false; + } + + /** + * 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 + */ + protected static 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 + */ + protected static int findInInventory(PlayerInventory inventory, int itemId, byte metadata) { + int location = -1; + + ItemStack[] contents = inventory.getContents(); + + for (int i = 0; i < contents.length; i++) { + ItemStack item = contents[i]; + + if (item == null) { + continue; + } + + if (item.getTypeId() == itemId && item.getData().getData() == metadata) { + return i; + } + } + + return location; + } + + /** + * Decrease the amount of items in this slot by one + * + * @param inventory PlayerInventory to work in + * @param index Item index to decrement + */ + protected static void removeOneFrom(PlayerInventory inventory, int index) { + ItemStack item = inventory.getItem(index).clone(); + item.setAmount(1); + + inventory.removeItem(item); + } + + protected static String[] getSpoutAnvilMessages(int blockId) { + if (blockId == repairAnvilId) { + return new String[] {LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2")}; + } + + if (blockId == salvageAnvilId) { + return new String[] {"[mcMMO] Anvil Placed", "Right click to salvage!"}; + } + + return new String[] {"", ""}; + } + + protected static String getAnvilMessage(int blockId) { + if (blockId == repairAnvilId) { + return LocaleLoader.getString("Repair.Listener.Anvil"); + } + + 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 (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels2()) { + 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 (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels1()) { - return 1; + 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; } } - - /** - * Handles removing & downgrading enchants. - * - * @param player Player repairing the item - * @param is Item being repaired - */ - protected static void addEnchants(Player player, ItemStack is) { - if (Permissions.arcaneBypass(player)) { - player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); - return; - } - Map enchants = is.getEnchantments(); - - 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); - } - 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); - } - } - - 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")); - } - } - - /** - * Gets chance of keeping enchantment during repair. - * - * @param rank Arcane Forging rank - * @return The chance of keeping the enchantment - */ - public static int getEnchantChance(int rank) { - switch (rank) { - case 4: - return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); - - 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; - } } 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..06faeed2e 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,350 @@ package com.gmail.nossr50.skills.repair; -import java.util.List; +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.ArcaneForging.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 interface RepairManager { - /** - * Register a repairable with the RepairManager - * - * @param repairable Repairable to register - */ - public void registerRepairable(Repairable repairable); +public class RepairManager extends SkillManager { + public RepairManager(McMMOPlayer mcMMOPlayer) { + super(mcMMOPlayer, SkillType.REPAIR); + } /** - * Register a list of repairables with the RepairManager + * Handles notifications for placing an anvil. * - * @param repairables List to register + * @param anvilID The item ID of the anvil block */ - public void registerRepairables(List repairables); + 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 (ArcaneForging.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")); + } + } /** - * Checks if an item is repairable + * Gets the Arcane Forging rank * - * @param itemId id to check if repairable - * @return true if repairable, false if not + * @return the current Arcane Forging rank */ - public boolean isRepairable(int itemId); + public int getArcaneForgingRank() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.toNumerical(); + } + } + + return 0; + } /** - * Checks if an item is repairable + * Gets chance of keeping enchantment during repair. * - * @param itemStack Item to check if repairable - * @return true if repairable, false if not + * @return The chance of keeping the enchantment */ - public boolean isRepairable(ItemStack itemStack); + public int getKeepEnchantChance() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getKeepEnchantChance(); + } + } + + return 0; + } /** - * Gets the repairable with this id + * Gets chance of enchantment being downgraded during repair. * - * @param id Id of the repairable to look for - * @return the repairable, can be null + * @return The chance of the enchantment being downgraded */ - public Repairable getRepairable(int id); + public int getDowngradeEnchantChance() { + int skillLevel = getSkillLevel(); + + for (Tier tier : Tier.values()) { + if (skillLevel >= tier.getLevel()) { + return tier.getDowngradeEnchantChance(); + } + } + + return 100; + } /** - * Handle the repairing of this object + * Computes repair bonuses. * - * @param mcMMOPlayer Player that is repairing an item - * @param item ItemStack that is being repaired + * @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 */ - public void handleRepair(McMMOPlayer mcMMOPlayer, ItemStack 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(); + + 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); + } + + 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 (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) { + item.addEnchantment(enchantment, enchantLevel - 1); + 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/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java deleted file mode 100644 index 912abf387..000000000 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ /dev/null @@ -1,152 +0,0 @@ -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. - * - * @param is Item to check - * @return true if the item is salvageable, false otherwise - */ - public static boolean isSalvageable(final ItemStack is) { - if (Config.getInstance().getSalvageTools() && (ItemUtils.isMinecraftTool(is) || ItemUtils.isStringTool(is) || is.getType() == Material.BUCKET)) { - return true; - } - - if (Config.getInstance().getSalvageArmor() && ItemUtils.isMinecraftArmor(is)) { - return true; - } - - return false; - } - - private static Material getSalvagedItem(final ItemStack inHand) { - if (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; - } - } - - private 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; - } - } -} 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); + } +} 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. * 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..5709e5055 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,133 @@ 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) { + inHand.setDurability(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; + } + + // Without this check Tree Feller propagates through leaves until the threshold is hit + if (BlockUtils.isLog(blockState)) { + 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..1905a76f8 --- /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); + } + +} diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 3edd77b6a..715042da7 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: @@ -92,6 +93,9 @@ public final class BlockUtils { case WORKBENCH: case BEACON: case ANVIL: + case DROPPER: + case HOPPER: + case TRAPPED_CHEST: return false; default: @@ -123,6 +127,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 +213,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/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index db05ac465..5a8dd1c4f 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -1,14 +1,23 @@ package com.gmail.nossr50.util; +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; 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 { @@ -22,42 +31,85 @@ 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(); + Location location = player.getLocation(); 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)) { + player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player))); + return; + } + + if (amount < Config.getInstance().getChimaeraUseCost()) { + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", "Chimaera Wings")); //TODO Locale! + 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)); + CombatUtils.dealDamage(player, Misc.getRandom().nextInt(player.getHealth() - 10)); + 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 { - player.teleport(player.getWorld().getSpawnLocation()); + player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation()); } + } - MetricsManager.chimeraWingUsed(); - player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass")); - } - else if (!SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) { - player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt, 60, player))); - } - else if (amount <= Config.getInstance().getChimaeraCost()) { - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Config.getInstance().getChimaeraItemId()))); - } + 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")); } } + + 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/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java index 42a72ae81..61eda995f 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().runTaskLater(mcMMO.p, new Runnable() { @Override public void run() { spawnFireworks((Player) sender); diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index db6bd9311..c0987a97d 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,32 @@ public class ItemUtils { return false; } } + + public static boolean isMcMMOItem(ItemStack is) { + if (!is.hasItemMeta()) { + return false; + } + + 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/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index e19eebde6..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(); @@ -26,6 +31,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() {}; @@ -77,7 +84,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; } @@ -159,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/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) { 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) { 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; 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); } } 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/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/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. * 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..8c6d95b02 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)) { @@ -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; @@ -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); + new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target).runTaskLater(mcMMO.p, 0); } } 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; 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..b1dbbd444 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); @@ -92,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)) { @@ -215,9 +213,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; @@ -460,22 +459,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(); @@ -493,7 +476,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); @@ -559,11 +542,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 ec35aa44a..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 ### @@ -247,6 +249,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 7466dcc75..f0361cafc 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -72,7 +72,10 @@ Mods: Items: Chimaera_Wing: Enabled: true - Feather_Cost: 10 + Cooldown: 240 + Prevent_Use_Underground: true + Use_Cost: 1 + Recipe_Cost: 5 Item_ID: 288 # @@ -160,9 +163,7 @@ Skills: Level_Cap: 0 Anvil_Messages: true Anvil_ID: 42 - Salvage_enabled: true Salvage_Anvil_ID: 41 - Salvage_UnlockLevel: 600 Salvage_tools: true Salvage_armor: true Smelting: @@ -186,7 +187,6 @@ Skills: SmoothBrick_To_CrackedBrick: true Woodcutting: Level_Cap: 0 - Requires_Axe: true # # Settings for Double Drops @@ -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: @@ -360,8 +363,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 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_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 3f4b864ab..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 @@ -566,6 +565,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 +590,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 +627,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) 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 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: